mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
Fix menu items being wrongly disabled
* Add Directories to the View menu. * View menu items should be disabled properly depending on whether they point to the current page/tab. * Keep "Load scan results" actions active while viewing pages other than the Directories tab.
This commit is contained in:
parent
1b3b40543b
commit
86e1b55b02
12
qt/app.py
12
qt/app.py
@ -69,6 +69,7 @@ class DupeGuru(QObject):
|
||||
self.directories_dialog = self.main_window.createPage("DirectoriesDialog", app=self)
|
||||
self.main_window.addTab(
|
||||
self.directories_dialog, "Directories", switch=False)
|
||||
self.actionDirectoriesWindow.setEnabled(False)
|
||||
else: # floating windows only
|
||||
self.main_window = None
|
||||
self.directories_dialog = DirectoriesDialog(self)
|
||||
@ -121,6 +122,7 @@ class DupeGuru(QObject):
|
||||
self.preferencesTriggered,
|
||||
),
|
||||
("actionIgnoreList", "", "", tr("Ignore List"), self.ignoreListTriggered),
|
||||
("actionDirectoriesWindow", "", "", tr("Directories"), self.showDirectoriesWindow),
|
||||
(
|
||||
"actionClearPictureCache",
|
||||
"Ctrl+Shift+P",
|
||||
@ -220,6 +222,16 @@ class DupeGuru(QObject):
|
||||
else:
|
||||
self.resultWindow.show()
|
||||
|
||||
def showDirectoriesWindow(self):
|
||||
if self.directories_dialog is not None:
|
||||
if self.main_window:
|
||||
index = self.main_window.indexOfWidget(self.directories_dialog)
|
||||
# if not self.main_window.tabWidget.isTabVisible(index):
|
||||
self.main_window.setTabVisible(index, True)
|
||||
self.main_window.setCurrentIndex(index)
|
||||
else:
|
||||
self.directories_dialog.show()
|
||||
|
||||
def shutdown(self):
|
||||
self.willSavePrefs.emit()
|
||||
self.prefs.save()
|
||||
|
@ -88,17 +88,17 @@ class DirectoriesDialog(QMainWindow):
|
||||
"actionShowResultsWindow",
|
||||
"",
|
||||
"",
|
||||
tr("Results Window"),
|
||||
tr("Scan Results"),
|
||||
self.app.showResultsWindow,
|
||||
),
|
||||
("actionAddFolder", "", "", tr("Add Folder..."), self.addFolderTriggered),
|
||||
]
|
||||
createActions(ACTIONS, self)
|
||||
|
||||
if self.app.main_window: # We use tab widgets in this case
|
||||
# Keep track of actions which should only be accessible from this class
|
||||
for action, _, _, _, _ in ACTIONS:
|
||||
self.specific_actions.add(getattr(self, action))
|
||||
# if self.app.main_window: # We use tab widgets in this case
|
||||
# # Keep track of actions which should only be accessible from this class
|
||||
# for action, _, _, _, _ in ACTIONS:
|
||||
# self.specific_actions.add(getattr(self, action))
|
||||
|
||||
def _setupMenu(self):
|
||||
if not self.app.main_window:
|
||||
@ -124,7 +124,6 @@ class DirectoriesDialog(QMainWindow):
|
||||
self.menuLoadRecent.setTitle(tr("Load Recent Results"))
|
||||
self.menuFile.addAction(self.actionLoadResults)
|
||||
self.menuFile.addAction(self.menuLoadRecent.menuAction())
|
||||
self.specific_actions.add(self.menuLoadRecent.menuAction())
|
||||
self.menuFile.addSeparator()
|
||||
self.menuFile.addAction(self.app.actionClearPictureCache)
|
||||
self.menuFile.addSeparator()
|
||||
@ -132,6 +131,7 @@ class DirectoriesDialog(QMainWindow):
|
||||
self.menuView.addAction(self.app.actionPreferences)
|
||||
self.menuView.addAction(self.actionShowResultsWindow)
|
||||
self.menuView.addAction(self.app.actionIgnoreList)
|
||||
self.menuView.addAction(self.app.actionDirectoriesWindow)
|
||||
self.menuHelp.addAction(self.app.actionShowHelp)
|
||||
self.menuHelp.addAction(self.app.actionOpenDebugLog)
|
||||
self.menuHelp.addAction(self.app.actionAbout)
|
||||
|
@ -117,38 +117,33 @@ class TabWindow(QMainWindow):
|
||||
self.last_index = current_index
|
||||
self.previous_widget_actions = active_widget.specific_actions
|
||||
return
|
||||
isResultWindow = isinstance(active_widget, ResultWindow)
|
||||
isIgnoreListDialog = isinstance(active_widget, IgnoreListDialog)
|
||||
|
||||
page_type = type(active_widget).__name__
|
||||
for menu in self.menuList:
|
||||
if menu is self.menuColumns or menu is self.menuActions or menu is self.menuMark:
|
||||
if not isResultWindow:
|
||||
if not isinstance(active_widget, ResultWindow):
|
||||
menu.setEnabled(False)
|
||||
continue
|
||||
else:
|
||||
menu.setEnabled(True)
|
||||
|
||||
for action in menu.actions():
|
||||
if action is self.app.directories_dialog.actionShowResultsWindow:
|
||||
if isResultWindow:
|
||||
self.app.actionIgnoreList.setEnabled(self.app.ignoreListDialog is not None)
|
||||
# Action points to ourselves, always disable it
|
||||
self.app.directories_dialog.actionShowResultsWindow\
|
||||
.setEnabled(False)
|
||||
continue
|
||||
else:
|
||||
self.app.directories_dialog.actionShowResultsWindow\
|
||||
.setEnabled(self.app.resultWindow is not None)
|
||||
if isIgnoreListDialog:
|
||||
self.app.actionIgnoreList.setEnabled(False)
|
||||
continue
|
||||
else:
|
||||
self.app.actionIgnoreList.setEnabled(self.app.ignoreListDialog is not None)
|
||||
continue
|
||||
if action not in active_widget.specific_actions:
|
||||
if action in self.previous_widget_actions:
|
||||
action.setEnabled(False)
|
||||
# action.setEnabled(False)
|
||||
menu.removeAction(action)
|
||||
continue
|
||||
action.setEnabled(True)
|
||||
|
||||
self.app.directories_dialog.actionShowResultsWindow.setEnabled(
|
||||
False if page_type == "ResultWindow"
|
||||
else self.app.resultWindow is not None)
|
||||
self.app.actionIgnoreList.setEnabled(
|
||||
True if self.app.ignoreListDialog is not None
|
||||
and not page_type == "IgnoreListDialog" else False)
|
||||
self.app.actionDirectoriesWindow.setEnabled(
|
||||
False if page_type == "DirectoriesDialog" else True)
|
||||
|
||||
self.previous_widget_actions = active_widget.specific_actions
|
||||
self.last_index = current_index
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user