diff --git a/onionshare/common.py b/onionshare/common.py index 4a5c388e..8f4d257e 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -267,6 +267,6 @@ class close_after_seconds(threading.Thread): self.time = time def run(self): - log('Shutdown Timer', 'Server will shut down after {} seconds'.format(3600 * self.time)) - time.sleep(3600 * self.time) # seconds -> hours + log('Shutdown Timer', 'Server will shut down after {} seconds'.format(self.time)) + time.sleep(self.time) return 1 diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 151d2468..06d17df6 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -374,7 +374,7 @@ 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.server_shutdown_timeout.value() > 0: + if self.app.shutdown_timer and self.server_status.timeout > 0: if not self.app.shutdown_timer.is_alive(): self.server_status.stop_server() self.status_bar.showMessage(strings._('close_on_timeout',True)) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 35c49072..7bf8011a 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -50,8 +50,9 @@ class ServerStatus(QtWidgets.QVBoxLayout): self.server_shutdown_timeout_checkbox.toggled.connect(self.shutdown_timeout_toggled) self.server_shutdown_timeout_checkbox.setText(strings._("gui_settings_shutdown_timeout_choice", True)) self.server_shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True)) - self.server_shutdown_timeout = QtWidgets.QDoubleSpinBox() - self.server_shutdown_timeout.setRange(0,100) + self.server_shutdown_timeout = QtWidgets.QDateTimeEdit() + self.server_shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime()) + self.server_shutdown_timeout.setCurrentSectionIndex(4) self.server_shutdown_timeout_label.hide() self.server_shutdown_timeout.hide() shutdown_timeout_layout_group = QtWidgets.QHBoxLayout() @@ -177,9 +178,12 @@ class ServerStatus(QtWidgets.QVBoxLayout): The server has finished starting. """ self.status = self.STATUS_STARTED + # Convert the date value to seconds between now and then + now = QtCore.QDateTime.currentDateTime() + self.timeout = now.secsTo(self.server_shutdown_timeout.dateTime()) # Set the shutdown timeout value - if self.server_shutdown_timeout.value() > 0: - self.app.shutdown_timer = common.close_after_seconds(self.server_shutdown_timeout.value()) + if self.timeout > 0: + self.app.shutdown_timer = common.close_after_seconds(self.timeout) self.app.shutdown_timer.start() self.copy_url() self.update() diff --git a/share/locale/en.json b/share/locale/en.json index 0f2a3518..2965869e 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -92,7 +92,7 @@ "gui_settings_button_cancel": "Cancel", "gui_settings_button_help": "Help", "gui_settings_shutdown_timeout_choice": "Set auto-stop timer?", - "gui_settings_shutdown_timeout": "Auto-stop share in (hours):", + "gui_settings_shutdown_timeout": "Auto-stop share at:", "settings_saved": "Settings saved to {}", "settings_error_unknown": "Can't connect to Tor controller because the settings don't make sense.", "settings_error_automatic": "Can't connect to Tor controller. Is Tor Browser running in the background? If you don't have it you can get it from:\nhttps://www.torproject.org/.",