Fix the settings tab calls

This commit is contained in:
Saptak S 2022-02-24 18:14:06 +05:30
parent 2d7e980ade
commit fdc7ba9228
No known key found for this signature in database
GPG Key ID: 7B7F1772C0C6FCBF
4 changed files with 40 additions and 38 deletions

View File

@ -149,7 +149,7 @@ class AutoConnectTab(QtWidgets.QWidget):
self.curr_settings.save()
def open_tor_settings(self):
self.parent.open_tor_settings_tab(from_autoconnect=True)
self.parent.open_settings_tab(from_autoconnect=True)
def first_launch_widget_connect_clicked(self):
"""

View File

@ -246,7 +246,7 @@ class MainWindow(QtWidgets.QMainWindow):
if type(self.tabs.tabs[tab_id]) is AutoConnectTab:
from_autoconnect = True
break
self.tabs.open_tor_settings_tab(from_autoconnect)
self.tabs.open_settings_tab(from_autoconnect)
def open_settings(self):
"""

View File

@ -38,7 +38,7 @@ class SettingsParentTab(QtWidgets.QTabWidget):
tab_bar = TabBar()
self.setTabBar(tab_bar)
settings_tab = SettingsTab(self.common, 0)
tor_settings_tab = TorSettingsTab(
self.tor_settings_tab = TorSettingsTab(
self.common,
1,
self.parent.are_tabs_active(),
@ -46,7 +46,7 @@ class SettingsParentTab(QtWidgets.QTabWidget):
from_autoconnect,
)
self.addTab(
tor_settings_tab, strings._("gui_tor_settings_window_title")
self.tor_settings_tab, strings._("gui_tor_settings_window_title")
)
self.addTab(settings_tab, strings._("gui_settings_window_title"))

View File

@ -232,47 +232,49 @@ class TabWidget(QtWidgets.QTabWidget):
index = self.addTab(connection_tab, strings._("gui_autoconnect_start"))
self.setCurrentIndex(index)
def open_settings_tab(self):
def open_settings_tab(self, from_autoconnect=False, active_tab='tor'):
self.common.log("TabWidget", "open_settings_tab")
# See if a settings tab is already open, and if so switch to it
for tab_id in self.tabs:
if type(self.tabs[tab_id]) is SettingsTab:
if type(self.tabs[tab_id]) is SettingsParentTab:
self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
return
settings_tab = SettingsParentTab(self.common, self.current_tab_id, parent=self)
settings_tab = SettingsParentTab(self.common, self.current_tab_id,active_tab=active_tab, parent=self, from_autoconnect=from_autoconnect)
settings_tab.close_this_tab.connect(self.close_settings_tab)
settings_tab.tor_settings_tab.tor_is_connected.connect(self.tor_is_connected)
settings_tab.tor_settings_tab.tor_is_disconnected.connect(self.tor_is_disconnected)
self.tabs[self.current_tab_id] = settings_tab
self.current_tab_id += 1
index = self.addTab(settings_tab, strings._("gui_settings_window_title"))
self.setCurrentIndex(index)
def open_tor_settings_tab(self, from_autoconnect=False):
self.common.log("TabWidget", "open_tor_settings_tab")
# def open_tor_settings_tab(self, from_autoconnect=False):
# self.common.log("TabWidget", "open_tor_settings_tab")
# See if a settings tab is already open, and if so switch to it
for tab_id in self.tabs:
if type(self.tabs[tab_id]) is TorSettingsTab:
self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
return
# # See if a settings tab is already open, and if so switch to it
# for tab_id in self.tabs:
# if type(self.tabs[tab_id]) is TorSettingsTab:
# self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
# return
self.tor_settings_tab = TorSettingsTab(
self.common,
self.current_tab_id,
self.are_tabs_active(),
self.status_bar,
from_autoconnect,
)
self.tor_settings_tab.close_this_tab.connect(self.close_tor_settings_tab)
self.tor_settings_tab.tor_is_connected.connect(self.tor_is_connected)
self.tor_settings_tab.tor_is_disconnected.connect(self.tor_is_disconnected)
self.tabs[self.current_tab_id] = self.tor_settings_tab
self.current_tab_id += 1
index = self.addTab(
self.tor_settings_tab, strings._("gui_tor_settings_window_title")
)
self.setCurrentIndex(index)
# self.tor_settings_tab = TorSettingsTab(
# self.common,
# self.current_tab_id,
# self.are_tabs_active(),
# self.status_bar,
# from_autoconnect,
# )
# self.tor_settings_tab.close_this_tab.connect(self.close_tor_settings_tab)
# self.tor_settings_tab.tor_is_connected.connect(self.tor_is_connected)
# self.tor_settings_tab.tor_is_disconnected.connect(self.tor_is_disconnected)
# self.tabs[self.current_tab_id] = self.tor_settings_tab
# self.current_tab_id += 1
# index = self.addTab(
# self.tor_settings_tab, strings._("gui_tor_settings_window_title")
# )
# self.setCurrentIndex(index)
def change_title(self, tab_id, title):
shortened_title = title
@ -384,15 +386,15 @@ class TabWidget(QtWidgets.QTabWidget):
self.close_tab(index)
return
def close_settings_tab(self):
self.common.log("TabWidget", "close_settings_tab")
for tab_id in self.tabs:
if type(self.tabs[tab_id]) is SettingsTab:
index = self.indexOf(self.tabs[tab_id])
self.close_tab(index)
return
# def close_settings_tab(self):
# self.common.log("TabWidget", "close_settings_tab")
# for tab_id in self.tabs:
# if type(self.tabs[tab_id]) is SettingsTab:
# index = self.indexOf(self.tabs[tab_id])
# self.close_tab(index)
# return
def close_tor_settings_tab(self):
def close_settings_tab(self):
self.common.log("TabWidget", "close_tor_settings_tab")
for tab_id in list(self.tabs):
if type(self.tabs[tab_id]) is AutoConnectTab: