aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaptak S <saptak013@gmail.com>2022-02-24 18:04:26 +0530
committerSaptak S <saptak013@gmail.com>2022-02-24 18:04:26 +0530
commit2d7e980adece27cd54536f87e9ee7b03df9b701b (patch)
tree131f47d5c99975b212eb141a38d831123b0496ed
parente168080b77c1ec7ba40022a106a43d524e227945 (diff)
downloadonionshare-2d7e980adece27cd54536f87e9ee7b03df9b701b.tar.gz
onionshare-2d7e980adece27cd54536f87e9ee7b03df9b701b.zip
Moving tor settings and app settings as subtabs under a parent settings tab
-rw-r--r--desktop/onionshare/main_window.py7
-rw-r--r--desktop/onionshare/settings_parent_tab.py72
-rw-r--r--desktop/onionshare/tab_widget.py8
3 files changed, 85 insertions, 2 deletions
diff --git a/desktop/onionshare/main_window.py b/desktop/onionshare/main_window.py
index 9c6f455f..61119683 100644
--- a/desktop/onionshare/main_window.py
+++ b/desktop/onionshare/main_window.py
@@ -253,7 +253,12 @@ class MainWindow(QtWidgets.QMainWindow):
Open the SettingsTab
"""
self.common.log("MainWindow", "open_settings")
- self.tabs.open_settings_tab()
+ from_autoconnect = False
+ for tab_id in self.tabs.tabs:
+ if type(self.tabs.tabs[tab_id]) is AutoConnectTab:
+ from_autoconnect = True
+ break
+ self.tabs.open_settings_tab(from_autoconnect)
def settings_have_changed(self):
self.common.log("OnionShareGui", "settings_have_changed")
diff --git a/desktop/onionshare/settings_parent_tab.py b/desktop/onionshare/settings_parent_tab.py
new file mode 100644
index 00000000..2e372983
--- /dev/null
+++ b/desktop/onionshare/settings_parent_tab.py
@@ -0,0 +1,72 @@
+from PySide2 import QtCore, QtWidgets, QtGui
+
+from onionshare_cli.mode_settings import ModeSettings
+
+from . import strings
+from .tab import Tab
+from .threads import EventHandlerThread
+from .gui_common import GuiCommon
+from .tor_settings_tab import TorSettingsTab
+from .settings_tab import SettingsTab
+from .connection_tab import AutoConnectTab
+
+
+class SettingsParentTab(QtWidgets.QTabWidget):
+ """
+ The settings tab widget containing the tor settings
+ and app settings subtabs
+ """
+
+ bring_to_front = QtCore.Signal()
+ close_this_tab = QtCore.Signal()
+
+ def __init__(self, common, tab_id, parent=None, active_tab='tor', from_autoconnect=False):
+ super(SettingsParentTab, self).__init__()
+ self.parent = parent
+ self.common = common
+ self.common.log("SettingsParentTab", "__init__")
+
+ # Keep track of tabs in a dictionary that maps tab_id to tab.
+ # Each tab has a unique, auto-incremented id (tab_id). This is different than the
+ # tab's index, which changes as tabs are re-arranged.
+ # self.tabs = {}
+ self.tab_id = tab_id
+ # self.current_tab_id = 0 # Each tab has a unique id
+ # self.tor_settings_tab = None
+
+ # Use a custom tab bar
+ tab_bar = TabBar()
+ self.setTabBar(tab_bar)
+ settings_tab = SettingsTab(self.common, 0)
+ tor_settings_tab = TorSettingsTab(
+ self.common,
+ 1,
+ self.parent.are_tabs_active(),
+ self.parent.status_bar,
+ from_autoconnect,
+ )
+ self.addTab(
+ tor_settings_tab, strings._("gui_tor_settings_window_title")
+ )
+ self.addTab(settings_tab, strings._("gui_settings_window_title"))
+
+ # Set up the tab widget
+ self.setMovable(False)
+ self.setTabsClosable(False)
+ self.setUsesScrollButtons(False)
+ # self.setDocumentMode(True)
+ # self.setStyleSheet(self.common.gui.css["tab_widget"])
+
+ # self.tabCloseRequested.connect(self.close_tab)
+
+ # self.move_new_tab_button()
+
+class TabBar(QtWidgets.QTabBar):
+ """
+ A custom tab bar
+ """
+
+ move_new_tab_button = QtCore.Signal()
+
+ def __init__(self):
+ super(TabBar, self).__init__()
diff --git a/desktop/onionshare/tab_widget.py b/desktop/onionshare/tab_widget.py
index 29f443ac..05285a61 100644
--- a/desktop/onionshare/tab_widget.py
+++ b/desktop/onionshare/tab_widget.py
@@ -28,6 +28,7 @@ from .threads import EventHandlerThread
from .gui_common import GuiCommon
from .tor_settings_tab import TorSettingsTab
from .settings_tab import SettingsTab
+from .settings_parent_tab import SettingsParentTab
from .connection_tab import AutoConnectTab
@@ -98,6 +99,7 @@ class TabWidget(QtWidgets.QTabWidget):
for tab_id in self.tabs:
if not (
type(self.tabs[tab_id]) is SettingsTab
+ or type(self.tabs[tab_id]) is SettingsParentTab
or type(self.tabs[tab_id]) is TorSettingsTab
or type(self.tabs[tab_id]) is AutoConnectTab
):
@@ -139,6 +141,7 @@ class TabWidget(QtWidgets.QTabWidget):
# If it's Settings or Tor Settings, ignore
if (
type(self.tabs[tab_id]) is SettingsTab
+ or type(self.tabs[tab_id]) is SettingsParentTab
or type(self.tabs[tab_id]) is TorSettingsTab
or type(self.tabs[tab_id]) is AutoConnectTab
):
@@ -238,7 +241,7 @@ class TabWidget(QtWidgets.QTabWidget):
self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
return
- settings_tab = SettingsTab(self.common, self.current_tab_id)
+ settings_tab = SettingsParentTab(self.common, self.current_tab_id, parent=self)
settings_tab.close_this_tab.connect(self.close_settings_tab)
self.tabs[self.current_tab_id] = settings_tab
self.current_tab_id += 1
@@ -315,6 +318,7 @@ class TabWidget(QtWidgets.QTabWidget):
for tab_id in self.tabs:
if not (
type(self.tabs[tab_id]) is SettingsTab
+ or type(self.tabs[tab_id]) is SettingsParentTab
or type(self.tabs[tab_id]) is TorSettingsTab
or type(self.tabs[tab_id]) is AutoConnectTab
):
@@ -333,6 +337,7 @@ class TabWidget(QtWidgets.QTabWidget):
if (
type(self.tabs[tab_id]) is SettingsTab
+ or type(self.tabs[tab_id]) is SettingsParentTab
or type(self.tabs[tab_id]) is TorSettingsTab
or type(self.tabs[tab_id]) is AutoConnectTab
):
@@ -425,6 +430,7 @@ class TabWidget(QtWidgets.QTabWidget):
for tab_id in self.tabs:
if not (
type(self.tabs[tab_id]) is SettingsTab
+ or type(self.tabs[tab_id]) is SettingsParentTab
or type(self.tabs[tab_id]) is TorSettingsTab
or type(self.tabs[tab_id]) is AutoConnectTab
):