Remove the useless gui=True arg getting passed intro strings._ all over the place

This commit is contained in:
Micah Lee 2018-09-30 17:47:10 -07:00
parent fc1360a0ba
commit e6302f3ba4
12 changed files with 152 additions and 152 deletions

View file

@ -247,7 +247,7 @@ class Onion(object):
self.c = Controller.from_socket_file(path=self.tor_control_socket) self.c = Controller.from_socket_file(path=self.tor_control_socket)
self.c.authenticate() self.c.authenticate()
except Exception as e: except Exception as e:
raise BundledTorBroken(strings._('settings_error_bundled_tor_broken', True).format(e.args[0])) raise BundledTorBroken(strings._('settings_error_bundled_tor_broken').format(e.args[0]))
while True: while True:
try: try:

View file

@ -51,7 +51,7 @@ def load_strings(common):
strings[s] = translations[default_locale][s] strings[s] = translations[default_locale][s]
def translated(k, gui=False): def translated(k):
""" """
Returns a translated string. Returns a translated string.
""" """

View file

@ -100,10 +100,10 @@ def main():
valid = True valid = True
for filename in filenames: for filename in filenames:
if not os.path.isfile(filename) and not os.path.isdir(filename): if not os.path.isfile(filename) and not os.path.isdir(filename):
Alert(common, strings._("not_a_file", True).format(filename)) Alert(common, strings._("not_a_file").format(filename))
valid = False valid = False
if not os.access(filename, os.R_OK): if not os.access(filename, os.R_OK):
Alert(common, strings._("not_a_readable_file", True).format(filename)) Alert(common, strings._("not_a_readable_file").format(filename))
valid = False valid = False
if not valid: if not valid:
sys.exit() sys.exit()

View file

@ -64,11 +64,11 @@ class OnionShareGui(QtWidgets.QMainWindow):
# System tray # System tray
menu = QtWidgets.QMenu() menu = QtWidgets.QMenu()
self.settings_action = menu.addAction(strings._('gui_settings_window_title', True)) self.settings_action = menu.addAction(strings._('gui_settings_window_title'))
self.settings_action.triggered.connect(self.open_settings) self.settings_action.triggered.connect(self.open_settings)
help_action = menu.addAction(strings._('gui_settings_button_help', True)) help_action = menu.addAction(strings._('gui_settings_button_help'))
help_action.triggered.connect(SettingsDialog.help_clicked) help_action.triggered.connect(SettingsDialog.help_clicked)
exit_action = menu.addAction(strings._('systray_menu_exit', True)) exit_action = menu.addAction(strings._('systray_menu_exit'))
exit_action.triggered.connect(self.close) exit_action.triggered.connect(self.close)
self.system_tray = QtWidgets.QSystemTrayIcon(self) self.system_tray = QtWidgets.QSystemTrayIcon(self)
@ -81,10 +81,10 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.system_tray.show() self.system_tray.show()
# Mode switcher, to switch between share files and receive files # Mode switcher, to switch between share files and receive files
self.share_mode_button = QtWidgets.QPushButton(strings._('gui_mode_share_button', True)); self.share_mode_button = QtWidgets.QPushButton(strings._('gui_mode_share_button'));
self.share_mode_button.setFixedHeight(50) self.share_mode_button.setFixedHeight(50)
self.share_mode_button.clicked.connect(self.share_mode_clicked) self.share_mode_button.clicked.connect(self.share_mode_clicked)
self.receive_mode_button = QtWidgets.QPushButton(strings._('gui_mode_receive_button', True)); self.receive_mode_button = QtWidgets.QPushButton(strings._('gui_mode_receive_button'));
self.receive_mode_button.setFixedHeight(50) self.receive_mode_button.setFixedHeight(50)
self.receive_mode_button.clicked.connect(self.receive_mode_clicked) self.receive_mode_button.clicked.connect(self.receive_mode_clicked)
self.settings_button = QtWidgets.QPushButton() self.settings_button = QtWidgets.QPushButton()
@ -224,24 +224,24 @@ class OnionShareGui(QtWidgets.QMainWindow):
# Share mode # Share mode
if self.share_mode.server_status.status == ServerStatus.STATUS_STOPPED: if self.share_mode.server_status.status == ServerStatus.STATUS_STOPPED:
self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_stopped)) self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_stopped))
self.server_status_label.setText(strings._('gui_status_indicator_share_stopped', True)) self.server_status_label.setText(strings._('gui_status_indicator_share_stopped'))
elif self.share_mode.server_status.status == ServerStatus.STATUS_WORKING: elif self.share_mode.server_status.status == ServerStatus.STATUS_WORKING:
self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_working)) self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_working))
self.server_status_label.setText(strings._('gui_status_indicator_share_working', True)) self.server_status_label.setText(strings._('gui_status_indicator_share_working'))
elif self.share_mode.server_status.status == ServerStatus.STATUS_STARTED: elif self.share_mode.server_status.status == ServerStatus.STATUS_STARTED:
self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_started)) self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_started))
self.server_status_label.setText(strings._('gui_status_indicator_share_started', True)) self.server_status_label.setText(strings._('gui_status_indicator_share_started'))
else: else:
# Receive mode # Receive mode
if self.receive_mode.server_status.status == ServerStatus.STATUS_STOPPED: if self.receive_mode.server_status.status == ServerStatus.STATUS_STOPPED:
self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_stopped)) self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_stopped))
self.server_status_label.setText(strings._('gui_status_indicator_receive_stopped', True)) self.server_status_label.setText(strings._('gui_status_indicator_receive_stopped'))
elif self.receive_mode.server_status.status == ServerStatus.STATUS_WORKING: elif self.receive_mode.server_status.status == ServerStatus.STATUS_WORKING:
self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_working)) self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_working))
self.server_status_label.setText(strings._('gui_status_indicator_receive_working', True)) self.server_status_label.setText(strings._('gui_status_indicator_receive_working'))
elif self.receive_mode.server_status.status == ServerStatus.STATUS_STARTED: elif self.receive_mode.server_status.status == ServerStatus.STATUS_STARTED:
self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_started)) self.server_status_image_label.setPixmap(QtGui.QPixmap.fromImage(self.server_status_image_started))
self.server_status_label.setText(strings._('gui_status_indicator_receive_started', True)) self.server_status_label.setText(strings._('gui_status_indicator_receive_started'))
def stop_server_finished(self): def stop_server_finished(self):
# When the server stopped, cleanup the ephemeral onion service # When the server stopped, cleanup the ephemeral onion service
@ -255,9 +255,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.common.log('OnionShareGui', '_tor_connection_canceled') self.common.log('OnionShareGui', '_tor_connection_canceled')
def ask(): def ask():
a = Alert(self.common, strings._('gui_tor_connection_ask', True), QtWidgets.QMessageBox.Question, buttons=QtWidgets.QMessageBox.NoButton, autostart=False) a = Alert(self.common, strings._('gui_tor_connection_ask'), QtWidgets.QMessageBox.Question, buttons=QtWidgets.QMessageBox.NoButton, autostart=False)
settings_button = QtWidgets.QPushButton(strings._('gui_tor_connection_ask_open_settings', True)) settings_button = QtWidgets.QPushButton(strings._('gui_tor_connection_ask_open_settings'))
quit_button = QtWidgets.QPushButton(strings._('gui_tor_connection_ask_quit', True)) quit_button = QtWidgets.QPushButton(strings._('gui_tor_connection_ask_quit'))
a.addButton(settings_button, QtWidgets.QMessageBox.AcceptRole) a.addButton(settings_button, QtWidgets.QMessageBox.AcceptRole)
a.addButton(quit_button, QtWidgets.QMessageBox.RejectRole) a.addButton(quit_button, QtWidgets.QMessageBox.RejectRole)
a.setDefaultButton(settings_button) a.setDefaultButton(settings_button)
@ -328,7 +328,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
if self.common.platform == 'Windows' or self.common.platform == 'Darwin': if self.common.platform == 'Windows' or self.common.platform == 'Darwin':
if self.common.settings.get('use_autoupdate'): if self.common.settings.get('use_autoupdate'):
def update_available(update_url, installed_version, latest_version): def update_available(update_url, installed_version, latest_version):
Alert(self.common, strings._("update_available", True).format(update_url, installed_version, latest_version)) Alert(self.common, strings._("update_available").format(update_url, installed_version, latest_version))
self.update_thread = UpdateThread(self.common, self.onion, self.config) self.update_thread = UpdateThread(self.common, self.onion, self.config)
self.update_thread.update_available.connect(update_available) self.update_thread.update_available.connect(update_available)
@ -345,8 +345,8 @@ class OnionShareGui(QtWidgets.QMainWindow):
# Have we lost connection to Tor somehow? # Have we lost connection to Tor somehow?
if not self.onion.is_authenticated(): if not self.onion.is_authenticated():
self.timer.stop() self.timer.stop()
self.status_bar.showMessage(strings._('gui_tor_connection_lost', True)) self.status_bar.showMessage(strings._('gui_tor_connection_lost'))
self.system_tray.showMessage(strings._('gui_tor_connection_lost', True), strings._('gui_tor_connection_error_settings', True)) self.system_tray.showMessage(strings._('gui_tor_connection_lost'), strings._('gui_tor_connection_error_settings'))
self.share_mode.handle_tor_broke() self.share_mode.handle_tor_broke()
self.receive_mode.handle_tor_broke() self.receive_mode.handle_tor_broke()
@ -400,7 +400,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
if event["type"] == Web.REQUEST_OTHER: if event["type"] == Web.REQUEST_OTHER:
if event["path"] != '/favicon.ico' and event["path"] != "/{}/shutdown".format(mode.web.shutdown_slug): if event["path"] != '/favicon.ico' and event["path"] != "/{}/shutdown".format(mode.web.shutdown_slug):
self.status_bar.showMessage('[#{0:d}] {1:s}: {2:s}'.format(mode.web.error404_count, strings._('other_page_loaded', True), event["path"])) self.status_bar.showMessage('[#{0:d}] {1:s}: {2:s}'.format(mode.web.error404_count, strings._('other_page_loaded'), event["path"]))
mode.timer_callback() mode.timer_callback()
@ -409,14 +409,14 @@ class OnionShareGui(QtWidgets.QMainWindow):
When the URL gets copied to the clipboard, display this in the status bar. When the URL gets copied to the clipboard, display this in the status bar.
""" """
self.common.log('OnionShareGui', 'copy_url') self.common.log('OnionShareGui', 'copy_url')
self.system_tray.showMessage(strings._('gui_copied_url_title', True), strings._('gui_copied_url', True)) self.system_tray.showMessage(strings._('gui_copied_url_title'), strings._('gui_copied_url'))
def copy_hidservauth(self): def copy_hidservauth(self):
""" """
When the stealth onion service HidServAuth gets copied to the clipboard, display this in the status bar. When the stealth onion service HidServAuth gets copied to the clipboard, display this in the status bar.
""" """
self.common.log('OnionShareGui', 'copy_hidservauth') self.common.log('OnionShareGui', 'copy_hidservauth')
self.system_tray.showMessage(strings._('gui_copied_hidservauth_title', True), strings._('gui_copied_hidservauth', True)) self.system_tray.showMessage(strings._('gui_copied_hidservauth_title'), strings._('gui_copied_hidservauth'))
def clear_message(self): def clear_message(self):
""" """
@ -454,14 +454,14 @@ class OnionShareGui(QtWidgets.QMainWindow):
if server_status.status != server_status.STATUS_STOPPED: if server_status.status != server_status.STATUS_STOPPED:
self.common.log('OnionShareGui', 'closeEvent, opening warning dialog') self.common.log('OnionShareGui', 'closeEvent, opening warning dialog')
dialog = QtWidgets.QMessageBox() dialog = QtWidgets.QMessageBox()
dialog.setWindowTitle(strings._('gui_quit_title', True)) dialog.setWindowTitle(strings._('gui_quit_title'))
if self.mode == OnionShareGui.MODE_SHARE: if self.mode == OnionShareGui.MODE_SHARE:
dialog.setText(strings._('gui_share_quit_warning', True)) dialog.setText(strings._('gui_share_quit_warning'))
else: else:
dialog.setText(strings._('gui_receive_quit_warning', True)) dialog.setText(strings._('gui_receive_quit_warning'))
dialog.setIcon(QtWidgets.QMessageBox.Critical) dialog.setIcon(QtWidgets.QMessageBox.Critical)
quit_button = dialog.addButton(strings._('gui_quit_warning_quit', True), QtWidgets.QMessageBox.YesRole) quit_button = dialog.addButton(strings._('gui_quit_warning_quit'), QtWidgets.QMessageBox.YesRole)
dont_quit_button = dialog.addButton(strings._('gui_quit_warning_dont_quit', True), QtWidgets.QMessageBox.NoRole) dont_quit_button = dialog.addButton(strings._('gui_quit_warning_dont_quit'), QtWidgets.QMessageBox.NoRole)
dialog.setDefaultButton(dont_quit_button) dialog.setDefaultButton(dont_quit_button)
reply = dialog.exec_() reply = dialog.exec_()

View file

@ -72,7 +72,7 @@ class ReceiveMode(Mode):
self.info_widget.hide() self.info_widget.hide()
# Receive mode info # Receive mode info
self.receive_info = QtWidgets.QLabel(strings._('gui_receive_mode_warning', True)) self.receive_info = QtWidgets.QLabel(strings._('gui_receive_mode_warning'))
self.receive_info.setMinimumHeight(80) self.receive_info.setMinimumHeight(80)
self.receive_info.setWordWrap(True) self.receive_info.setWordWrap(True)
@ -86,7 +86,7 @@ class ReceiveMode(Mode):
""" """
Return the string to put on the stop server button, if there's a shutdown timeout Return the string to put on the stop server button, if there's a shutdown timeout
""" """
return strings._('gui_receive_stop_server_shutdown_timeout', True) return strings._('gui_receive_stop_server_shutdown_timeout')
def timeout_finished_should_stop_server(self): def timeout_finished_should_stop_server(self):
""" """
@ -125,7 +125,7 @@ class ReceiveMode(Mode):
""" """
Handle REQUEST_LOAD event. Handle REQUEST_LOAD event.
""" """
self.system_tray.showMessage(strings._('systray_page_loaded_title', True), strings._('systray_upload_page_loaded_message', True)) self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_upload_page_loaded_message'))
def handle_request_started(self, event): def handle_request_started(self, event):
""" """
@ -135,7 +135,7 @@ class ReceiveMode(Mode):
self.uploads_in_progress += 1 self.uploads_in_progress += 1
self.update_uploads_in_progress() self.update_uploads_in_progress()
self.system_tray.showMessage(strings._('systray_upload_started_title', True), strings._('systray_upload_started_message', True)) self.system_tray.showMessage(strings._('systray_upload_started_title'), strings._('systray_upload_started_message'))
def handle_request_progress(self, event): def handle_request_progress(self, event):
""" """
@ -148,7 +148,7 @@ class ReceiveMode(Mode):
Handle REQUEST_CLOSE_SERVER event. Handle REQUEST_CLOSE_SERVER event.
""" """
self.stop_server() self.stop_server()
self.system_tray.showMessage(strings._('systray_close_server_title', True), strings._('systray_close_server_message', True)) self.system_tray.showMessage(strings._('systray_close_server_title'), strings._('systray_close_server_message'))
def handle_request_upload_file_renamed(self, event): def handle_request_upload_file_renamed(self, event):
""" """
@ -194,7 +194,7 @@ class ReceiveMode(Mode):
else: else:
image = self.common.get_resource_path('images/share_completed.png') image = self.common.get_resource_path('images/share_completed.png')
self.info_completed_uploads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.uploads_completed)) self.info_completed_uploads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.uploads_completed))
self.info_completed_uploads_count.setToolTip(strings._('info_completed_uploads_tooltip', True).format(self.uploads_completed)) self.info_completed_uploads_count.setToolTip(strings._('info_completed_uploads_tooltip').format(self.uploads_completed))
def update_uploads_in_progress(self): def update_uploads_in_progress(self):
""" """
@ -205,7 +205,7 @@ class ReceiveMode(Mode):
else: else:
image = self.common.get_resource_path('images/share_in_progress.png') image = self.common.get_resource_path('images/share_in_progress.png')
self.info_in_progress_uploads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.uploads_in_progress)) self.info_in_progress_uploads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.uploads_in_progress))
self.info_in_progress_uploads_count.setToolTip(strings._('info_in_progress_uploads_tooltip', True).format(self.uploads_in_progress)) self.info_in_progress_uploads_count.setToolTip(strings._('info_in_progress_uploads_tooltip').format(self.uploads_in_progress))
def update_primary_action(self): def update_primary_action(self):
self.common.log('ReceiveMode', 'update_primary_action') self.common.log('ReceiveMode', 'update_primary_action')

View file

@ -113,7 +113,7 @@ class Upload(QtWidgets.QWidget):
self.started = datetime.now() self.started = datetime.now()
# Label # Label
self.label = QtWidgets.QLabel(strings._('gui_upload_in_progress', True).format(self.started.strftime("%b %d, %I:%M%p"))) self.label = QtWidgets.QLabel(strings._('gui_upload_in_progress').format(self.started.strftime("%b %d, %I:%M%p")))
# Progress bar # Progress bar
self.progress_bar = QtWidgets.QProgressBar() self.progress_bar = QtWidgets.QProgressBar()
@ -190,16 +190,16 @@ class Upload(QtWidgets.QWidget):
self.ended = self.started = datetime.now() self.ended = self.started = datetime.now()
if self.started.year == self.ended.year and self.started.month == self.ended.month and self.started.day == self.ended.day: if self.started.year == self.ended.year and self.started.month == self.ended.month and self.started.day == self.ended.day:
if self.started.hour == self.ended.hour and self.started.minute == self.ended.minute: if self.started.hour == self.ended.hour and self.started.minute == self.ended.minute:
text = strings._('gui_upload_finished', True).format( text = strings._('gui_upload_finished').format(
self.started.strftime("%b %d, %I:%M%p") self.started.strftime("%b %d, %I:%M%p")
) )
else: else:
text = strings._('gui_upload_finished_range', True).format( text = strings._('gui_upload_finished_range').format(
self.started.strftime("%b %d, %I:%M%p"), self.started.strftime("%b %d, %I:%M%p"),
self.ended.strftime("%I:%M%p") self.ended.strftime("%I:%M%p")
) )
else: else:
text = strings._('gui_upload_finished_range', True).format( text = strings._('gui_upload_finished_range').format(
self.started.strftime("%b %d, %I:%M%p"), self.started.strftime("%b %d, %I:%M%p"),
self.ended.strftime("%b %d, %I:%M%p") self.ended.strftime("%b %d, %I:%M%p")
) )
@ -220,7 +220,7 @@ class Uploads(QtWidgets.QScrollArea):
self.uploads = {} self.uploads = {}
self.setWindowTitle(strings._('gui_uploads', True)) self.setWindowTitle(strings._('gui_uploads'))
self.setWidgetResizable(True) self.setWidgetResizable(True)
self.setMinimumHeight(150) self.setMinimumHeight(150)
self.setMinimumWidth(350) self.setMinimumWidth(350)
@ -229,10 +229,10 @@ class Uploads(QtWidgets.QScrollArea):
self.vbar = self.verticalScrollBar() self.vbar = self.verticalScrollBar()
self.vbar.rangeChanged.connect(self.resizeScroll) self.vbar.rangeChanged.connect(self.resizeScroll)
uploads_label = QtWidgets.QLabel(strings._('gui_uploads', True)) uploads_label = QtWidgets.QLabel(strings._('gui_uploads'))
uploads_label.setStyleSheet(self.common.css['downloads_uploads_label']) uploads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
self.no_uploads_label = QtWidgets.QLabel(strings._('gui_no_uploads', True)) self.no_uploads_label = QtWidgets.QLabel(strings._('gui_no_uploads'))
self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history', True)) self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history'))
self.clear_history_button.clicked.connect(self.reset) self.clear_history_button.clicked.connect(self.reset)
self.clear_history_button.hide() self.clear_history_button.hide()

View file

@ -61,7 +61,7 @@ class ServerStatus(QtWidgets.QWidget):
self.resizeEvent(None) self.resizeEvent(None)
# Shutdown timeout layout # Shutdown timeout layout
self.shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True)) self.shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout'))
self.shutdown_timeout = QtWidgets.QDateTimeEdit() self.shutdown_timeout = QtWidgets.QDateTimeEdit()
self.shutdown_timeout.setDisplayFormat("hh:mm A MMM d, yy") self.shutdown_timeout.setDisplayFormat("hh:mm A MMM d, yy")
if self.local_only: if self.local_only:
@ -101,11 +101,11 @@ class ServerStatus(QtWidgets.QWidget):
self.url.setMinimumSize(self.url.sizeHint()) self.url.setMinimumSize(self.url.sizeHint())
self.url.setStyleSheet(self.common.css['server_status_url']) self.url.setStyleSheet(self.common.css['server_status_url'])
self.copy_url_button = QtWidgets.QPushButton(strings._('gui_copy_url', True)) self.copy_url_button = QtWidgets.QPushButton(strings._('gui_copy_url'))
self.copy_url_button.setFlat(True) self.copy_url_button.setFlat(True)
self.copy_url_button.setStyleSheet(self.common.css['server_status_url_buttons']) self.copy_url_button.setStyleSheet(self.common.css['server_status_url_buttons'])
self.copy_url_button.clicked.connect(self.copy_url) self.copy_url_button.clicked.connect(self.copy_url)
self.copy_hidservauth_button = QtWidgets.QPushButton(strings._('gui_copy_hidservauth', True)) self.copy_hidservauth_button = QtWidgets.QPushButton(strings._('gui_copy_hidservauth'))
self.copy_hidservauth_button.setFlat(True) self.copy_hidservauth_button.setFlat(True)
self.copy_hidservauth_button.setStyleSheet(self.common.css['server_status_url_buttons']) self.copy_hidservauth_button.setStyleSheet(self.common.css['server_status_url_buttons'])
self.copy_hidservauth_button.clicked.connect(self.copy_hidservauth) self.copy_hidservauth_button.clicked.connect(self.copy_hidservauth)
@ -174,21 +174,21 @@ class ServerStatus(QtWidgets.QWidget):
info_image = self.common.get_resource_path('images/info.png') info_image = self.common.get_resource_path('images/info.png')
if self.mode == ServerStatus.MODE_SHARE: if self.mode == ServerStatus.MODE_SHARE:
self.url_description.setText(strings._('gui_share_url_description', True).format(info_image)) self.url_description.setText(strings._('gui_share_url_description').format(info_image))
else: else:
self.url_description.setText(strings._('gui_receive_url_description', True).format(info_image)) self.url_description.setText(strings._('gui_receive_url_description').format(info_image))
# Show a Tool Tip explaining the lifecycle of this URL # Show a Tool Tip explaining the lifecycle of this URL
if self.common.settings.get('save_private_key'): if self.common.settings.get('save_private_key'):
if self.mode == ServerStatus.MODE_SHARE and self.common.settings.get('close_after_first_download'): if self.mode == ServerStatus.MODE_SHARE and self.common.settings.get('close_after_first_download'):
self.url_description.setToolTip(strings._('gui_url_label_onetime_and_persistent', True)) self.url_description.setToolTip(strings._('gui_url_label_onetime_and_persistent'))
else: else:
self.url_description.setToolTip(strings._('gui_url_label_persistent', True)) self.url_description.setToolTip(strings._('gui_url_label_persistent'))
else: else:
if self.mode == ServerStatus.MODE_SHARE and self.common.settings.get('close_after_first_download'): if self.mode == ServerStatus.MODE_SHARE and self.common.settings.get('close_after_first_download'):
self.url_description.setToolTip(strings._('gui_url_label_onetime', True)) self.url_description.setToolTip(strings._('gui_url_label_onetime'))
else: else:
self.url_description.setToolTip(strings._('gui_url_label_stay_open', True)) self.url_description.setToolTip(strings._('gui_url_label_stay_open'))
self.url.setText(self.get_url()) self.url.setText(self.get_url())
self.url.show() self.url.show()
@ -223,9 +223,9 @@ class ServerStatus(QtWidgets.QWidget):
self.server_button.setStyleSheet(self.common.css['server_status_button_stopped']) self.server_button.setStyleSheet(self.common.css['server_status_button_stopped'])
self.server_button.setEnabled(True) self.server_button.setEnabled(True)
if self.mode == ServerStatus.MODE_SHARE: if self.mode == ServerStatus.MODE_SHARE:
self.server_button.setText(strings._('gui_share_start_server', True)) self.server_button.setText(strings._('gui_share_start_server'))
else: else:
self.server_button.setText(strings._('gui_receive_start_server', True)) self.server_button.setText(strings._('gui_receive_start_server'))
self.server_button.setToolTip('') self.server_button.setToolTip('')
if self.common.settings.get('shutdown_timeout'): if self.common.settings.get('shutdown_timeout'):
self.shutdown_timeout_container.show() self.shutdown_timeout_container.show()
@ -233,15 +233,15 @@ class ServerStatus(QtWidgets.QWidget):
self.server_button.setStyleSheet(self.common.css['server_status_button_started']) self.server_button.setStyleSheet(self.common.css['server_status_button_started'])
self.server_button.setEnabled(True) self.server_button.setEnabled(True)
if self.mode == ServerStatus.MODE_SHARE: if self.mode == ServerStatus.MODE_SHARE:
self.server_button.setText(strings._('gui_share_stop_server', True)) self.server_button.setText(strings._('gui_share_stop_server'))
else: else:
self.server_button.setText(strings._('gui_receive_stop_server', True)) self.server_button.setText(strings._('gui_receive_stop_server'))
if self.common.settings.get('shutdown_timeout'): if self.common.settings.get('shutdown_timeout'):
self.shutdown_timeout_container.hide() self.shutdown_timeout_container.hide()
if self.mode == ServerStatus.MODE_SHARE: if self.mode == ServerStatus.MODE_SHARE:
self.server_button.setToolTip(strings._('gui_share_stop_server_shutdown_timeout_tooltip', True).format(self.timeout)) self.server_button.setToolTip(strings._('gui_share_stop_server_shutdown_timeout_tooltip').format(self.timeout))
else: else:
self.server_button.setToolTip(strings._('gui_receive_stop_server_shutdown_timeout_tooltip', True).format(self.timeout)) self.server_button.setToolTip(strings._('gui_receive_stop_server_shutdown_timeout_tooltip').format(self.timeout))
elif self.status == self.STATUS_WORKING: elif self.status == self.STATUS_WORKING:
self.server_button.setStyleSheet(self.common.css['server_status_button_working']) self.server_button.setStyleSheet(self.common.css['server_status_button_working'])

View file

@ -47,7 +47,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.local_only = local_only self.local_only = local_only
self.setModal(True) self.setModal(True)
self.setWindowTitle(strings._('gui_settings_window_title', True)) self.setWindowTitle(strings._('gui_settings_window_title'))
self.setWindowIcon(QtGui.QIcon(self.common.get_resource_path('images/logo.png'))) self.setWindowIcon(QtGui.QIcon(self.common.get_resource_path('images/logo.png')))
self.system = platform.system() self.system = platform.system()
@ -57,8 +57,8 @@ class SettingsDialog(QtWidgets.QDialog):
# Use a slug or not ('public mode') # Use a slug or not ('public mode')
self.public_mode_checkbox = QtWidgets.QCheckBox() self.public_mode_checkbox = QtWidgets.QCheckBox()
self.public_mode_checkbox.setCheckState(QtCore.Qt.Unchecked) self.public_mode_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.public_mode_checkbox.setText(strings._("gui_settings_public_mode_checkbox", True)) self.public_mode_checkbox.setText(strings._("gui_settings_public_mode_checkbox"))
public_mode_label = QtWidgets.QLabel(strings._("gui_settings_whats_this", True).format("https://github.com/micahflee/onionshare/wiki/Public-Mode")) public_mode_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Public-Mode"))
public_mode_label.setStyleSheet(self.common.css['settings_whats_this']) public_mode_label.setStyleSheet(self.common.css['settings_whats_this'])
public_mode_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) public_mode_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
public_mode_label.setOpenExternalLinks(True) public_mode_label.setOpenExternalLinks(True)
@ -74,8 +74,8 @@ class SettingsDialog(QtWidgets.QDialog):
# Whether or not to use a shutdown ('auto-stop') timer # Whether or not to use a shutdown ('auto-stop') timer
self.shutdown_timeout_checkbox = QtWidgets.QCheckBox() self.shutdown_timeout_checkbox = QtWidgets.QCheckBox()
self.shutdown_timeout_checkbox.setCheckState(QtCore.Qt.Checked) self.shutdown_timeout_checkbox.setCheckState(QtCore.Qt.Checked)
self.shutdown_timeout_checkbox.setText(strings._("gui_settings_shutdown_timeout_checkbox", True)) self.shutdown_timeout_checkbox.setText(strings._("gui_settings_shutdown_timeout_checkbox"))
shutdown_timeout_label = QtWidgets.QLabel(strings._("gui_settings_whats_this", True).format("https://github.com/micahflee/onionshare/wiki/Using-the-Auto-Stop-Timer")) shutdown_timeout_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Using-the-Auto-Stop-Timer"))
shutdown_timeout_label.setStyleSheet(self.common.css['settings_whats_this']) shutdown_timeout_label.setStyleSheet(self.common.css['settings_whats_this'])
shutdown_timeout_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) shutdown_timeout_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
shutdown_timeout_label.setOpenExternalLinks(True) shutdown_timeout_label.setOpenExternalLinks(True)
@ -91,9 +91,9 @@ class SettingsDialog(QtWidgets.QDialog):
# Whether or not to use legacy v2 onions # Whether or not to use legacy v2 onions
self.use_legacy_v2_onions_checkbox = QtWidgets.QCheckBox() self.use_legacy_v2_onions_checkbox = QtWidgets.QCheckBox()
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Unchecked) self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.use_legacy_v2_onions_checkbox.setText(strings._("gui_use_legacy_v2_onions_checkbox", True)) self.use_legacy_v2_onions_checkbox.setText(strings._("gui_use_legacy_v2_onions_checkbox"))
self.use_legacy_v2_onions_checkbox.clicked.connect(self.use_legacy_v2_onions_checkbox_clicked) self.use_legacy_v2_onions_checkbox.clicked.connect(self.use_legacy_v2_onions_checkbox_clicked)
use_legacy_v2_onions_label = QtWidgets.QLabel(strings._("gui_settings_whats_this", True).format("https://github.com/micahflee/onionshare/wiki/Legacy-Addresses")) use_legacy_v2_onions_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Legacy-Addresses"))
use_legacy_v2_onions_label.setStyleSheet(self.common.css['settings_whats_this']) use_legacy_v2_onions_label.setStyleSheet(self.common.css['settings_whats_this'])
use_legacy_v2_onions_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) use_legacy_v2_onions_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
use_legacy_v2_onions_label.setOpenExternalLinks(True) use_legacy_v2_onions_label.setOpenExternalLinks(True)
@ -108,9 +108,9 @@ class SettingsDialog(QtWidgets.QDialog):
# Whether or not to save the Onion private key for reuse (persistent URL mode) # Whether or not to save the Onion private key for reuse (persistent URL mode)
self.save_private_key_checkbox = QtWidgets.QCheckBox() self.save_private_key_checkbox = QtWidgets.QCheckBox()
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked) self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.save_private_key_checkbox.setText(strings._("gui_save_private_key_checkbox", True)) self.save_private_key_checkbox.setText(strings._("gui_save_private_key_checkbox"))
self.save_private_key_checkbox.clicked.connect(self.save_private_key_checkbox_clicked) self.save_private_key_checkbox.clicked.connect(self.save_private_key_checkbox_clicked)
save_private_key_label = QtWidgets.QLabel(strings._("gui_settings_whats_this", True).format("https://github.com/micahflee/onionshare/wiki/Using-a-Persistent-URL")) save_private_key_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Using-a-Persistent-URL"))
save_private_key_label.setStyleSheet(self.common.css['settings_whats_this']) save_private_key_label.setStyleSheet(self.common.css['settings_whats_this'])
save_private_key_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) save_private_key_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
save_private_key_label.setOpenExternalLinks(True) save_private_key_label.setOpenExternalLinks(True)
@ -125,9 +125,9 @@ class SettingsDialog(QtWidgets.QDialog):
# Stealth # Stealth
self.stealth_checkbox = QtWidgets.QCheckBox() self.stealth_checkbox = QtWidgets.QCheckBox()
self.stealth_checkbox.setCheckState(QtCore.Qt.Unchecked) self.stealth_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.stealth_checkbox.setText(strings._("gui_settings_stealth_option", True)) self.stealth_checkbox.setText(strings._("gui_settings_stealth_option"))
self.stealth_checkbox.clicked.connect(self.stealth_checkbox_clicked_connect) self.stealth_checkbox.clicked.connect(self.stealth_checkbox_clicked_connect)
use_stealth_label = QtWidgets.QLabel(strings._("gui_settings_whats_this", True).format("https://github.com/micahflee/onionshare/wiki/Stealth-Onion-Services")) use_stealth_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Stealth-Onion-Services"))
use_stealth_label.setStyleSheet(self.common.css['settings_whats_this']) use_stealth_label.setStyleSheet(self.common.css['settings_whats_this'])
use_stealth_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) use_stealth_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
use_stealth_label.setOpenExternalLinks(True) use_stealth_label.setOpenExternalLinks(True)
@ -140,12 +140,12 @@ class SettingsDialog(QtWidgets.QDialog):
self.use_stealth_widget = QtWidgets.QWidget() self.use_stealth_widget = QtWidgets.QWidget()
self.use_stealth_widget.setLayout(use_stealth_layout) self.use_stealth_widget.setLayout(use_stealth_layout)
hidservauth_details = QtWidgets.QLabel(strings._('gui_settings_stealth_hidservauth_string', True)) hidservauth_details = QtWidgets.QLabel(strings._('gui_settings_stealth_hidservauth_string'))
hidservauth_details.setWordWrap(True) hidservauth_details.setWordWrap(True)
hidservauth_details.setMinimumSize(hidservauth_details.sizeHint()) hidservauth_details.setMinimumSize(hidservauth_details.sizeHint())
hidservauth_details.hide() hidservauth_details.hide()
self.hidservauth_copy_button = QtWidgets.QPushButton(strings._('gui_copy_hidservauth', True)) self.hidservauth_copy_button = QtWidgets.QPushButton(strings._('gui_copy_hidservauth'))
self.hidservauth_copy_button.clicked.connect(self.hidservauth_copy_button_clicked) self.hidservauth_copy_button.clicked.connect(self.hidservauth_copy_button_clicked)
self.hidservauth_copy_button.hide() self.hidservauth_copy_button.hide()
@ -159,7 +159,7 @@ class SettingsDialog(QtWidgets.QDialog):
general_group_layout.addWidget(hidservauth_details) general_group_layout.addWidget(hidservauth_details)
general_group_layout.addWidget(self.hidservauth_copy_button) general_group_layout.addWidget(self.hidservauth_copy_button)
general_group = QtWidgets.QGroupBox(strings._("gui_settings_general_label", True)) general_group = QtWidgets.QGroupBox(strings._("gui_settings_general_label"))
general_group.setLayout(general_group_layout) general_group.setLayout(general_group_layout)
# Sharing options # Sharing options
@ -167,19 +167,19 @@ class SettingsDialog(QtWidgets.QDialog):
# Close after first download # Close after first download
self.close_after_first_download_checkbox = QtWidgets.QCheckBox() self.close_after_first_download_checkbox = QtWidgets.QCheckBox()
self.close_after_first_download_checkbox.setCheckState(QtCore.Qt.Checked) self.close_after_first_download_checkbox.setCheckState(QtCore.Qt.Checked)
self.close_after_first_download_checkbox.setText(strings._("gui_settings_close_after_first_download_option", True)) self.close_after_first_download_checkbox.setText(strings._("gui_settings_close_after_first_download_option"))
# Sharing options layout # Sharing options layout
sharing_group_layout = QtWidgets.QVBoxLayout() sharing_group_layout = QtWidgets.QVBoxLayout()
sharing_group_layout.addWidget(self.close_after_first_download_checkbox) sharing_group_layout.addWidget(self.close_after_first_download_checkbox)
sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label", True)) sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label"))
sharing_group.setLayout(sharing_group_layout) sharing_group.setLayout(sharing_group_layout)
# Downloads dir # Downloads dir
downloads_label = QtWidgets.QLabel(strings._('gui_settings_downloads_label', True)); downloads_label = QtWidgets.QLabel(strings._('gui_settings_downloads_label'));
self.downloads_dir_lineedit = QtWidgets.QLineEdit() self.downloads_dir_lineedit = QtWidgets.QLineEdit()
self.downloads_dir_lineedit.setReadOnly(True) self.downloads_dir_lineedit.setReadOnly(True)
downloads_button = QtWidgets.QPushButton(strings._('gui_settings_downloads_button', True)) downloads_button = QtWidgets.QPushButton(strings._('gui_settings_downloads_button'))
downloads_button.clicked.connect(self.downloads_button_clicked) downloads_button.clicked.connect(self.downloads_button_clicked)
downloads_layout = QtWidgets.QHBoxLayout() downloads_layout = QtWidgets.QHBoxLayout()
downloads_layout.addWidget(downloads_label) downloads_layout.addWidget(downloads_label)
@ -189,13 +189,13 @@ class SettingsDialog(QtWidgets.QDialog):
# Allow the receiver to shutdown the server # Allow the receiver to shutdown the server
self.receive_allow_receiver_shutdown_checkbox = QtWidgets.QCheckBox() self.receive_allow_receiver_shutdown_checkbox = QtWidgets.QCheckBox()
self.receive_allow_receiver_shutdown_checkbox.setCheckState(QtCore.Qt.Checked) self.receive_allow_receiver_shutdown_checkbox.setCheckState(QtCore.Qt.Checked)
self.receive_allow_receiver_shutdown_checkbox.setText(strings._("gui_settings_receive_allow_receiver_shutdown_checkbox", True)) self.receive_allow_receiver_shutdown_checkbox.setText(strings._("gui_settings_receive_allow_receiver_shutdown_checkbox"))
# Receiving options layout # Receiving options layout
receiving_group_layout = QtWidgets.QVBoxLayout() receiving_group_layout = QtWidgets.QVBoxLayout()
receiving_group_layout.addLayout(downloads_layout) receiving_group_layout.addLayout(downloads_layout)
receiving_group_layout.addWidget(self.receive_allow_receiver_shutdown_checkbox) receiving_group_layout.addWidget(self.receive_allow_receiver_shutdown_checkbox)
receiving_group = QtWidgets.QGroupBox(strings._("gui_settings_receiving_label", True)) receiving_group = QtWidgets.QGroupBox(strings._("gui_settings_receiving_label"))
receiving_group.setLayout(receiving_group_layout) receiving_group.setLayout(receiving_group_layout)
# Automatic updates options # Automatic updates options
@ -203,13 +203,13 @@ class SettingsDialog(QtWidgets.QDialog):
# Autoupdate # Autoupdate
self.autoupdate_checkbox = QtWidgets.QCheckBox() self.autoupdate_checkbox = QtWidgets.QCheckBox()
self.autoupdate_checkbox.setCheckState(QtCore.Qt.Unchecked) self.autoupdate_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.autoupdate_checkbox.setText(strings._("gui_settings_autoupdate_option", True)) self.autoupdate_checkbox.setText(strings._("gui_settings_autoupdate_option"))
# Last update time # Last update time
self.autoupdate_timestamp = QtWidgets.QLabel() self.autoupdate_timestamp = QtWidgets.QLabel()
# Check for updates button # Check for updates button
self.check_for_updates_button = QtWidgets.QPushButton(strings._('gui_settings_autoupdate_check_button', True)) self.check_for_updates_button = QtWidgets.QPushButton(strings._('gui_settings_autoupdate_check_button'))
self.check_for_updates_button.clicked.connect(self.check_for_updates) self.check_for_updates_button.clicked.connect(self.check_for_updates)
# We can't check for updates if not connected to Tor # We can't check for updates if not connected to Tor
if not self.onion.connected_to_tor: if not self.onion.connected_to_tor:
@ -220,7 +220,7 @@ class SettingsDialog(QtWidgets.QDialog):
autoupdate_group_layout.addWidget(self.autoupdate_checkbox) autoupdate_group_layout.addWidget(self.autoupdate_checkbox)
autoupdate_group_layout.addWidget(self.autoupdate_timestamp) autoupdate_group_layout.addWidget(self.autoupdate_timestamp)
autoupdate_group_layout.addWidget(self.check_for_updates_button) autoupdate_group_layout.addWidget(self.check_for_updates_button)
autoupdate_group = QtWidgets.QGroupBox(strings._("gui_settings_autoupdate_label", True)) autoupdate_group = QtWidgets.QGroupBox(strings._("gui_settings_autoupdate_label"))
autoupdate_group.setLayout(autoupdate_group_layout) autoupdate_group.setLayout(autoupdate_group_layout)
# Autoupdate is only available for Windows and Mac (Linux updates using package manager) # Autoupdate is only available for Windows and Mac (Linux updates using package manager)
@ -228,7 +228,7 @@ class SettingsDialog(QtWidgets.QDialog):
autoupdate_group.hide() autoupdate_group.hide()
# Language settings # Language settings
language_label = QtWidgets.QLabel(strings._("gui_settings_language_label", True)) language_label = QtWidgets.QLabel(strings._("gui_settings_language_label"))
self.language_combobox = QtWidgets.QComboBox() self.language_combobox = QtWidgets.QComboBox()
# Populate the dropdown with all of OnionShare's available languages # Populate the dropdown with all of OnionShare's available languages
language_names_to_locales = {v: k for k, v in self.common.settings.available_locales.items()} language_names_to_locales = {v: k for k, v in self.common.settings.available_locales.items()}
@ -245,7 +245,7 @@ class SettingsDialog(QtWidgets.QDialog):
# Connection type: either automatic, control port, or socket file # Connection type: either automatic, control port, or socket file
# Bundled Tor # Bundled Tor
self.connection_type_bundled_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_bundled_option', True)) self.connection_type_bundled_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_bundled_option'))
self.connection_type_bundled_radio.toggled.connect(self.connection_type_bundled_toggled) self.connection_type_bundled_radio.toggled.connect(self.connection_type_bundled_toggled)
# Bundled Tor doesn't work on dev mode in Windows or Mac # Bundled Tor doesn't work on dev mode in Windows or Mac
@ -255,27 +255,27 @@ class SettingsDialog(QtWidgets.QDialog):
# Bridge options for bundled tor # Bridge options for bundled tor
# No bridges option radio # No bridges option radio
self.tor_bridges_no_bridges_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_no_bridges_radio_option', True)) self.tor_bridges_no_bridges_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_no_bridges_radio_option'))
self.tor_bridges_no_bridges_radio.toggled.connect(self.tor_bridges_no_bridges_radio_toggled) self.tor_bridges_no_bridges_radio.toggled.connect(self.tor_bridges_no_bridges_radio_toggled)
# obfs4 option radio # obfs4 option radio
# if the obfs4proxy binary is missing, we can't use obfs4 transports # if the obfs4proxy binary is missing, we can't use obfs4 transports
(self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path, self.obfs4proxy_file_path) = self.common.get_tor_paths() (self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path, self.obfs4proxy_file_path) = self.common.get_tor_paths()
if not os.path.isfile(self.obfs4proxy_file_path): if not os.path.isfile(self.obfs4proxy_file_path):
self.tor_bridges_use_obfs4_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_obfs4_radio_option_no_obfs4proxy', True)) self.tor_bridges_use_obfs4_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_obfs4_radio_option_no_obfs4proxy'))
self.tor_bridges_use_obfs4_radio.setEnabled(False) self.tor_bridges_use_obfs4_radio.setEnabled(False)
else: else:
self.tor_bridges_use_obfs4_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_obfs4_radio_option', True)) self.tor_bridges_use_obfs4_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_obfs4_radio_option'))
self.tor_bridges_use_obfs4_radio.toggled.connect(self.tor_bridges_use_obfs4_radio_toggled) self.tor_bridges_use_obfs4_radio.toggled.connect(self.tor_bridges_use_obfs4_radio_toggled)
# meek_lite-azure option radio # meek_lite-azure option radio
# if the obfs4proxy binary is missing, we can't use meek_lite-azure transports # if the obfs4proxy binary is missing, we can't use meek_lite-azure transports
(self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path, self.obfs4proxy_file_path) = self.common.get_tor_paths() (self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path, self.obfs4proxy_file_path) = self.common.get_tor_paths()
if not os.path.isfile(self.obfs4proxy_file_path): if not os.path.isfile(self.obfs4proxy_file_path):
self.tor_bridges_use_meek_lite_azure_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_meek_lite_azure_radio_option_no_obfs4proxy', True)) self.tor_bridges_use_meek_lite_azure_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_meek_lite_azure_radio_option_no_obfs4proxy'))
self.tor_bridges_use_meek_lite_azure_radio.setEnabled(False) self.tor_bridges_use_meek_lite_azure_radio.setEnabled(False)
else: else:
self.tor_bridges_use_meek_lite_azure_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_meek_lite_azure_radio_option', True)) self.tor_bridges_use_meek_lite_azure_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_meek_lite_azure_radio_option'))
self.tor_bridges_use_meek_lite_azure_radio.toggled.connect(self.tor_bridges_use_meek_lite_azure_radio_toggled) self.tor_bridges_use_meek_lite_azure_radio.toggled.connect(self.tor_bridges_use_meek_lite_azure_radio_toggled)
# meek_lite currently not supported on the version of obfs4proxy bundled with TorBrowser # meek_lite currently not supported on the version of obfs4proxy bundled with TorBrowser
@ -283,10 +283,10 @@ class SettingsDialog(QtWidgets.QDialog):
self.tor_bridges_use_meek_lite_azure_radio.hide() self.tor_bridges_use_meek_lite_azure_radio.hide()
# Custom bridges radio and textbox # Custom bridges radio and textbox
self.tor_bridges_use_custom_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_custom_radio_option', True)) self.tor_bridges_use_custom_radio = QtWidgets.QRadioButton(strings._('gui_settings_tor_bridges_custom_radio_option'))
self.tor_bridges_use_custom_radio.toggled.connect(self.tor_bridges_use_custom_radio_toggled) self.tor_bridges_use_custom_radio.toggled.connect(self.tor_bridges_use_custom_radio_toggled)
self.tor_bridges_use_custom_label = QtWidgets.QLabel(strings._('gui_settings_tor_bridges_custom_label', True)) self.tor_bridges_use_custom_label = QtWidgets.QLabel(strings._('gui_settings_tor_bridges_custom_label'))
self.tor_bridges_use_custom_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) self.tor_bridges_use_custom_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
self.tor_bridges_use_custom_label.setOpenExternalLinks(True) self.tor_bridges_use_custom_label.setOpenExternalLinks(True)
self.tor_bridges_use_custom_textbox = QtWidgets.QPlainTextEdit() self.tor_bridges_use_custom_textbox = QtWidgets.QPlainTextEdit()
@ -313,14 +313,14 @@ class SettingsDialog(QtWidgets.QDialog):
self.bridges.setLayout(bridges_layout) self.bridges.setLayout(bridges_layout)
# Automatic # Automatic
self.connection_type_automatic_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_automatic_option', True)) self.connection_type_automatic_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_automatic_option'))
self.connection_type_automatic_radio.toggled.connect(self.connection_type_automatic_toggled) self.connection_type_automatic_radio.toggled.connect(self.connection_type_automatic_toggled)
# Control port # Control port
self.connection_type_control_port_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_control_port_option', True)) self.connection_type_control_port_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_control_port_option'))
self.connection_type_control_port_radio.toggled.connect(self.connection_type_control_port_toggled) self.connection_type_control_port_radio.toggled.connect(self.connection_type_control_port_toggled)
connection_type_control_port_extras_label = QtWidgets.QLabel(strings._('gui_settings_control_port_label', True)) connection_type_control_port_extras_label = QtWidgets.QLabel(strings._('gui_settings_control_port_label'))
self.connection_type_control_port_extras_address = QtWidgets.QLineEdit() self.connection_type_control_port_extras_address = QtWidgets.QLineEdit()
self.connection_type_control_port_extras_port = QtWidgets.QLineEdit() self.connection_type_control_port_extras_port = QtWidgets.QLineEdit()
connection_type_control_port_extras_layout = QtWidgets.QHBoxLayout() connection_type_control_port_extras_layout = QtWidgets.QHBoxLayout()
@ -333,10 +333,10 @@ class SettingsDialog(QtWidgets.QDialog):
self.connection_type_control_port_extras.hide() self.connection_type_control_port_extras.hide()
# Socket file # Socket file
self.connection_type_socket_file_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_socket_file_option', True)) self.connection_type_socket_file_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_socket_file_option'))
self.connection_type_socket_file_radio.toggled.connect(self.connection_type_socket_file_toggled) self.connection_type_socket_file_radio.toggled.connect(self.connection_type_socket_file_toggled)
connection_type_socket_file_extras_label = QtWidgets.QLabel(strings._('gui_settings_socket_file_label', True)) connection_type_socket_file_extras_label = QtWidgets.QLabel(strings._('gui_settings_socket_file_label'))
self.connection_type_socket_file_extras_path = QtWidgets.QLineEdit() self.connection_type_socket_file_extras_path = QtWidgets.QLineEdit()
connection_type_socket_file_extras_layout = QtWidgets.QHBoxLayout() connection_type_socket_file_extras_layout = QtWidgets.QHBoxLayout()
connection_type_socket_file_extras_layout.addWidget(connection_type_socket_file_extras_label) connection_type_socket_file_extras_layout.addWidget(connection_type_socket_file_extras_label)
@ -347,7 +347,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.connection_type_socket_file_extras.hide() self.connection_type_socket_file_extras.hide()
# Tor SOCKS address and port # Tor SOCKS address and port
gui_settings_socks_label = QtWidgets.QLabel(strings._('gui_settings_socks_label', True)) gui_settings_socks_label = QtWidgets.QLabel(strings._('gui_settings_socks_label'))
self.connection_type_socks_address = QtWidgets.QLineEdit() self.connection_type_socks_address = QtWidgets.QLineEdit()
self.connection_type_socks_port = QtWidgets.QLineEdit() self.connection_type_socks_port = QtWidgets.QLineEdit()
connection_type_socks_layout = QtWidgets.QHBoxLayout() connection_type_socks_layout = QtWidgets.QHBoxLayout()
@ -362,14 +362,14 @@ class SettingsDialog(QtWidgets.QDialog):
# Authentication options # Authentication options
# No authentication # No authentication
self.authenticate_no_auth_radio = QtWidgets.QRadioButton(strings._('gui_settings_authenticate_no_auth_option', True)) self.authenticate_no_auth_radio = QtWidgets.QRadioButton(strings._('gui_settings_authenticate_no_auth_option'))
self.authenticate_no_auth_radio.toggled.connect(self.authenticate_no_auth_toggled) self.authenticate_no_auth_radio.toggled.connect(self.authenticate_no_auth_toggled)
# Password # Password
self.authenticate_password_radio = QtWidgets.QRadioButton(strings._('gui_settings_authenticate_password_option', True)) self.authenticate_password_radio = QtWidgets.QRadioButton(strings._('gui_settings_authenticate_password_option'))
self.authenticate_password_radio.toggled.connect(self.authenticate_password_toggled) self.authenticate_password_radio.toggled.connect(self.authenticate_password_toggled)
authenticate_password_extras_label = QtWidgets.QLabel(strings._('gui_settings_password_label', True)) authenticate_password_extras_label = QtWidgets.QLabel(strings._('gui_settings_password_label'))
self.authenticate_password_extras_password = QtWidgets.QLineEdit('') self.authenticate_password_extras_password = QtWidgets.QLineEdit('')
authenticate_password_extras_layout = QtWidgets.QHBoxLayout() authenticate_password_extras_layout = QtWidgets.QHBoxLayout()
authenticate_password_extras_layout.addWidget(authenticate_password_extras_label) authenticate_password_extras_layout.addWidget(authenticate_password_extras_label)
@ -384,7 +384,7 @@ class SettingsDialog(QtWidgets.QDialog):
authenticate_group_layout.addWidget(self.authenticate_no_auth_radio) authenticate_group_layout.addWidget(self.authenticate_no_auth_radio)
authenticate_group_layout.addWidget(self.authenticate_password_radio) authenticate_group_layout.addWidget(self.authenticate_password_radio)
authenticate_group_layout.addWidget(self.authenticate_password_extras) authenticate_group_layout.addWidget(self.authenticate_password_extras)
self.authenticate_group = QtWidgets.QGroupBox(strings._("gui_settings_authenticate_label", True)) self.authenticate_group = QtWidgets.QGroupBox(strings._("gui_settings_authenticate_label"))
self.authenticate_group.setLayout(authenticate_group_layout) self.authenticate_group.setLayout(authenticate_group_layout)
# Put the radios into their own group so they are exclusive # Put the radios into their own group so they are exclusive
@ -393,18 +393,18 @@ class SettingsDialog(QtWidgets.QDialog):
connection_type_radio_group_layout.addWidget(self.connection_type_automatic_radio) connection_type_radio_group_layout.addWidget(self.connection_type_automatic_radio)
connection_type_radio_group_layout.addWidget(self.connection_type_control_port_radio) connection_type_radio_group_layout.addWidget(self.connection_type_control_port_radio)
connection_type_radio_group_layout.addWidget(self.connection_type_socket_file_radio) connection_type_radio_group_layout.addWidget(self.connection_type_socket_file_radio)
connection_type_radio_group = QtWidgets.QGroupBox(strings._("gui_settings_connection_type_label", True)) connection_type_radio_group = QtWidgets.QGroupBox(strings._("gui_settings_connection_type_label"))
connection_type_radio_group.setLayout(connection_type_radio_group_layout) connection_type_radio_group.setLayout(connection_type_radio_group_layout)
# The Bridges options are not exclusive (enabling Bridges offers obfs4 or custom bridges) # The Bridges options are not exclusive (enabling Bridges offers obfs4 or custom bridges)
connection_type_bridges_radio_group_layout = QtWidgets.QVBoxLayout() connection_type_bridges_radio_group_layout = QtWidgets.QVBoxLayout()
connection_type_bridges_radio_group_layout.addWidget(self.bridges) connection_type_bridges_radio_group_layout.addWidget(self.bridges)
self.connection_type_bridges_radio_group = QtWidgets.QGroupBox(strings._("gui_settings_tor_bridges", True)) self.connection_type_bridges_radio_group = QtWidgets.QGroupBox(strings._("gui_settings_tor_bridges"))
self.connection_type_bridges_radio_group.setLayout(connection_type_bridges_radio_group_layout) self.connection_type_bridges_radio_group.setLayout(connection_type_bridges_radio_group_layout)
self.connection_type_bridges_radio_group.hide() self.connection_type_bridges_radio_group.hide()
# Test tor settings button # Test tor settings button
self.connection_type_test_button = QtWidgets.QPushButton(strings._('gui_settings_connection_type_test_button', True)) self.connection_type_test_button = QtWidgets.QPushButton(strings._('gui_settings_connection_type_test_button'))
self.connection_type_test_button.clicked.connect(self.test_tor_clicked) self.connection_type_test_button.clicked.connect(self.test_tor_clicked)
connection_type_test_button_layout = QtWidgets.QHBoxLayout() connection_type_test_button_layout = QtWidgets.QHBoxLayout()
connection_type_test_button_layout.addWidget(self.connection_type_test_button) connection_type_test_button_layout.addWidget(self.connection_type_test_button)
@ -420,13 +420,13 @@ class SettingsDialog(QtWidgets.QDialog):
connection_type_layout.addLayout(connection_type_test_button_layout) connection_type_layout.addLayout(connection_type_test_button_layout)
# Buttons # Buttons
self.save_button = QtWidgets.QPushButton(strings._('gui_settings_button_save', True)) self.save_button = QtWidgets.QPushButton(strings._('gui_settings_button_save'))
self.save_button.clicked.connect(self.save_clicked) self.save_button.clicked.connect(self.save_clicked)
self.cancel_button = QtWidgets.QPushButton(strings._('gui_settings_button_cancel', True)) self.cancel_button = QtWidgets.QPushButton(strings._('gui_settings_button_cancel'))
self.cancel_button.clicked.connect(self.cancel_clicked) self.cancel_button.clicked.connect(self.cancel_clicked)
version_label = QtWidgets.QLabel('OnionShare {0:s}'.format(self.common.version)) version_label = QtWidgets.QLabel('OnionShare {0:s}'.format(self.common.version))
version_label.setStyleSheet(self.common.css['settings_version']) version_label.setStyleSheet(self.common.css['settings_version'])
self.help_button = QtWidgets.QPushButton(strings._('gui_settings_button_help', True)) self.help_button = QtWidgets.QPushButton(strings._('gui_settings_button_help'))
self.help_button.clicked.connect(self.help_clicked) self.help_button.clicked.connect(self.help_clicked)
buttons_layout = QtWidgets.QHBoxLayout() buttons_layout = QtWidgets.QHBoxLayout()
buttons_layout.addWidget(version_label) buttons_layout.addWidget(version_label)
@ -623,7 +623,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.tor_bridges_use_custom_textbox_options.hide() self.tor_bridges_use_custom_textbox_options.hide()
# Alert the user about meek's costliness if it looks like they're turning it on # Alert the user about meek's costliness if it looks like they're turning it on
if not self.old_settings.get('tor_bridges_use_meek_lite_azure'): if not self.old_settings.get('tor_bridges_use_meek_lite_azure'):
Alert(self.common, strings._('gui_settings_meek_lite_expensive_warning', True), QtWidgets.QMessageBox.Warning) Alert(self.common, strings._('gui_settings_meek_lite_expensive_warning'), QtWidgets.QMessageBox.Warning)
def tor_bridges_use_custom_radio_toggled(self, checked): def tor_bridges_use_custom_radio_toggled(self, checked):
""" """
@ -736,7 +736,7 @@ class SettingsDialog(QtWidgets.QDialog):
""" """
downloads_dir = self.downloads_dir_lineedit.text() downloads_dir = self.downloads_dir_lineedit.text()
selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self, selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self,
strings._('gui_settings_downloads_label', True), downloads_dir) strings._('gui_settings_downloads_label'), downloads_dir)
if selected_dir: if selected_dir:
self.common.log('SettingsDialog', 'downloads_button_clicked', 'selected dir: {}'.format(selected_dir)) self.common.log('SettingsDialog', 'downloads_button_clicked', 'selected dir: {}'.format(selected_dir))
@ -766,7 +766,7 @@ class SettingsDialog(QtWidgets.QDialog):
onion.connect(custom_settings=settings, config=self.config, tor_status_update_func=tor_status_update_func) onion.connect(custom_settings=settings, config=self.config, tor_status_update_func=tor_status_update_func)
# If an exception hasn't been raised yet, the Tor settings work # If an exception hasn't been raised yet, the Tor settings work
Alert(self.common, strings._('settings_test_success', True).format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth, onion.supports_next_gen_onions)) Alert(self.common, strings._('settings_test_success').format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth, onion.supports_next_gen_onions))
# Clean up # Clean up
onion.cleanup() onion.cleanup()
@ -802,19 +802,19 @@ class SettingsDialog(QtWidgets.QDialog):
# Check for updates # Check for updates
def update_available(update_url, installed_version, latest_version): def update_available(update_url, installed_version, latest_version):
Alert(self.common, strings._("update_available", True).format(update_url, installed_version, latest_version)) Alert(self.common, strings._("update_available").format(update_url, installed_version, latest_version))
close_forced_update_thread() close_forced_update_thread()
def update_not_available(): def update_not_available():
Alert(self.common, strings._('update_not_available', True)) Alert(self.common, strings._('update_not_available'))
close_forced_update_thread() close_forced_update_thread()
def update_error(): def update_error():
Alert(self.common, strings._('update_error_check_error', True), QtWidgets.QMessageBox.Warning) Alert(self.common, strings._('update_error_check_error'), QtWidgets.QMessageBox.Warning)
close_forced_update_thread() close_forced_update_thread()
def update_invalid_version(latest_version): def update_invalid_version(latest_version):
Alert(self.common, strings._('update_error_invalid_latest_version', True).format(latest_version), QtWidgets.QMessageBox.Warning) Alert(self.common, strings._('update_error_invalid_latest_version').format(latest_version), QtWidgets.QMessageBox.Warning)
close_forced_update_thread() close_forced_update_thread()
forced_update_thread = UpdateThread(self.common, self.onion, self.config, force=True) forced_update_thread = UpdateThread(self.common, self.onion, self.config, force=True)
@ -905,7 +905,7 @@ class SettingsDialog(QtWidgets.QDialog):
""" """
self.common.log('SettingsDialog', 'cancel_clicked') self.common.log('SettingsDialog', 'cancel_clicked')
if not self.local_only and not self.onion.is_authenticated(): if not self.local_only and not self.onion.is_authenticated():
Alert(self.common, strings._('gui_tor_connection_canceled', True), QtWidgets.QMessageBox.Warning) Alert(self.common, strings._('gui_tor_connection_canceled'), QtWidgets.QMessageBox.Warning)
sys.exit() sys.exit()
else: else:
self.close() self.close()
@ -938,7 +938,7 @@ class SettingsDialog(QtWidgets.QDialog):
if self.save_private_key_checkbox.isChecked(): if self.save_private_key_checkbox.isChecked():
# force the legacy mode on # force the legacy mode on
use_legacy_v2_onions = True use_legacy_v2_onions = True
settings.set('save_private_key', True) settings.set('save_private_key')
settings.set('private_key', self.old_settings.get('private_key')) settings.set('private_key', self.old_settings.get('private_key'))
settings.set('slug', self.old_settings.get('slug')) settings.set('slug', self.old_settings.get('slug'))
settings.set('hidservauth_string', self.old_settings.get('hidservauth_string')) settings.set('hidservauth_string', self.old_settings.get('hidservauth_string'))
@ -950,7 +950,7 @@ class SettingsDialog(QtWidgets.QDialog):
settings.set('hidservauth_string', '') settings.set('hidservauth_string', '')
if use_legacy_v2_onions: if use_legacy_v2_onions:
settings.set('use_legacy_v2_onions', True) settings.set('use_legacy_v2_onions')
else: else:
settings.set('use_legacy_v2_onions', False) settings.set('use_legacy_v2_onions', False)
# If we are not using legacy mode, but we previously had persistence turned on, force it off! # If we are not using legacy mode, but we previously had persistence turned on, force it off!
@ -984,7 +984,7 @@ class SettingsDialog(QtWidgets.QDialog):
settings.set('connection_type', 'socket_file') settings.set('connection_type', 'socket_file')
if self.autoupdate_checkbox.isChecked(): if self.autoupdate_checkbox.isChecked():
settings.set('use_autoupdate', True) settings.set('use_autoupdate')
else: else:
settings.set('use_autoupdate', False) settings.set('use_autoupdate', False)
@ -1004,19 +1004,19 @@ class SettingsDialog(QtWidgets.QDialog):
# Whether we use bridges # Whether we use bridges
if self.tor_bridges_no_bridges_radio.isChecked(): if self.tor_bridges_no_bridges_radio.isChecked():
settings.set('no_bridges', True) settings.set('no_bridges')
settings.set('tor_bridges_use_obfs4', False) settings.set('tor_bridges_use_obfs4', False)
settings.set('tor_bridges_use_meek_lite_azure', False) settings.set('tor_bridges_use_meek_lite_azure', False)
settings.set('tor_bridges_use_custom_bridges', '') settings.set('tor_bridges_use_custom_bridges', '')
if self.tor_bridges_use_obfs4_radio.isChecked(): if self.tor_bridges_use_obfs4_radio.isChecked():
settings.set('no_bridges', False) settings.set('no_bridges', False)
settings.set('tor_bridges_use_obfs4', True) settings.set('tor_bridges_use_obfs4')
settings.set('tor_bridges_use_meek_lite_azure', False) settings.set('tor_bridges_use_meek_lite_azure', False)
settings.set('tor_bridges_use_custom_bridges', '') settings.set('tor_bridges_use_custom_bridges', '')
if self.tor_bridges_use_meek_lite_azure_radio.isChecked(): if self.tor_bridges_use_meek_lite_azure_radio.isChecked():
settings.set('no_bridges', False) settings.set('no_bridges', False)
settings.set('tor_bridges_use_obfs4', False) settings.set('tor_bridges_use_obfs4', False)
settings.set('tor_bridges_use_meek_lite_azure', True) settings.set('tor_bridges_use_meek_lite_azure')
settings.set('tor_bridges_use_custom_bridges', '') settings.set('tor_bridges_use_custom_bridges', '')
if self.tor_bridges_use_custom_radio.isChecked(): if self.tor_bridges_use_custom_radio.isChecked():
settings.set('no_bridges', False) settings.set('no_bridges', False)
@ -1047,8 +1047,8 @@ class SettingsDialog(QtWidgets.QDialog):
new_bridges = ''.join(new_bridges) new_bridges = ''.join(new_bridges)
settings.set('tor_bridges_use_custom_bridges', new_bridges) settings.set('tor_bridges_use_custom_bridges', new_bridges)
else: else:
Alert(self.common, strings._('gui_settings_tor_bridges_invalid', True)) Alert(self.common, strings._('gui_settings_tor_bridges_invalid'))
settings.set('no_bridges', True) settings.set('no_bridges')
return False return False
return settings return settings
@ -1071,11 +1071,11 @@ class SettingsDialog(QtWidgets.QDialog):
dt = datetime.datetime.fromtimestamp(autoupdate_timestamp) dt = datetime.datetime.fromtimestamp(autoupdate_timestamp)
last_checked = dt.strftime('%B %d, %Y %H:%M') last_checked = dt.strftime('%B %d, %Y %H:%M')
else: else:
last_checked = strings._('gui_settings_autoupdate_timestamp_never', True) last_checked = strings._('gui_settings_autoupdate_timestamp_never')
self.autoupdate_timestamp.setText(strings._('gui_settings_autoupdate_timestamp', True).format(last_checked)) self.autoupdate_timestamp.setText(strings._('gui_settings_autoupdate_timestamp').format(last_checked))
def _tor_status_update(self, progress, summary): def _tor_status_update(self, progress, summary):
self.tor_status.setText('<strong>{}</strong><br>{}% {}'.format(strings._('connecting_to_tor', True), progress, summary)) self.tor_status.setText('<strong>{}</strong><br>{}% {}'.format(strings._('connecting_to_tor'), progress, summary))
self.qtapp.processEvents() self.qtapp.processEvents()
if 'Done' in summary: if 'Done' in summary:
self.tor_status.hide() self.tor_status.hide()

View file

@ -118,7 +118,7 @@ class ShareMode(Mode):
""" """
Return the string to put on the stop server button, if there's a shutdown timeout Return the string to put on the stop server button, if there's a shutdown timeout
""" """
return strings._('gui_share_stop_server_shutdown_timeout', True) return strings._('gui_share_stop_server_shutdown_timeout')
def timeout_finished_should_stop_server(self): def timeout_finished_should_stop_server(self):
""" """
@ -127,11 +127,11 @@ class ShareMode(Mode):
# If there were no attempts to download the share, or all downloads are done, we can stop # If there were no attempts to download the share, or all downloads are done, we can stop
if self.web.share_mode.download_count == 0 or self.web.done: if self.web.share_mode.download_count == 0 or self.web.done:
self.server_status.stop_server() self.server_status.stop_server()
self.server_status_label.setText(strings._('close_on_timeout', True)) self.server_status_label.setText(strings._('close_on_timeout'))
return True return True
# A download is probably still running - hold off on stopping the share # A download is probably still running - hold off on stopping the share
else: else:
self.server_status_label.setText(strings._('timeout_download_still_running', True)) self.server_status_label.setText(strings._('timeout_download_still_running'))
return False return False
def start_server_custom(self): def start_server_custom(self):
@ -178,7 +178,7 @@ class ShareMode(Mode):
# Warn about sending large files over Tor # Warn about sending large files over Tor
if self.web.share_mode.download_filesize >= 157286400: # 150mb if self.web.share_mode.download_filesize >= 157286400: # 150mb
self.filesize_warning.setText(strings._("large_filesize", True)) self.filesize_warning.setText(strings._("large_filesize"))
self.filesize_warning.show() self.filesize_warning.show()
def start_server_error_custom(self): def start_server_error_custom(self):
@ -223,7 +223,7 @@ class ShareMode(Mode):
""" """
Handle REQUEST_LOAD event. Handle REQUEST_LOAD event.
""" """
self.system_tray.showMessage(strings._('systray_page_loaded_title', True), strings._('systray_download_page_loaded_message', True)) self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_download_page_loaded_message'))
def handle_request_started(self, event): def handle_request_started(self, event):
""" """
@ -237,7 +237,7 @@ class ShareMode(Mode):
self.downloads_in_progress += 1 self.downloads_in_progress += 1
self.update_downloads_in_progress() self.update_downloads_in_progress()
self.system_tray.showMessage(strings._('systray_download_started_title', True), strings._('systray_download_started_message', True)) self.system_tray.showMessage(strings._('systray_download_started_title'), strings._('systray_download_started_message'))
def handle_request_progress(self, event): def handle_request_progress(self, event):
""" """
@ -247,7 +247,7 @@ class ShareMode(Mode):
# Is the download complete? # Is the download complete?
if event["data"]["bytes"] == self.web.share_mode.filesize: if event["data"]["bytes"] == self.web.share_mode.filesize:
self.system_tray.showMessage(strings._('systray_download_completed_title', True), strings._('systray_download_completed_message', True)) self.system_tray.showMessage(strings._('systray_download_completed_title'), strings._('systray_download_completed_message'))
# Update the total 'completed downloads' info # Update the total 'completed downloads' info
self.downloads_completed += 1 self.downloads_completed += 1
@ -260,7 +260,7 @@ class ShareMode(Mode):
if self.common.settings.get('close_after_first_download'): if self.common.settings.get('close_after_first_download'):
self.server_status.stop_server() self.server_status.stop_server()
self.status_bar.clearMessage() self.status_bar.clearMessage()
self.server_status_label.setText(strings._('closing_automatically', True)) self.server_status_label.setText(strings._('closing_automatically'))
else: else:
if self.server_status.status == self.server_status.STATUS_STOPPED: if self.server_status.status == self.server_status.STATUS_STOPPED:
self.downloads.cancel(event["data"]["id"]) self.downloads.cancel(event["data"]["id"])
@ -276,7 +276,7 @@ class ShareMode(Mode):
# Update the 'in progress downloads' info # Update the 'in progress downloads' info
self.downloads_in_progress -= 1 self.downloads_in_progress -= 1
self.update_downloads_in_progress() self.update_downloads_in_progress()
self.system_tray.showMessage(strings._('systray_download_canceled_title', True), strings._('systray_download_canceled_message', True)) self.system_tray.showMessage(strings._('systray_download_canceled_title'), strings._('systray_download_canceled_message'))
def on_reload_settings(self): def on_reload_settings(self):
""" """
@ -302,9 +302,9 @@ class ShareMode(Mode):
total_size_readable = self.common.human_readable_filesize(total_size_bytes) total_size_readable = self.common.human_readable_filesize(total_size_bytes)
if file_count > 1: if file_count > 1:
self.info_label.setText(strings._('gui_file_info', True).format(file_count, total_size_readable)) self.info_label.setText(strings._('gui_file_info').format(file_count, total_size_readable))
else: else:
self.info_label.setText(strings._('gui_file_info_single', True).format(file_count, total_size_readable)) self.info_label.setText(strings._('gui_file_info_single').format(file_count, total_size_readable))
else: else:
self.primary_action.hide() self.primary_action.hide()
@ -332,7 +332,7 @@ class ShareMode(Mode):
else: else:
image = self.common.get_resource_path('images/share_completed.png') image = self.common.get_resource_path('images/share_completed.png')
self.info_completed_downloads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.downloads_completed)) self.info_completed_downloads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.downloads_completed))
self.info_completed_downloads_count.setToolTip(strings._('info_completed_downloads_tooltip', True).format(self.downloads_completed)) self.info_completed_downloads_count.setToolTip(strings._('info_completed_downloads_tooltip').format(self.downloads_completed))
def update_downloads_in_progress(self): def update_downloads_in_progress(self):
""" """
@ -343,7 +343,7 @@ class ShareMode(Mode):
else: else:
image = self.common.get_resource_path('images/share_in_progress.png') image = self.common.get_resource_path('images/share_in_progress.png')
self.info_in_progress_downloads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.downloads_in_progress)) self.info_in_progress_downloads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.downloads_in_progress))
self.info_in_progress_downloads_count.setToolTip(strings._('info_in_progress_downloads_tooltip', True).format(self.downloads_in_progress)) self.info_in_progress_downloads_count.setToolTip(strings._('info_in_progress_downloads_tooltip').format(self.downloads_in_progress))
@staticmethod @staticmethod
def _compute_total_size(filenames): def _compute_total_size(filenames):

View file

@ -89,7 +89,7 @@ class Downloads(QtWidgets.QScrollArea):
self.downloads = {} self.downloads = {}
self.setWindowTitle(strings._('gui_downloads', True)) self.setWindowTitle(strings._('gui_downloads'))
self.setWidgetResizable(True) self.setWidgetResizable(True)
self.setMinimumHeight(150) self.setMinimumHeight(150)
self.setMinimumWidth(350) self.setMinimumWidth(350)
@ -98,10 +98,10 @@ class Downloads(QtWidgets.QScrollArea):
self.vbar = self.verticalScrollBar() self.vbar = self.verticalScrollBar()
self.vbar.rangeChanged.connect(self.resizeScroll) self.vbar.rangeChanged.connect(self.resizeScroll)
downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True)) downloads_label = QtWidgets.QLabel(strings._('gui_downloads'))
downloads_label.setStyleSheet(self.common.css['downloads_uploads_label']) downloads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
self.no_downloads_label = QtWidgets.QLabel(strings._('gui_no_downloads', True)) self.no_downloads_label = QtWidgets.QLabel(strings._('gui_no_downloads'))
self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history', True)) self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history'))
self.clear_history_button.clicked.connect(self.reset) self.clear_history_button.clicked.connect(self.reset)
self.clear_history_button.hide() self.clear_history_button.hide()

View file

@ -41,7 +41,7 @@ class DropHereLabel(QtWidgets.QLabel):
if image: if image:
self.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/logo_transparent.png')))) self.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/logo_transparent.png'))))
else: else:
self.setText(strings._('gui_drag_and_drop', True)) self.setText(strings._('gui_drag_and_drop'))
self.setStyleSheet(self.common.css['share_file_selection_drop_here_label']) self.setStyleSheet(self.common.css['share_file_selection_drop_here_label'])
self.hide() self.hide()
@ -65,7 +65,7 @@ class DropCountLabel(QtWidgets.QLabel):
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.setAlignment(QtCore.Qt.AlignCenter) self.setAlignment(QtCore.Qt.AlignCenter)
self.setText(strings._('gui_drag_and_drop', True)) self.setText(strings._('gui_drag_and_drop'))
self.setStyleSheet(self.common.css['share_file_selection_drop_count_label']) self.setStyleSheet(self.common.css['share_file_selection_drop_count_label'])
self.hide() self.hide()
@ -216,7 +216,7 @@ class FileList(QtWidgets.QListWidget):
if filename not in filenames: if filename not in filenames:
if not os.access(filename, os.R_OK): if not os.access(filename, os.R_OK):
Alert(self.common, strings._("not_a_readable_file", True).format(filename)) Alert(self.common, strings._("not_a_readable_file").format(filename))
return return
fileinfo = QtCore.QFileInfo(filename) fileinfo = QtCore.QFileInfo(filename)
@ -301,9 +301,9 @@ class FileSelection(QtWidgets.QVBoxLayout):
self.file_list.files_updated.connect(self.update) self.file_list.files_updated.connect(self.update)
# Buttons # Buttons
self.add_button = QtWidgets.QPushButton(strings._('gui_add', True)) self.add_button = QtWidgets.QPushButton(strings._('gui_add'))
self.add_button.clicked.connect(self.add) self.add_button.clicked.connect(self.add)
self.delete_button = QtWidgets.QPushButton(strings._('gui_delete', True)) self.delete_button = QtWidgets.QPushButton(strings._('gui_delete'))
self.delete_button.clicked.connect(self.delete) self.delete_button.clicked.connect(self.delete)
button_layout = QtWidgets.QHBoxLayout() button_layout = QtWidgets.QHBoxLayout()
button_layout.addStretch() button_layout.addStretch()
@ -340,7 +340,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
""" """
Add button clicked. Add button clicked.
""" """
file_dialog = AddFileDialog(self.common, caption=strings._('gui_choose_items', True)) file_dialog = AddFileDialog(self.common, caption=strings._('gui_choose_items'))
if file_dialog.exec_() == QtWidgets.QDialog.Accepted: if file_dialog.exec_() == QtWidgets.QDialog.Accepted:
for filename in file_dialog.selectedFiles(): for filename in file_dialog.selectedFiles():
self.file_list.add_file(filename) self.file_list.add_file(filename)

View file

@ -51,7 +51,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
self.setFixedSize(400, 150) self.setFixedSize(400, 150)
# Label # Label
self.setLabelText(strings._('connecting_to_tor', True)) self.setLabelText(strings._('connecting_to_tor'))
# Progress bar ticks from 0 to 100 # Progress bar ticks from 0 to 100
self.setRange(0, 100) self.setRange(0, 100)
@ -81,7 +81,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
def _tor_status_update(self, progress, summary): def _tor_status_update(self, progress, summary):
self.setValue(int(progress)) self.setValue(int(progress))
self.setLabelText("<strong>{}</strong><br>{}".format(strings._('connecting_to_tor', True), summary)) self.setLabelText("<strong>{}</strong><br>{}".format(strings._('connecting_to_tor'), summary))
def _connected_to_tor(self): def _connected_to_tor(self):
self.common.log('TorConnectionDialog', '_connected_to_tor') self.common.log('TorConnectionDialog', '_connected_to_tor')
@ -104,7 +104,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
def alert_and_open_settings(): def alert_and_open_settings():
# Display the exception in an alert box # Display the exception in an alert box
Alert(self.common, "{}\n\n{}".format(msg, strings._('gui_tor_connection_error_settings', True)), QtWidgets.QMessageBox.Warning) Alert(self.common, "{}\n\n{}".format(msg, strings._('gui_tor_connection_error_settings')), QtWidgets.QMessageBox.Warning)
# Open settings # Open settings
self.open_settings.emit() self.open_settings.emit()