Fix adding new Result tab if already existed

* Whenever the Result Window already existed and its tab was in second position, and if the ignore list tab was in 3rd position, asking to show the Result window through the View menu would add a new tab and push the Result tab to the third position (ignore list tab would then become 2nd position).
* Fix view menu Directories entry not switching to index "0" in custom tab bar.
This commit is contained in:
glubsy 2020-08-02 16:12:47 +02:00
parent 866bf996cf
commit 76fbfc2822
2 changed files with 10 additions and 6 deletions

View File

@ -223,17 +223,14 @@ class DupeGuru(QObject):
def showResultsWindow(self):
if self.resultWindow is not None:
if self.use_tabs:
self.main_window.addTab(
self.resultWindow, "Results", switch=True)
self.main_window.showTab(self.resultWindow)
else:
self.resultWindow.show()
def showDirectoriesWindow(self):
if self.directories_dialog is not None:
if self.use_tabs:
index = self.main_window.indexOfWidget(self.directories_dialog)
self.main_window.setTabVisible(index, True)
self.main_window.setCurrentIndex(index)
self.main_window.showTab(self.directories_dialog)
else:
self.directories_dialog.show()
@ -354,6 +351,8 @@ class DupeGuru(QObject):
if self.use_tabs:
self.resultWindow = self.main_window.createPage(
"ResultWindow", parent=self.main_window, app=self)
self.main_window.addTab(
self.resultWindow, "Results", switch=False)
else: # We don't use a tab widget, regular floating QMainWindow
self.resultWindow = ResultWindow(self.directories_dialog, self)
self.directories_dialog._updateActionsState()

View File

@ -171,6 +171,11 @@ class TabWindow(QMainWindow):
self.setCurrentIndex(index)
return index
def showTab(self, page):
index = self.indexOfWidget(page)
self.setTabVisible(index, True)
self.setCurrentIndex(index)
def indexOfWidget(self, widget):
return self.tabWidget.indexOf(widget)
@ -302,7 +307,7 @@ class TabBarWindow(TabWindow):
@pyqtSlot(int)
def setTabIndex(self, index):
if not index:
if index is None:
return
self.tabBar.setCurrentIndex(index)