From a96991713bec44f4c33b5483a11547e2665eaf94 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 23 Nov 2022 17:04:15 +1100 Subject: [PATCH 1/2] Ensure Tab timer starts once tor is connected --- desktop/onionshare/main_window.py | 11 ----------- desktop/onionshare/settings_tab.py | 4 ---- desktop/onionshare/tab/mode/__init__.py | 2 ++ desktop/onionshare/tab/tab.py | 14 -------------- desktop/onionshare/tor_settings_tab.py | 4 ---- 5 files changed, 2 insertions(+), 33 deletions(-) diff --git a/desktop/onionshare/main_window.py b/desktop/onionshare/main_window.py index 7cad2df1..127c8605 100644 --- a/desktop/onionshare/main_window.py +++ b/desktop/onionshare/main_window.py @@ -244,17 +244,6 @@ class MainWindow(QtWidgets.QMainWindow): break self.tabs.open_settings_tab(from_autoconnect, active_tab=active_tab) - def settings_have_changed(self): - self.common.log("OnionShareGui", "settings_have_changed") - - if self.common.gui.onion.is_authenticated(): - self.status_bar.clearMessage() - - # Tell each tab that settings have changed - for index in range(self.tabs.count()): - tab = self.tabs.widget(index) - tab.settings_have_changed() - def bring_to_front(self): self.common.log("MainWindow", "bring_to_front") self.raise_() diff --git a/desktop/onionshare/settings_tab.py b/desktop/onionshare/settings_tab.py index cf2261b6..088efb6b 100644 --- a/desktop/onionshare/settings_tab.py +++ b/desktop/onionshare/settings_tab.py @@ -315,10 +315,6 @@ class SettingsTab(QtWidgets.QWidget): return settings - def settings_have_changed(self): - # Global settings have changed - self.common.log("SettingsTab", "settings_have_changed") - def _update_autoupdate_timestamp(self, autoupdate_timestamp): self.common.log("SettingsTab", "_update_autoupdate_timestamp") diff --git a/desktop/onionshare/tab/mode/__init__.py b/desktop/onionshare/tab/mode/__init__.py index a9fd2a12..65b05ef2 100644 --- a/desktop/onionshare/tab/mode/__init__.py +++ b/desktop/onionshare/tab/mode/__init__.py @@ -564,6 +564,8 @@ class Mode(QtWidgets.QWidget): self.content_widget.show() self.tor_not_connected_widget.hide() self.primary_action.show() + if not self.tab.timer.isActive(): + self.tab.timer.start(500) def tor_connection_stopped(self): """ diff --git a/desktop/onionshare/tab/tab.py b/desktop/onionshare/tab/tab.py index 5e2d4af8..680e5edb 100644 --- a/desktop/onionshare/tab/tab.py +++ b/desktop/onionshare/tab/tab.py @@ -630,20 +630,6 @@ class Tab(QtWidgets.QWidget): else: return None - def settings_have_changed(self): - # Global settings have changed - self.common.log("Tab", "settings_have_changed") - - # We might've stopped the main requests timer if a Tor connection failed. If we've reloaded - # settings, we probably succeeded in obtaining a new connection. If so, restart the timer. - if not self.common.gui.local_only: - if self.common.gui.onion.is_authenticated(): - mode = self.get_mode() - if mode: - if not self.timer.isActive(): - self.timer.start(500) - mode.on_reload_settings() - def close_tab(self): self.common.log("Tab", "close_tab") if self.mode is None: diff --git a/desktop/onionshare/tor_settings_tab.py b/desktop/onionshare/tor_settings_tab.py index 0e72c3b8..a685712f 100644 --- a/desktop/onionshare/tor_settings_tab.py +++ b/desktop/onionshare/tor_settings_tab.py @@ -903,7 +903,3 @@ class TorSettingsTab(QtWidgets.QWidget): # Wait 1ms for the event loop to finish, then quit QtCore.QTimer.singleShot(1, self.common.gui.qtapp.quit) - - def settings_have_changed(self): - # Global settings have changed - self.common.log("TorSettingsTab", "settings_have_changed") From bde2db38798517a60561ec4db689b13048d38e47 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 23 Nov 2022 17:09:41 +1100 Subject: [PATCH 2/2] Remove on_reload_settings() --- desktop/onionshare/tab/mode/chat_mode/__init__.py | 6 ------ desktop/onionshare/tab/mode/receive_mode/__init__.py | 6 ------ desktop/onionshare/tab/mode/share_mode/__init__.py | 10 ---------- desktop/onionshare/tab/mode/website_mode/__init__.py | 10 ---------- 4 files changed, 32 deletions(-) diff --git a/desktop/onionshare/tab/mode/chat_mode/__init__.py b/desktop/onionshare/tab/mode/chat_mode/__init__.py index af2cab81..61062f0f 100644 --- a/desktop/onionshare/tab/mode/chat_mode/__init__.py +++ b/desktop/onionshare/tab/mode/chat_mode/__init__.py @@ -149,11 +149,5 @@ class ChatMode(Mode): """ self.primary_action.hide() - def on_reload_settings(self): - """ - We should be ok to re-enable the 'Start Receive Mode' button now. - """ - self.primary_action.show() - def update_primary_action(self): self.common.log("ChatMode", "update_primary_action") diff --git a/desktop/onionshare/tab/mode/receive_mode/__init__.py b/desktop/onionshare/tab/mode/receive_mode/__init__.py index 55640c33..6c8dee10 100644 --- a/desktop/onionshare/tab/mode/receive_mode/__init__.py +++ b/desktop/onionshare/tab/mode/receive_mode/__init__.py @@ -409,12 +409,6 @@ class ReceiveMode(Mode): self.history.in_progress_count -= 1 self.history.update_in_progress() - def on_reload_settings(self): - """ - We should be ok to re-enable the 'Start Receive Mode' button now. - """ - self.primary_action.show() - def reset_info_counters(self): """ Set the info counters back to zero. diff --git a/desktop/onionshare/tab/mode/share_mode/__init__.py b/desktop/onionshare/tab/mode/share_mode/__init__.py index 2617176d..caa29e69 100644 --- a/desktop/onionshare/tab/mode/share_mode/__init__.py +++ b/desktop/onionshare/tab/mode/share_mode/__init__.py @@ -362,16 +362,6 @@ class ShareMode(Mode): strings._("systray_share_canceled_message"), ) - def on_reload_settings(self): - """ - If there were some files listed for sharing, we should be ok to re-enable - the 'Start Sharing' button now. - """ - if self.server_status.file_selection.get_num_files() > 0: - self.primary_action.show() - self.info_label.show() - self.remove_all_button.show() - def update_primary_action(self): self.common.log("ShareMode", "update_primary_action") diff --git a/desktop/onionshare/tab/mode/website_mode/__init__.py b/desktop/onionshare/tab/mode/website_mode/__init__.py index a732c390..df031bad 100644 --- a/desktop/onionshare/tab/mode/website_mode/__init__.py +++ b/desktop/onionshare/tab/mode/website_mode/__init__.py @@ -317,16 +317,6 @@ class WebsiteMode(Mode): """ self.primary_action.hide() - def on_reload_settings(self): - """ - If there were some files listed for sharing, we should be ok to re-enable - the 'Start Sharing' button now. - """ - if self.server_status.file_selection.get_num_files() > 0: - self.primary_action.show() - self.info_label.show() - self.remove_all_button.show() - def update_primary_action(self): self.common.log("WebsiteMode", "update_primary_action")