mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Fix shutdown timer and insert larger messages as word-wrapped widgets into the Status Bar
This commit is contained in:
parent
af1b56e659
commit
749ca6312d
@ -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):
|
||||
"""
|
||||
|
@ -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.
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user