mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-26 11:13:00 -03:00
Merge pull request #1581 from SaptakS/new-tab-fix
Opens new tab if the only other tab is a settings tab
This commit is contained in:
commit
c267d27eaa
1 changed files with 9 additions and 4 deletions
|
@ -314,6 +314,11 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||||
self.common.settings.set("persistent_tabs", persistent_tabs)
|
self.common.settings.set("persistent_tabs", persistent_tabs)
|
||||||
self.common.settings.save()
|
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):
|
def close_tab(self, index):
|
||||||
self.common.log("TabWidget", "close_tab", f"{index}")
|
self.common.log("TabWidget", "close_tab", f"{index}")
|
||||||
tab = self.widget(index)
|
tab = self.widget(index)
|
||||||
|
@ -332,8 +337,8 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||||
self.removeTab(index)
|
self.removeTab(index)
|
||||||
del self.tabs[tab.tab_id]
|
del self.tabs[tab.tab_id]
|
||||||
|
|
||||||
# If the last tab is closed, open a new one
|
# If no onionshare feature tab, open a new main window tab
|
||||||
if self.count() == 0:
|
if self.has_no_onionshare_tab():
|
||||||
self.new_tab_clicked()
|
self.new_tab_clicked()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -352,8 +357,8 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||||
self.removeTab(index)
|
self.removeTab(index)
|
||||||
del self.tabs[tab.tab_id]
|
del self.tabs[tab.tab_id]
|
||||||
|
|
||||||
# If the last tab is closed, open a new one
|
# If no onionshare feature tab, open a new main window tab
|
||||||
if self.count() == 0:
|
if self.has_no_onionshare_tab():
|
||||||
self.new_tab_clicked()
|
self.new_tab_clicked()
|
||||||
else:
|
else:
|
||||||
self.common.log("TabWidget", "user does not want to close the tab")
|
self.common.log("TabWidget", "user does not want to close the tab")
|
||||||
|
|
Loading…
Add table
Reference in a new issue