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

Use tabs instead of floating windows

* Directories dialog, Results window and ignore list dialog are the three dialog windows which can now be tabbed instead of previously floating.
* Menus are automatically updated depending on the type of dialog as the current tab. Menu items which do not apply to the currently displayed tab are disabled but not hidden.
* The floating windows logic is preserved in case we want to use them again later (I don't see why though)
* There are two different versions of the tab bar: the default one used in TabBarWindow class places the tabs next to the top menu to save screen real estate. The other option is to use TabWindow which uses a regular QTabWidget where the tab bar is placed right on top of the displayed window.
* There is a toggle option in the View menu to hide the tabs, the windows can still be navigated to with the View menu items.
This commit is contained in:
glubsy
2020-07-12 16:58:01 +02:00
parent 092cf1471b
commit a4265e7fff
6 changed files with 509 additions and 52 deletions

View File

@@ -35,6 +35,7 @@ from .se.preferences_dialog import PreferencesDialog as PreferencesDialogStandar
from .me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic
from .pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture
from .pe.photo import File as PlatSpecificPhoto
from .tabbed_window import TabBarWindow
tr = trget("ui")
@@ -47,6 +48,9 @@ class DupeGuru(QObject):
super().__init__(**kwargs)
self.prefs = Preferences()
self.prefs.load()
# Enable tabs instead of separate floating windows for each dialog
# Could be passed as an argument to this class if we wanted
self.use_tabs = True
self.model = DupeGuruModel(view=self)
self._setup()
@@ -59,22 +63,41 @@ class DupeGuru(QObject):
self.recentResults.mustOpenItem.connect(self.model.load_from)
self.resultWindow = None
self.details_dialog = None
self.directories_dialog = DirectoriesDialog(self)
if self.use_tabs:
self.main_window = TabBarWindow(self)
parent_window = self.main_window
self.directories_dialog = self.main_window.createPage("DirectoriesDialog", app=self)
self.main_window.addTab(
self.directories_dialog, "Directories", switch=False)
else: # floating windows only
self.main_window = None
self.directories_dialog = DirectoriesDialog(self)
parent_window = self.directories_dialog
self.progress_window = ProgressWindow(
self.directories_dialog, self.model.progress_window
parent_window, self.model.progress_window
)
self.problemDialog = ProblemDialog(
parent=self.directories_dialog, model=self.model.problem_dialog
parent=parent_window, model=self.model.problem_dialog
)
self.ignoreListDialog = IgnoreListDialog(
parent=self.directories_dialog, model=self.model.ignore_list_dialog
)
self.deletionOptions = DeletionOptions(
parent=self.directories_dialog, model=self.model.deletion_options
)
self.about_box = AboutBox(self.directories_dialog, self)
if self.main_window: # we use tab widget
self.ignoreListDialog = self.main_window.createPage(
"IgnoreListDialog",
parent=self.main_window,
model=self.model.ignore_list_dialog)
self.ignoreListDialog.accepted.connect(self.main_window.onDialogAccepted)
else:
self.ignoreListDialog = IgnoreListDialog(
parent=parent_window, model=self.model.ignore_list_dialog
)
self.directories_dialog.show()
self.deletionOptions = DeletionOptions(
parent=parent_window,
model=self.model.deletion_options
)
self.about_box = AboutBox(parent_window, self)
parent_window.show()
self.model.load()
self.SIGTERM.connect(self.handleSIGTERM)
@@ -191,7 +214,11 @@ class DupeGuru(QObject):
def showResultsWindow(self):
if self.resultWindow is not None:
self.resultWindow.show()
if self.main_window:
self.main_window.addTab(
self.resultWindow, "Results", switch=True)
else:
self.resultWindow.show()
def shutdown(self):
self.willSavePrefs.emit()
@@ -212,7 +239,9 @@ class DupeGuru(QObject):
"scanning have accented letters, you'll probably get a crash. It is advised that "
"you set your system locale properly."
)
QMessageBox.warning(self.directories_dialog, "Wrong Locale", msg)
QMessageBox.warning(self.main_window if self.main_window
else self.directories_dialog,
"Wrong Locale", msg)
def clearPictureCacheTriggered(self):
title = tr("Clear Picture Cache")
@@ -223,7 +252,19 @@ class DupeGuru(QObject):
QMessageBox.information(active, title, tr("Picture cache cleared."))
def ignoreListTriggered(self):
self.model.ignore_list_dialog.show()
if self.main_window:
# 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)
# if not self.main_window.tabWidget.isTabVisible(index):
self.main_window.setTabVisible(index, True)
self.main_window.setCurrentIndex(index)
return
else:
self.model.ignore_list_dialog.show()
def openDebugLogTriggered(self):
debugLogPath = op.join(self.model.appdata, "debug.log")
@@ -231,7 +272,8 @@ class DupeGuru(QObject):
def preferencesTriggered(self):
preferences_dialog = self._get_preferences_dialog_class()(
self.directories_dialog, self
self.main_window if self.main_window else self.directories_dialog,
self
)
preferences_dialog.load()
result = preferences_dialog.exec()
@@ -242,7 +284,10 @@ class DupeGuru(QObject):
preferences_dialog.setParent(None)
def quitTriggered(self):
self.directories_dialog.close()
if self.main_window:
self.main_window.close()
else:
self.directories_dialog.close()
def showAboutBoxTriggered(self):
self.about_box.show()
@@ -282,7 +327,12 @@ class DupeGuru(QObject):
if self.resultWindow is not None:
self.resultWindow.close()
self.resultWindow.setParent(None)
self.resultWindow = ResultWindow(self.directories_dialog, self)
if self.main_window:
self.resultWindow = self.main_window.createPage(
"ResultWindow", parent=self.main_window, app=self)
else: # We don't use a tab widget, regular floating QMainWindow
self.resultWindow = ResultWindow(self.directories_dialog, self)
self.directories_dialog._updateActionsState()
self.details_dialog = self._get_details_dialog_class()(self.resultWindow, self)
def show_results_window(self):