1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

Fix tab indices not aligned with stackwidget's

* The custom QStackWidget+QTabBar class did not manage the tabs properly because the indices in the stackwidget were not aligned with the ones in the tab bar.
* Properly disable exclude list action when it is the currently displayed widget.
* Merge action callbacks for triggering ignore list or exclude list to avoid repeating code and remove unused checks for tab visibility.
* Remove unused SetTabVisible() function.
This commit is contained in:
glubsy
2020-08-23 16:49:43 +02:00
parent 3382bd5e5b
commit 26d18945b1
2 changed files with 45 additions and 56 deletions

View File

@@ -279,35 +279,24 @@ class DupeGuru(QObject):
def ignoreListTriggered(self):
if self.use_tabs:
# Fetch the index in the TabWidget or the StackWidget (depends on class):
index = self.main_window.indexOfWidget(self.ignoreListDialog)
if index < 0:
# we have not instantiated and populated it in their internal list yet
index = self.main_window.addTab(
self.ignoreListDialog, "Ignore List", switch=True)
elif not self.ignoreListDialog.isVisible() and not self.main_window.isTabVisible(index):
index = self.main_window.addTab(
self.ignoreListDialog, "Ignore List", switch=True)
# self.main_window.showTab(self.ignoreListDialog)
self.main_window.setTabVisible(index, True)
self.main_window.setCurrentIndex(index)
else:
self.showTriggeredTabbedDialog(self.ignoreListDialog, "Ignore List")
else: # floating windows
self.model.ignore_list_dialog.show()
def excludeListTriggered(self):
if self.use_tabs:
index = self.main_window.indexOfWidget(self.excludeListDialog)
if index < 0:
index = self.main_window.addTab(
self.excludeListDialog, "Exclude List", switch=True)
elif not self.excludeListDialog.isVisible() and not self.main_window.isTabVisible(index):
index = self.main_window.addTab(
self.excludeListDialog, "Exclude List", switch=True)
# self.main_window.showTab(self.excludeListDialog)
self.main_window.setTabVisible(index, True)
self.main_window.setCurrentIndex(index)
else:
self.excludeListDialog.show()
self.showTriggeredTabbedDialog(self.excludeListDialog, "Exclude List")
else: # floating windows
self.model.exclude_list_dialog.show()
def showTriggeredTabbedDialog(self, dialog, desc_string):
"""Add tab for dialog, name the tab with desc_string, then show it."""
index = self.main_window.indexOfWidget(dialog)
# Create the tab if it doesn't exist already
if index < 0: # or (not dialog.isVisible() and not self.main_window.isTabVisible(index)):
index = self.main_window.addTab(dialog, desc_string, switch=True)
# Show the tab for that widget
self.main_window.setCurrentIndex(index)
def openDebugLogTriggered(self):
debugLogPath = op.join(self.model.appdata, "debug.log")