mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-18 21:34:17 -05:00
use QDateTimeEdit instead of a spinbox for selecting a future date/time to auto-stop share
This commit is contained in:
parent
89129a2ca7
commit
f5b45539b0
@ -267,6 +267,6 @@ class close_after_seconds(threading.Thread):
|
|||||||
self.time = time
|
self.time = time
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
log('Shutdown Timer', 'Server will shut down after {} seconds'.format(3600 * self.time))
|
log('Shutdown Timer', 'Server will shut down after {} seconds'.format(self.time))
|
||||||
time.sleep(3600 * self.time) # seconds -> hours
|
time.sleep(self.time)
|
||||||
return 1
|
return 1
|
||||||
|
@ -374,7 +374,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
# If the auto-shutdown timer has stopped, stop the server
|
# If the auto-shutdown timer has stopped, stop the server
|
||||||
if self.server_status.status == self.server_status.STATUS_STARTED:
|
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():
|
if not self.app.shutdown_timer.is_alive():
|
||||||
self.server_status.stop_server()
|
self.server_status.stop_server()
|
||||||
self.status_bar.showMessage(strings._('close_on_timeout',True))
|
self.status_bar.showMessage(strings._('close_on_timeout',True))
|
||||||
|
@ -50,8 +50,9 @@ class ServerStatus(QtWidgets.QVBoxLayout):
|
|||||||
self.server_shutdown_timeout_checkbox.toggled.connect(self.shutdown_timeout_toggled)
|
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_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_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True))
|
||||||
self.server_shutdown_timeout = QtWidgets.QDoubleSpinBox()
|
self.server_shutdown_timeout = QtWidgets.QDateTimeEdit()
|
||||||
self.server_shutdown_timeout.setRange(0,100)
|
self.server_shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime())
|
||||||
|
self.server_shutdown_timeout.setCurrentSectionIndex(4)
|
||||||
self.server_shutdown_timeout_label.hide()
|
self.server_shutdown_timeout_label.hide()
|
||||||
self.server_shutdown_timeout.hide()
|
self.server_shutdown_timeout.hide()
|
||||||
shutdown_timeout_layout_group = QtWidgets.QHBoxLayout()
|
shutdown_timeout_layout_group = QtWidgets.QHBoxLayout()
|
||||||
@ -177,9 +178,12 @@ class ServerStatus(QtWidgets.QVBoxLayout):
|
|||||||
The server has finished starting.
|
The server has finished starting.
|
||||||
"""
|
"""
|
||||||
self.status = self.STATUS_STARTED
|
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
|
# Set the shutdown timeout value
|
||||||
if self.server_shutdown_timeout.value() > 0:
|
if self.timeout > 0:
|
||||||
self.app.shutdown_timer = common.close_after_seconds(self.server_shutdown_timeout.value())
|
self.app.shutdown_timer = common.close_after_seconds(self.timeout)
|
||||||
self.app.shutdown_timer.start()
|
self.app.shutdown_timer.start()
|
||||||
self.copy_url()
|
self.copy_url()
|
||||||
self.update()
|
self.update()
|
||||||
|
@ -92,7 +92,7 @@
|
|||||||
"gui_settings_button_cancel": "Cancel",
|
"gui_settings_button_cancel": "Cancel",
|
||||||
"gui_settings_button_help": "Help",
|
"gui_settings_button_help": "Help",
|
||||||
"gui_settings_shutdown_timeout_choice": "Set auto-stop timer?",
|
"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_saved": "Settings saved to {}",
|
||||||
"settings_error_unknown": "Can't connect to Tor controller because the settings don't make sense.",
|
"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/.",
|
"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/.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user