diff options
author | Micah Lee <micah@micahflee.com> | 2020-06-29 12:41:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 12:41:34 -0700 |
commit | 8395fef88708e22b86a81cb1789f4247eb7efcd8 (patch) | |
tree | b267eddd3e5566ddd847341bf78a1562ac945489 /onionshare_gui | |
parent | 423953b3c19d1077a30d33416c99c9c843138359 (diff) | |
parent | 39f20874f239b4f57ccf46c320cbcf8a97684eb5 (diff) | |
download | onionshare-8395fef88708e22b86a81cb1789f4247eb7efcd8.tar.gz onionshare-8395fef88708e22b86a81cb1789f4247eb7efcd8.zip |
Merge pull request #1132 from mig5/update_status_bar_on_tab_change
#1126 update the status bar each time the active tab is changed
Diffstat (limited to 'onionshare_gui')
-rw-r--r-- | onionshare_gui/tab_widget.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/onionshare_gui/tab_widget.py b/onionshare_gui/tab_widget.py index d69931c0..df4072f3 100644 --- a/onionshare_gui/tab_widget.py +++ b/onionshare_gui/tab_widget.py @@ -60,6 +60,7 @@ class TabWidget(QtWidgets.QTabWidget): # Use a custom tab bar tab_bar = TabBar() tab_bar.move_new_tab_button.connect(self.move_new_tab_button) + tab_bar.currentChanged.connect(self.tab_changed) self.setTabBar(tab_bar) # Set up the tab widget @@ -108,6 +109,24 @@ class TabWidget(QtWidgets.QTabWidget): self.new_tab_button.move(pos) self.new_tab_button.raise_() + def tab_changed(self): + # Active tab was changed + tab_id = self.currentIndex() + self.common.log("TabWidget", "tab_changed", f"Tab was changed to {tab_id}") + try: + mode = self.tabs[tab_id].get_mode() + if mode: + # Update the server status indicator to reflect that of the current tab + self.tabs[tab_id].update_server_status_indicator() + else: + # If this tab doesn't have a mode set yet, blank the server status indicator + self.status_bar.server_status_image_label.clear() + self.status_bar.server_status_label.clear() + except KeyError: + # When all current tabs are closed, index briefly drops to -1 before resetting to 0 + # which will otherwise trigger a KeyError on tab.get_mode() above. + pass + def new_tab_clicked(self): # Create a new tab self.add_tab() |