aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaptak S <saptak013@gmail.com>2022-04-30 13:20:30 +0530
committerSaptak S <saptak013@gmail.com>2022-04-30 13:20:30 +0530
commit4c0cbb877b0dcc2ddb19dd8b0a710c0c1c56bc78 (patch)
treeff38b50ad647d470646ea4ddf973d1c7f46034ac
parenta998a327af831caf9dbfa13d232bd874071a81d5 (diff)
downloadonionshare-4c0cbb877b0dcc2ddb19dd8b0a710c0c1c56bc78.tar.gz
onionshare-4c0cbb877b0dcc2ddb19dd8b0a710c0c1c56bc78.zip
Opens new tab if the only other tab is a settings tab
-rw-r--r--desktop/onionshare/tab_widget.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/desktop/onionshare/tab_widget.py b/desktop/onionshare/tab_widget.py
index c272c4e8..8ef88433 100644
--- a/desktop/onionshare/tab_widget.py
+++ b/desktop/onionshare/tab_widget.py
@@ -314,6 +314,11 @@ class TabWidget(QtWidgets.QTabWidget):
self.common.settings.set("persistent_tabs", persistent_tabs)
self.common.settings.save()
+ def has_no_onionshare_tab(self):
+ # Check if the last tab is closed, or there is only one tab
+ # which is the settings tab
+ return self.count() == 0 or (self.count() == 1 and type(list(self.tabs.values())[0]) is SettingsParentTab)
+
def close_tab(self, index):
self.common.log("TabWidget", "close_tab", f"{index}")
tab = self.widget(index)
@@ -332,8 +337,8 @@ class TabWidget(QtWidgets.QTabWidget):
self.removeTab(index)
del self.tabs[tab.tab_id]
- # If the last tab is closed, open a new one
- if self.count() == 0:
+ # If no onionshare feature tab, open a new main window tab
+ if self.has_no_onionshare_tab():
self.new_tab_clicked()
else:
@@ -352,8 +357,8 @@ class TabWidget(QtWidgets.QTabWidget):
self.removeTab(index)
del self.tabs[tab.tab_id]
- # If the last tab is closed, open a new one
- if self.count() == 0:
+ # If no onionshare feature tab, open a new main window tab
+ if self.has_no_onionshare_tab():
self.new_tab_clicked()
else:
self.common.log("TabWidget", "user does not want to close the tab")