mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 19:52:50 -03:00
Fix logic that checks if auto-start timer setting is enabled, so that it checks real settings and not widget instantiation. Ensure the auto-start and auto-stop widgets show their datetime widget on start-up if the setting was already enabled.
This commit is contained in:
parent
1c424500f0
commit
a7856d5dcb
4 changed files with 15 additions and 21 deletions
|
@ -138,7 +138,7 @@ class Mode(QtWidgets.QWidget):
|
|||
"""
|
||||
# If this is a scheduled share, display the countdown til the share starts
|
||||
if self.server_status.status == ServerStatus.STATUS_WORKING:
|
||||
if self.server_status.autostart_timer_datetime:
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
now = QtCore.QDateTime.currentDateTime()
|
||||
if self.server_status.local_only:
|
||||
seconds_remaining = now.secsTo(
|
||||
|
@ -227,13 +227,8 @@ class Mode(QtWidgets.QWidget):
|
|||
# Start the onion thread. If this share was scheduled for a future date,
|
||||
# the OnionThread will start and exit 'early' to obtain the port, password
|
||||
# and onion address, but it will not start the WebThread yet.
|
||||
if self.server_status.autostart_timer_datetime:
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
self.start_onion_thread(obtain_onion_early=True)
|
||||
else:
|
||||
self.start_onion_thread()
|
||||
|
||||
# If scheduling a share, delay starting the real share
|
||||
if self.server_status.autostart_timer_datetime:
|
||||
self.common.log("Mode", "start_server", "Starting auto-start timer")
|
||||
self.startup_thread = AutoStartTimer(self)
|
||||
# Once the timer has finished, start the real share, with a WebThread
|
||||
|
@ -241,6 +236,8 @@ class Mode(QtWidgets.QWidget):
|
|||
self.startup_thread.error.connect(self.start_server_error)
|
||||
self.startup_thread.canceled = False
|
||||
self.startup_thread.start()
|
||||
else:
|
||||
self.start_onion_thread()
|
||||
|
||||
def start_onion_thread(self, obtain_onion_early=False):
|
||||
self.common.log("Mode", "start_server", "Starting an onion thread")
|
||||
|
|
|
@ -76,7 +76,10 @@ class ModeSettingsWidget(QtWidgets.QWidget):
|
|||
self.autostart_timer_widget.setCurrentSection(
|
||||
QtWidgets.QDateTimeEdit.MinuteSection
|
||||
)
|
||||
self.autostart_timer_widget.hide()
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
self.autostart_timer_widget.show()
|
||||
else:
|
||||
self.autostart_timer_widget.hide()
|
||||
|
||||
# Autostart timer layout
|
||||
autostart_timer_layout = QtWidgets.QHBoxLayout()
|
||||
|
@ -104,7 +107,10 @@ class ModeSettingsWidget(QtWidgets.QWidget):
|
|||
self.autostop_timer_widget.setCurrentSection(
|
||||
QtWidgets.QDateTimeEdit.MinuteSection
|
||||
)
|
||||
self.autostop_timer_widget.hide()
|
||||
if self.settings.get("general", "autostop_timer"):
|
||||
self.autostop_timer_widget.show()
|
||||
else:
|
||||
self.autostop_timer_widget.hide()
|
||||
|
||||
# Autostop timer layout
|
||||
autostop_timer_layout = QtWidgets.QHBoxLayout()
|
||||
|
|
|
@ -269,7 +269,7 @@ class ServerStatus(QtWidgets.QWidget):
|
|||
self.common.gui.css["server_status_button_working"]
|
||||
)
|
||||
self.server_button.setEnabled(True)
|
||||
if self.autostart_timer_datetime:
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
self.server_button.setToolTip(
|
||||
strings._("gui_start_server_autostart_timer_tooltip").format(
|
||||
self.mode_settings_widget.autostart_timer_widget.dateTime().toString(
|
||||
|
@ -279,15 +279,6 @@ class ServerStatus(QtWidgets.QWidget):
|
|||
)
|
||||
else:
|
||||
self.server_button.setText(strings._("gui_please_wait"))
|
||||
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
self.server_button.setToolTip(
|
||||
strings._("gui_start_server_autostart_timer_tooltip").format(
|
||||
self.mode_settings_widget.autostart_timer_widget.dateTime().toString(
|
||||
"h:mm AP, MMMM dd, yyyy"
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.server_button.setStyleSheet(
|
||||
self.common.gui.css["server_status_button_working"]
|
||||
|
|
|
@ -287,7 +287,7 @@ class Tab(QtWidgets.QWidget):
|
|||
strings._("gui_status_indicator_share_stopped")
|
||||
)
|
||||
elif self.share_mode.server_status.status == ServerStatus.STATUS_WORKING:
|
||||
if self.share_mode.server_status.autostart_timer_datetime:
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
self.set_server_status_indicator_working(
|
||||
strings._("gui_status_indicator_share_scheduled")
|
||||
)
|
||||
|
@ -320,7 +320,7 @@ class Tab(QtWidgets.QWidget):
|
|||
strings._("gui_status_indicator_receive_stopped")
|
||||
)
|
||||
elif self.receive_mode.server_status.status == ServerStatus.STATUS_WORKING:
|
||||
if self.receive_mode.server_status.autostart_timer_datetime:
|
||||
if self.settings.get("general", "autostart_timer"):
|
||||
self.set_server_status_indicator_working(
|
||||
strings._("gui_status_indicator_receive_scheduled")
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue