mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-24 23:09:42 -05:00
Moving tor settings and app settings as subtabs under a parent settings tab
This commit is contained in:
parent
e168080b77
commit
2d7e980ade
@ -253,7 +253,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
Open the SettingsTab
|
Open the SettingsTab
|
||||||
"""
|
"""
|
||||||
self.common.log("MainWindow", "open_settings")
|
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):
|
def settings_have_changed(self):
|
||||||
self.common.log("OnionShareGui", "settings_have_changed")
|
self.common.log("OnionShareGui", "settings_have_changed")
|
||||||
|
72
desktop/onionshare/settings_parent_tab.py
Normal file
72
desktop/onionshare/settings_parent_tab.py
Normal file
@ -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__()
|
@ -28,6 +28,7 @@ from .threads import EventHandlerThread
|
|||||||
from .gui_common import GuiCommon
|
from .gui_common import GuiCommon
|
||||||
from .tor_settings_tab import TorSettingsTab
|
from .tor_settings_tab import TorSettingsTab
|
||||||
from .settings_tab import SettingsTab
|
from .settings_tab import SettingsTab
|
||||||
|
from .settings_parent_tab import SettingsParentTab
|
||||||
from .connection_tab import AutoConnectTab
|
from .connection_tab import AutoConnectTab
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
for tab_id in self.tabs:
|
for tab_id in self.tabs:
|
||||||
if not (
|
if not (
|
||||||
type(self.tabs[tab_id]) is SettingsTab
|
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 TorSettingsTab
|
||||||
or type(self.tabs[tab_id]) is AutoConnectTab
|
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 it's Settings or Tor Settings, ignore
|
||||||
if (
|
if (
|
||||||
type(self.tabs[tab_id]) is SettingsTab
|
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 TorSettingsTab
|
||||||
or type(self.tabs[tab_id]) is AutoConnectTab
|
or type(self.tabs[tab_id]) is AutoConnectTab
|
||||||
):
|
):
|
||||||
@ -238,7 +241,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
|
self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
|
||||||
return
|
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)
|
settings_tab.close_this_tab.connect(self.close_settings_tab)
|
||||||
self.tabs[self.current_tab_id] = settings_tab
|
self.tabs[self.current_tab_id] = settings_tab
|
||||||
self.current_tab_id += 1
|
self.current_tab_id += 1
|
||||||
@ -315,6 +318,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
for tab_id in self.tabs:
|
for tab_id in self.tabs:
|
||||||
if not (
|
if not (
|
||||||
type(self.tabs[tab_id]) is SettingsTab
|
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 TorSettingsTab
|
||||||
or type(self.tabs[tab_id]) is AutoConnectTab
|
or type(self.tabs[tab_id]) is AutoConnectTab
|
||||||
):
|
):
|
||||||
@ -333,6 +337,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
type(self.tabs[tab_id]) is SettingsTab
|
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 TorSettingsTab
|
||||||
or type(self.tabs[tab_id]) is AutoConnectTab
|
or type(self.tabs[tab_id]) is AutoConnectTab
|
||||||
):
|
):
|
||||||
@ -425,6 +430,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
for tab_id in self.tabs:
|
for tab_id in self.tabs:
|
||||||
if not (
|
if not (
|
||||||
type(self.tabs[tab_id]) is SettingsTab
|
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 TorSettingsTab
|
||||||
or type(self.tabs[tab_id]) is AutoConnectTab
|
or type(self.tabs[tab_id]) is AutoConnectTab
|
||||||
):
|
):
|
||||||
|
Loading…
Reference in New Issue
Block a user