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() self.curr_settings.save()
def open_tor_settings(self): 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): 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: if type(self.tabs.tabs[tab_id]) is AutoConnectTab:
from_autoconnect = True from_autoconnect = True
break break
self.tabs.open_tor_settings_tab(from_autoconnect) self.tabs.open_settings_tab(from_autoconnect)
def open_settings(self): def open_settings(self):
""" """

View File

@ -38,7 +38,7 @@ class SettingsParentTab(QtWidgets.QTabWidget):
tab_bar = TabBar() tab_bar = TabBar()
self.setTabBar(tab_bar) self.setTabBar(tab_bar)
settings_tab = SettingsTab(self.common, 0) settings_tab = SettingsTab(self.common, 0)
tor_settings_tab = TorSettingsTab( self.tor_settings_tab = TorSettingsTab(
self.common, self.common,
1, 1,
self.parent.are_tabs_active(), self.parent.are_tabs_active(),
@ -46,7 +46,7 @@ class SettingsParentTab(QtWidgets.QTabWidget):
from_autoconnect, from_autoconnect,
) )
self.addTab( 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")) 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")) index = self.addTab(connection_tab, strings._("gui_autoconnect_start"))
self.setCurrentIndex(index) 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") self.common.log("TabWidget", "open_settings_tab")
# See if a settings tab is already open, and if so switch to it # See if a settings tab is already open, and if so switch to it
for tab_id in self.tabs: 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])) self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
return 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.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.tabs[self.current_tab_id] = settings_tab
self.current_tab_id += 1 self.current_tab_id += 1
index = self.addTab(settings_tab, strings._("gui_settings_window_title")) index = self.addTab(settings_tab, strings._("gui_settings_window_title"))
self.setCurrentIndex(index) self.setCurrentIndex(index)
def open_tor_settings_tab(self, from_autoconnect=False): # def open_tor_settings_tab(self, from_autoconnect=False):
self.common.log("TabWidget", "open_tor_settings_tab") # self.common.log("TabWidget", "open_tor_settings_tab")
# See if a settings tab is already open, and if so switch to it # # See if a settings tab is already open, and if so switch to it
for tab_id in self.tabs: # for tab_id in self.tabs:
if type(self.tabs[tab_id]) is TorSettingsTab: # if type(self.tabs[tab_id]) is TorSettingsTab:
self.setCurrentIndex(self.indexOf(self.tabs[tab_id])) # self.setCurrentIndex(self.indexOf(self.tabs[tab_id]))
return # return
self.tor_settings_tab = TorSettingsTab( # self.tor_settings_tab = TorSettingsTab(
self.common, # self.common,
self.current_tab_id, # self.current_tab_id,
self.are_tabs_active(), # self.are_tabs_active(),
self.status_bar, # self.status_bar,
from_autoconnect, # from_autoconnect,
) # )
self.tor_settings_tab.close_this_tab.connect(self.close_tor_settings_tab) # 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_connected.connect(self.tor_is_connected)
self.tor_settings_tab.tor_is_disconnected.connect(self.tor_is_disconnected) # self.tor_settings_tab.tor_is_disconnected.connect(self.tor_is_disconnected)
self.tabs[self.current_tab_id] = self.tor_settings_tab # self.tabs[self.current_tab_id] = self.tor_settings_tab
self.current_tab_id += 1 # self.current_tab_id += 1
index = self.addTab( # index = self.addTab(
self.tor_settings_tab, strings._("gui_tor_settings_window_title") # self.tor_settings_tab, strings._("gui_tor_settings_window_title")
) # )
self.setCurrentIndex(index) # self.setCurrentIndex(index)
def change_title(self, tab_id, title): def change_title(self, tab_id, title):
shortened_title = title shortened_title = title
@ -384,15 +386,15 @@ class TabWidget(QtWidgets.QTabWidget):
self.close_tab(index) self.close_tab(index)
return return
def close_settings_tab(self): # def close_settings_tab(self):
self.common.log("TabWidget", "close_settings_tab") # self.common.log("TabWidget", "close_settings_tab")
for tab_id in self.tabs: # for tab_id in self.tabs:
if type(self.tabs[tab_id]) is SettingsTab: # if type(self.tabs[tab_id]) is SettingsTab:
index = self.indexOf(self.tabs[tab_id]) # index = self.indexOf(self.tabs[tab_id])
self.close_tab(index) # self.close_tab(index)
return # return
def close_tor_settings_tab(self): def close_settings_tab(self):
self.common.log("TabWidget", "close_tor_settings_tab") self.common.log("TabWidget", "close_tor_settings_tab")
for tab_id in list(self.tabs): for tab_id in list(self.tabs):
if type(self.tabs[tab_id]) is AutoConnectTab: if type(self.tabs[tab_id]) is AutoConnectTab: