From 749ca6312d74530bb4926a4f725e0295464c78c2 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 8 Feb 2018 11:32:34 +1100 Subject: [PATCH 1/7] Fix shutdown timer and insert larger messages as word-wrapped widgets into the Status Bar --- onionshare_gui/onionshare_gui.py | 33 +++++++++++++++++++++++++++----- onionshare_gui/server_status.py | 21 +------------------- share/locale/en.json | 2 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 7fdc3491..60788c36 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -139,6 +139,10 @@ class OnionShareGui(QtWidgets.QMainWindow): # Status bar, zip progress bar self._zip_progress_bar = None + # Status bar, other larger messages + self._close_on_timeout_label = None + self._closing_automatically_label = None + self._timeout_download_still_running_label = None # Persistent URL notification self.persistent_url_label = QtWidgets.QLabel(strings._('persistent_url_in_use', True)) @@ -315,6 +319,16 @@ class OnionShareGui(QtWidgets.QMainWindow): self.downloads_container.hide() self.downloads.reset_downloads() self.status_bar.clearMessage() + # Remove any other widgets from the statusBar + if self._close_on_timeout_label is not None: + self.status_bar.removeWidget(self._close_on_timeout_label) + self._close_on_timeout_label = None + if self._closing_automatically_label is not None: + self.status_bar.removeWidget(self._closing_automatically_label) + self._closing_automatically_label = None + if self._timeout_download_still_running_label is not None: + self.status_bar.removeWidget(self._timeout_download_still_running_label) + self._timeout_download_still_running_label = None # Reset web counters web.download_count = 0 @@ -396,7 +410,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.filesize_warning.setText(strings._("large_filesize", True)) self.filesize_warning.show() - if self.server_status.timer_enabled: + if self.settings.get('shutdown_timeout'): # Convert the date value to seconds between now and then now = QtCore.QDateTime.currentDateTime() self.timeout = now.secsTo(self.server_status.timeout) @@ -529,7 +543,10 @@ class OnionShareGui(QtWidgets.QMainWindow): # close on finish? if not web.get_stay_open(): self.server_status.stop_server() - self.status_bar.showMessage(strings._('closing_automatically', True)) + self._closing_automatically_label = QtWidgets.QLabel(strings._('closing_automatically', True)) + self._closing_automatically_label.setWordWrap(True) + self.status_bar.clearMessage() + self.status_bar.insertWidget(0, self._closing_automatically_label) else: if self.server_status.status == self.server_status.STATUS_STOPPED: self.downloads.cancel_download(event["data"]["id"]) @@ -544,16 +561,22 @@ class OnionShareGui(QtWidgets.QMainWindow): # If the auto-shutdown timer has stopped, stop the server if self.server_status.status == self.server_status.STATUS_STARTED: - if self.app.shutdown_timer and self.server_status.timer_enabled: + if self.app.shutdown_timer and self.settings.get('shutdown_timeout'): if self.timeout > 0: if not self.app.shutdown_timer.is_alive(): # If there were no attempts to download the share, or all downloads are done, we can stop if web.download_count == 0 or web.done: self.server_status.stop_server() - self.status_bar.showMessage(strings._('close_on_timeout', True)) + self._close_on_timeout_label = QtWidgets.QLabel(strings._('close_on_timeout', True)) + self._close_on_timeout_label.setWordWrap(True) + self.status_bar.clearMessage() + self.status_bar.insertWidget(0, self._close_on_timeout_label) # A download is probably still running - hold off on stopping the share else: - self.status_bar.showMessage(strings._('timeout_download_still_running', True)) + self._timeout_download_still_running_label = QtWidgets.QLabel(strings._('timeout_download_still_running', True)) + self._timeout_download_still_running_label.setWordWrap(True) + self.status_bar.clearMessage() + self.status_bar.insertWidget(0, self._timeout_download_still_running_label) def copy_url(self): """ diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 786deb64..adf064fb 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -47,9 +47,6 @@ class ServerStatus(QtWidgets.QWidget): self.settings = settings - # Helper boolean as this is used in a few places - self.timer_enabled = False - # Shutdown timeout layout self.shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True)) self.shutdown_timeout = QtWidgets.QDateTimeEdit() @@ -114,22 +111,6 @@ class ServerStatus(QtWidgets.QWidget): self.update() - def shutdown_timeout_toggled(self, checked): - """ - Shutdown timer option was toggled. If checked, show the timer settings. - """ - if checked: - self.timer_enabled = True - # Hide the checkbox, show the options - self.shutdown_timeout_label.show() - # Reset the default timer to 5 minutes into the future after toggling the option on - self.shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime().addSecs(300)) - self.shutdown_timeout.show() - else: - self.timer_enabled = False - self.shutdown_timeout_label.hide() - self.shutdown_timeout.hide() - def shutdown_timeout_reset(self): """ Reset the timeout in the UI after stopping a share @@ -212,7 +193,7 @@ class ServerStatus(QtWidgets.QWidget): Toggle starting or stopping the server. """ if self.status == self.STATUS_STOPPED: - if self.timer_enabled: + if self.settings.get('shutdown_timeout'): # Get the timeout chosen, stripped of its seconds. This prevents confusion if the share stops at (say) 37 seconds past the minute chosen self.timeout = self.shutdown_timeout.dateTime().toPyDateTime().replace(second=0, microsecond=0) # If the timeout has actually passed already before the user hit Start, refuse to start the server. diff --git a/share/locale/en.json b/share/locale/en.json index 5473a88f..5e08e57c 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -15,7 +15,7 @@ "other_page_loaded": "Address loaded", "close_on_timeout": "Closing automatically because timeout was reached", "closing_automatically": "Closing automatically because download finished", - "timeout_download_still_running": "Waiting for download to complete before auto-stopping", + "timeout_download_still_running": "Waiting for download to complete before stopping", "large_filesize": "Warning: Sending large files could take hours", "error_tails_invalid_port": "Invalid value, port must be an integer", "error_tails_unknown_root": "Unknown error with Tails root process", From 4d68b1a3dda5f1eb77cb2bde5f0e712b9aeb8f42 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 8 Feb 2018 11:53:56 +1100 Subject: [PATCH 2/7] Friendlier datetime format for the shutdown timer --- onionshare_gui/server_status.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index adf064fb..79fb4d67 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -51,10 +51,11 @@ class ServerStatus(QtWidgets.QWidget): self.shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True)) self.shutdown_timeout = QtWidgets.QDateTimeEdit() # Set proposed timeout to be 5 minutes into the future + self.shutdown_timeout.setDisplayFormat("HH:mm A MMM d, yy") self.shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime().addSecs(300)) # Onion services can take a little while to start, so reduce the risk of it expiring too soon by setting the minimum to 2 min from now self.shutdown_timeout.setMinimumDateTime(QtCore.QDateTime.currentDateTime().addSecs(120)) - self.shutdown_timeout.setCurrentSectionIndex(4) + self.shutdown_timeout.setCurrentSection(QtWidgets.QDateTimeEdit.MinuteSection) shutdown_timeout_layout = QtWidgets.QHBoxLayout() shutdown_timeout_layout.addWidget(self.shutdown_timeout_label) shutdown_timeout_layout.addWidget(self.shutdown_timeout) From 4751334ab1c46cdccdcb704f709222034001e43a Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 8 Feb 2018 12:03:40 +1100 Subject: [PATCH 3/7] Reduce the size of the closing messages so they only wrap 2 lines --- share/locale/en.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/locale/en.json b/share/locale/en.json index 5e08e57c..89d31c82 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -13,9 +13,9 @@ "no_available_port": "Could not start the Onion service as there was no available port.", "download_page_loaded": "Download page loaded", "other_page_loaded": "Address loaded", - "close_on_timeout": "Closing automatically because timeout was reached", - "closing_automatically": "Closing automatically because download finished", - "timeout_download_still_running": "Waiting for download to complete before stopping", + "close_on_timeout": "Stopped because timeout was reached", + "closing_automatically": "Stopped because download finished", + "timeout_download_still_running": "Waiting for download to complete", "large_filesize": "Warning: Sending large files could take hours", "error_tails_invalid_port": "Invalid value, port must be an integer", "error_tails_unknown_root": "Unknown error with Tails root process", From 3e5d51a858fff8a04d25ef183b301c6c6f239942 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 8 Feb 2018 12:25:30 +1100 Subject: [PATCH 4/7] Make status bar styling consistent --- onionshare_gui/onionshare_gui.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 60788c36..05e8b224 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -132,7 +132,17 @@ class OnionShareGui(QtWidgets.QMainWindow): # Status bar self.status_bar = QtWidgets.QStatusBar() self.status_bar.setSizeGripEnabled(False) - self.status_bar.setStyleSheet("QStatusBar::item { border: 0px; }") + statusBar_cssStyleData =""" + QStatusBar { + font-style: italic; + color: #666666; + } + + QStatusBar::item { + border: 0px; + }""" + + self.status_bar.setStyleSheet(statusBar_cssStyleData) self.status_bar.addPermanentWidget(self.server_status_indicator) self.status_bar.addPermanentWidget(self.settings_button) self.setStatusBar(self.status_bar) @@ -545,6 +555,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.server_status.stop_server() self._closing_automatically_label = QtWidgets.QLabel(strings._('closing_automatically', True)) self._closing_automatically_label.setWordWrap(True) + self._closing_automatically_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') self.status_bar.clearMessage() self.status_bar.insertWidget(0, self._closing_automatically_label) else: @@ -568,12 +579,14 @@ class OnionShareGui(QtWidgets.QMainWindow): if web.download_count == 0 or web.done: self.server_status.stop_server() self._close_on_timeout_label = QtWidgets.QLabel(strings._('close_on_timeout', True)) + self._close_on_timeout_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') self._close_on_timeout_label.setWordWrap(True) self.status_bar.clearMessage() self.status_bar.insertWidget(0, self._close_on_timeout_label) # A download is probably still running - hold off on stopping the share else: self._timeout_download_still_running_label = QtWidgets.QLabel(strings._('timeout_download_still_running', True)) + self._timeout_download_still_running_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') self._timeout_download_still_running_label.setWordWrap(True) self.status_bar.clearMessage() self.status_bar.insertWidget(0, self._timeout_download_still_running_label) From ef994ea012fe929081a011876d00b5c5db88f096 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Sun, 11 Feb 2018 09:54:22 +1100 Subject: [PATCH 5/7] Use just one share status QLabel widget and update the text accordingly --- onionshare_gui/onionshare_gui.py | 36 +++++++++----------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 05e8b224..99cbb479 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -93,6 +93,7 @@ class OnionShareGui(QtWidgets.QMainWindow): # Filesize warning self.filesize_warning = QtWidgets.QLabel() + self.filesize_warning.setWordWrap(True) self.filesize_warning.setStyleSheet('padding: 10px 0; font-weight: bold; color: #333333;') self.filesize_warning.hide() @@ -149,10 +150,11 @@ class OnionShareGui(QtWidgets.QMainWindow): # Status bar, zip progress bar self._zip_progress_bar = None - # Status bar, other larger messages - self._close_on_timeout_label = None - self._closing_automatically_label = None - self._timeout_download_still_running_label = None + # Status bar, sharing messages + self.server_share_status_label = QtWidgets.QLabel('') + self.server_share_status_label.setWordWrap(True) + self.server_share_status_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') + self.status_bar.insertWidget(0, self.server_share_status_label) # Persistent URL notification self.persistent_url_label = QtWidgets.QLabel(strings._('persistent_url_in_use', True)) @@ -329,16 +331,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.downloads_container.hide() self.downloads.reset_downloads() self.status_bar.clearMessage() - # Remove any other widgets from the statusBar - if self._close_on_timeout_label is not None: - self.status_bar.removeWidget(self._close_on_timeout_label) - self._close_on_timeout_label = None - if self._closing_automatically_label is not None: - self.status_bar.removeWidget(self._closing_automatically_label) - self._closing_automatically_label = None - if self._timeout_download_still_running_label is not None: - self.status_bar.removeWidget(self._timeout_download_still_running_label) - self._timeout_download_still_running_label = None + self.server_share_status_label.setText('') # Reset web counters web.download_count = 0 @@ -553,11 +546,8 @@ class OnionShareGui(QtWidgets.QMainWindow): # close on finish? if not web.get_stay_open(): self.server_status.stop_server() - self._closing_automatically_label = QtWidgets.QLabel(strings._('closing_automatically', True)) - self._closing_automatically_label.setWordWrap(True) - self._closing_automatically_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') self.status_bar.clearMessage() - self.status_bar.insertWidget(0, self._closing_automatically_label) + self.server_share_status_label.setText(strings._('closing_automatically', True)) else: if self.server_status.status == self.server_status.STATUS_STOPPED: self.downloads.cancel_download(event["data"]["id"]) @@ -578,18 +568,12 @@ class OnionShareGui(QtWidgets.QMainWindow): # If there were no attempts to download the share, or all downloads are done, we can stop if web.download_count == 0 or web.done: self.server_status.stop_server() - self._close_on_timeout_label = QtWidgets.QLabel(strings._('close_on_timeout', True)) - self._close_on_timeout_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') - self._close_on_timeout_label.setWordWrap(True) self.status_bar.clearMessage() - self.status_bar.insertWidget(0, self._close_on_timeout_label) + self.server_share_status_label.setText(strings._('close_on_timeout', True)) # A download is probably still running - hold off on stopping the share else: - self._timeout_download_still_running_label = QtWidgets.QLabel(strings._('timeout_download_still_running', True)) - self._timeout_download_still_running_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') - self._timeout_download_still_running_label.setWordWrap(True) self.status_bar.clearMessage() - self.status_bar.insertWidget(0, self._timeout_download_still_running_label) + self.server_share_status_label.setText(strings._('timeout_download_still_running', True)) def copy_url(self): """ From afc9568f30b45a838192f1654f06485c38fb28b7 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Sun, 11 Feb 2018 17:16:52 +1100 Subject: [PATCH 6/7] Adjust width of window to fit status bar messages, unwrapped, to avoid squishing widgets. Add pluralisation of filemanager total file(s) Use 'timer expired' rather than 'timeout reached' --- onionshare_gui/file_selection.py | 5 ++++- onionshare_gui/onionshare_gui.py | 12 ++++++------ onionshare_gui/server_status.py | 1 + share/locale/en.json | 5 +++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index b097e501..ba3df69d 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -310,7 +310,10 @@ class FileSelection(QtWidgets.QVBoxLayout): total_size_bytes += item.size_bytes total_size_readable = common.human_readable_filesize(total_size_bytes) - self.info_label.setText(strings._('gui_file_info', True).format(file_count, total_size_readable)) + if file_count > 1: + self.info_label.setText(strings._('gui_file_info', True).format(file_count, total_size_readable)) + else: + self.info_label.setText(strings._('gui_file_info_single', True).format(file_count, total_size_readable)) self.info_label.show() # All buttons should be hidden if the server is on diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 946000e9..f52281de 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -56,7 +56,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.setWindowTitle('OnionShare') self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png'))) - self.setMinimumWidth(350) + self.setMinimumWidth(430) # Load settings self.config = config @@ -152,7 +152,6 @@ class OnionShareGui(QtWidgets.QMainWindow): self._zip_progress_bar = None # Status bar, sharing messages self.server_share_status_label = QtWidgets.QLabel('') - self.server_share_status_label.setWordWrap(True) self.server_share_status_label.setStyleSheet('QLabel { font-style: italic; color: #666666; padding: 2px; }') self.status_bar.insertWidget(0, self.server_share_status_label) @@ -198,15 +197,15 @@ class OnionShareGui(QtWidgets.QMainWindow): self.check_for_updates() def update_primary_action(self): - # Resize window - self.adjustSize() - # Show or hide primary action layout if self.file_selection.file_list.count() > 0: self.primary_action.show() else: self.primary_action.hide() + # Resize window + self.adjustSize() + def update_server_status_indicator(self): common.log('OnionShareGui', 'update_server_status_indicator') @@ -450,9 +449,10 @@ class OnionShareGui(QtWidgets.QMainWindow): # Remove ephemeral service, but don't disconnect from Tor self.onion.cleanup(stop_tor=False) self.filesize_warning.hide() - self.stop_server_finished.emit() + self.file_selection.file_list.adjustSize() self.set_server_active(False) + self.stop_server_finished.emit() def check_for_updates(self): """ diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 5b6fdd52..c292d207 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -81,6 +81,7 @@ class ServerStatus(QtWidgets.QWidget): self.url.setFont(url_font) self.url.setWordWrap(True) self.url.setMinimumHeight(60) + self.url.setMinimumSize(self.url.sizeHint()) self.url.setStyleSheet('QLabel { background-color: #ffffff; color: #000000; padding: 10px; border: 1px solid #666666; }') url_buttons_style = 'QPushButton { color: #3f7fcf; }' diff --git a/share/locale/en.json b/share/locale/en.json index aed92e06..3e3d06c3 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -13,7 +13,7 @@ "no_available_port": "Could not start the Onion service as there was no available port.", "download_page_loaded": "Download page loaded", "other_page_loaded": "Address loaded", - "close_on_timeout": "Stopped because timeout was reached", + "close_on_timeout": "Stopped because timer expired", "closing_automatically": "Stopped because download finished", "timeout_download_still_running": "Waiting for download to complete", "large_filesize": "Warning: Sending large files could take hours", @@ -141,5 +141,6 @@ "gui_status_indicator_stopped": "Ready to Share", "gui_status_indicator_working": "Starting...", "gui_status_indicator_started": "Sharing", - "gui_file_info": "{} Files, {}" + "gui_file_info": "{} Files, {}", + "gui_file_info_single": "{} File, {}" } From e20e8d5181f772b77aa05ec94663fdbce5d850de Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 13 Feb 2018 17:20:10 -0800 Subject: [PATCH 7/7] Switch to 12 hour clock --- onionshare_gui/server_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index c292d207..a2701e6a 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -51,7 +51,7 @@ class ServerStatus(QtWidgets.QWidget): self.shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True)) self.shutdown_timeout = QtWidgets.QDateTimeEdit() # Set proposed timeout to be 5 minutes into the future - self.shutdown_timeout.setDisplayFormat("HH:mm A MMM d, yy") + self.shutdown_timeout.setDisplayFormat("hh:mm A MMM d, yy") self.shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime().addSecs(300)) # Onion services can take a little while to start, so reduce the risk of it expiring too soon by setting the minimum to 2 min from now self.shutdown_timeout.setMinimumDateTime(QtCore.QDateTime.currentDateTime().addSecs(120))