dupeguru/qt/app.py

397 lines
16 KiB
Python
Raw Normal View History

2016-05-31 20:22:50 -05:00
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
import sys
import os.path as op
Squashed commit of the following: commit ac941037ff51158b64daa65c244df26346af10cf Author: glubsy <glubsy@users.noreply.github.com> Date: Thu Jul 16 22:21:24 2020 +0200 Fix resize of top frame not updating scaled pixmap * Also limit viewing features such as zoom levels when files have different dimensions * GraphicsViewImageViewer is still a bit buggy: the scrollbars are toggled on when the pixmap is null in the reference viewer (we do not use that class right anyway) commit 733b3b0ed4fbd6de908c968402af03879df3336f Author: glubsy <glubsy@users.noreply.github.com> Date: Thu Jul 16 01:31:24 2020 +0200 Prevent zoom for images of differing dimensions * If images are not the same size, prevent zooming features from being used by disabling the normal size button, only enable swap commit 9168d72f38faaf0a12230cd544f14190cd29fca4 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 22:47:32 2020 +0200 Update preferences on show(), not in constructor * If the dialog window shouldn't have a titlebar during construction, update accordingly only when showing to fix Windows displaying a window without titlebar on first show * Only save geometry if the window is floating. Otherwise geometry while docked is saved whih gives weird results on subsequent starts, since it may be floating by default anyway (at least on Linux where titlebar being disabled is allowed while floating) * Vertical title bar doesn't seem to work on Windows, add note in preferences dialog commit 75621cc816120597f493e0debc6d88e2e0bbd30a Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 22:04:19 2020 +0200 Prevent Windows from floating if no decoration * Windows users cannot move a window which has no native decorations. Toggling a dock widget's titlebar off also removes native decorations on a floating window. Until we implement a replacement titlebar by overriding paintEvents, simply force the floating window to go back to docked state after we toggled the titlebar off. commit 3c816b2f11ddc66a78cdc6327ee102df46d1a552 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 21:43:01 2020 +0200 Fix computing and setting offset to 0 for tableview commit 85d6e05cd406b999e8f6ae421a9746a0c9f146bb Merge: 66127d02 3eddeb6a Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 21:25:44 2020 +0200 Merge branch 'dockable_windows' into details_dialog_improvements_dev commit 66127d025e9a497ee13126f955166946acdb35a8 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 20:22:13 2020 +0200 Add credit for icons used, upscale exchange icon * Jason Cho gave his express permission to use the icon (it was made 10 years ago and he doesn't have the source files anymore) * Used waifu2x to upscale the icon * Used GIMP to draw dark outline around the icon * Source files are included commit 58c675d1fa90a7247233d9887a460cf5a8e4cbf5 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 05:25:47 2020 +0200 Add custom icons * Use custom icons on platforms which do not provide theme * Old zoom icons credits to "schollidesign" from icon pack Office and Entertainment (GPL licence). * Exchange icon credit to Jason Cho (Unknown license). * Use hack to resize viewers on first show() as well commit 95b8406c7b97aab170d127b466ff506b724def3c Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 04:14:24 2020 +0200 Fix scrollbar displayed while splitter maxed out * For some reason the table's height is a few pixel longer on Windows so we work around the issue by adding a small offset to the maximum height hint. * No idea about MacOS yet but this might need the same treatment. commit 3eddeb6aebc99126e62eb05af60333ba3bd22e82 Author: glubsy <glubsy@users.noreply.github.com> Date: Tue Jul 14 17:37:48 2020 +0200 Fix ME/SE details dialogs, add preferences * Fix ME and SE versions of details dialog not displaying their content properly after change to QDockWidget * Add option to toggle titlebar and orientation of titlebar in preferences dialog * Fix setting layout on PE details dialog window while layout already set, by removing the self (parent) reference in constructing the QSplitter commit 56912a71084415eac2f447650279d833d9857686 Author: glubsy <glubsy@users.noreply.github.com> Date: Mon Jul 13 05:06:04 2020 +0200 Make details dialog dockable
2020-07-16 15:31:54 -05:00
from PyQt5.QtCore import QTimer, QObject, QUrl, pyqtSignal, Qt
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QMessageBox
from hscommon.trans import trget
from hscommon import desktop
from qtlib.about_box import AboutBox
from qtlib.recent import Recent
from qtlib.util import createActions
from qtlib.progress_window import ProgressWindow
2016-05-31 20:43:24 -05:00
from core.app import AppMode, DupeGuru as DupeGuruModel
import core.pe.photo
from . import platform
2016-05-31 20:22:50 -05:00
from .preferences import Preferences
from .result_window import ResultWindow
from .directories_dialog import DirectoriesDialog
from .problem_dialog import ProblemDialog
2012-03-14 11:47:21 -05:00
from .ignore_list_dialog import IgnoreListDialog
from .exclude_list_dialog import ExcludeListDialog
from .deletion_options import DeletionOptions
from .se.details_dialog import DetailsDialog as DetailsDialogStandard
from .me.details_dialog import DetailsDialog as DetailsDialogMusic
from .pe.details_dialog import DetailsDialog as DetailsDialogPicture
from .se.preferences_dialog import PreferencesDialog as PreferencesDialogStandard
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, TabWindow
tr = trget("ui")
class DupeGuru(QObject):
LOGO_NAME = "logo_se"
NAME = "dupeGuru"
def __init__(self, **kwargs):
super().__init__(**kwargs)
2016-05-31 20:22:50 -05:00
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
2016-05-31 20:22:50 -05:00
self.model = DupeGuruModel(view=self)
self._setup()
# --- Private
def _setup(self):
core.pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto
self._setupActions()
Squashed commit of the following: commit ac941037ff51158b64daa65c244df26346af10cf Author: glubsy <glubsy@users.noreply.github.com> Date: Thu Jul 16 22:21:24 2020 +0200 Fix resize of top frame not updating scaled pixmap * Also limit viewing features such as zoom levels when files have different dimensions * GraphicsViewImageViewer is still a bit buggy: the scrollbars are toggled on when the pixmap is null in the reference viewer (we do not use that class right anyway) commit 733b3b0ed4fbd6de908c968402af03879df3336f Author: glubsy <glubsy@users.noreply.github.com> Date: Thu Jul 16 01:31:24 2020 +0200 Prevent zoom for images of differing dimensions * If images are not the same size, prevent zooming features from being used by disabling the normal size button, only enable swap commit 9168d72f38faaf0a12230cd544f14190cd29fca4 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 22:47:32 2020 +0200 Update preferences on show(), not in constructor * If the dialog window shouldn't have a titlebar during construction, update accordingly only when showing to fix Windows displaying a window without titlebar on first show * Only save geometry if the window is floating. Otherwise geometry while docked is saved whih gives weird results on subsequent starts, since it may be floating by default anyway (at least on Linux where titlebar being disabled is allowed while floating) * Vertical title bar doesn't seem to work on Windows, add note in preferences dialog commit 75621cc816120597f493e0debc6d88e2e0bbd30a Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 22:04:19 2020 +0200 Prevent Windows from floating if no decoration * Windows users cannot move a window which has no native decorations. Toggling a dock widget's titlebar off also removes native decorations on a floating window. Until we implement a replacement titlebar by overriding paintEvents, simply force the floating window to go back to docked state after we toggled the titlebar off. commit 3c816b2f11ddc66a78cdc6327ee102df46d1a552 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 21:43:01 2020 +0200 Fix computing and setting offset to 0 for tableview commit 85d6e05cd406b999e8f6ae421a9746a0c9f146bb Merge: 66127d02 3eddeb6a Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 21:25:44 2020 +0200 Merge branch 'dockable_windows' into details_dialog_improvements_dev commit 66127d025e9a497ee13126f955166946acdb35a8 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 20:22:13 2020 +0200 Add credit for icons used, upscale exchange icon * Jason Cho gave his express permission to use the icon (it was made 10 years ago and he doesn't have the source files anymore) * Used waifu2x to upscale the icon * Used GIMP to draw dark outline around the icon * Source files are included commit 58c675d1fa90a7247233d9887a460cf5a8e4cbf5 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 05:25:47 2020 +0200 Add custom icons * Use custom icons on platforms which do not provide theme * Old zoom icons credits to "schollidesign" from icon pack Office and Entertainment (GPL licence). * Exchange icon credit to Jason Cho (Unknown license). * Use hack to resize viewers on first show() as well commit 95b8406c7b97aab170d127b466ff506b724def3c Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 04:14:24 2020 +0200 Fix scrollbar displayed while splitter maxed out * For some reason the table's height is a few pixel longer on Windows so we work around the issue by adding a small offset to the maximum height hint. * No idea about MacOS yet but this might need the same treatment. commit 3eddeb6aebc99126e62eb05af60333ba3bd22e82 Author: glubsy <glubsy@users.noreply.github.com> Date: Tue Jul 14 17:37:48 2020 +0200 Fix ME/SE details dialogs, add preferences * Fix ME and SE versions of details dialog not displaying their content properly after change to QDockWidget * Add option to toggle titlebar and orientation of titlebar in preferences dialog * Fix setting layout on PE details dialog window while layout already set, by removing the self (parent) reference in constructing the QSplitter commit 56912a71084415eac2f447650279d833d9857686 Author: glubsy <glubsy@users.noreply.github.com> Date: Mon Jul 13 05:06:04 2020 +0200 Make details dialog dockable
2020-07-16 15:31:54 -05:00
self.details_dialog = None
self._update_options()
self.recentResults = Recent(self, "recentResults")
self.recentResults.mustOpenItem.connect(self.model.load_from)
self.resultWindow = None
if self.use_tabs:
self.main_window = TabBarWindow(self) if not self.prefs.tabs_default_pos else TabWindow(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)
self.actionDirectoriesWindow.setEnabled(False)
else: # floating windows only
self.main_window = None
self.directories_dialog = DirectoriesDialog(self)
parent_window = self.directories_dialog
self.progress_window = ProgressWindow(
parent_window, self.model.progress_window
)
self.problemDialog = ProblemDialog(
parent=parent_window, model=self.model.problem_dialog
)
2020-07-31 15:27:18 -05:00
if self.use_tabs:
self.ignoreListDialog = self.main_window.createPage(
"IgnoreListDialog",
parent=self.main_window,
model=self.model.ignore_list_dialog)
self.excludeListDialog = self.main_window.createPage(
"ExcludeListDialog",
app=self,
parent=self.main_window,
model=self.model.exclude_list_dialog)
else:
self.ignoreListDialog = IgnoreListDialog(
parent=parent_window, model=self.model.ignore_list_dialog)
self.excludeDialog = ExcludeListDialog(
app=self, parent=parent_window, model=self.model.exclude_list_dialog)
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)
# The timer scheme is because if the nag is not shown before the application is
# completely initialized, the nag will be shown before the app shows up in the task bar
# In some circumstances, the nag is hidden by other window, which may make the user think
# that the application haven't launched.
QTimer.singleShot(0, self.finishedLaunching)
def _setupActions(self):
# Setup actions that are common to both the directory dialog and the results window.
# (name, shortcut, icon, desc, func)
ACTIONS = [
("actionQuit", "Ctrl+Q", "", tr("Quit"), self.quitTriggered),
(
"actionPreferences",
"Ctrl+P",
"",
tr("Options"),
self.preferencesTriggered,
),
("actionIgnoreList", "", "", tr("Ignore List"), self.ignoreListTriggered),
("actionDirectoriesWindow", "", "", tr("Directories"), self.showDirectoriesWindow),
(
"actionClearPictureCache",
"Ctrl+Shift+P",
"",
tr("Clear Picture Cache"),
self.clearPictureCacheTriggered,
),
("actionExcludeList", "", "", tr("Exclusion Filters"), self.excludeListTriggered),
("actionShowHelp", "F1", "", tr("dupeGuru Help"), self.showHelpTriggered),
("actionAbout", "", "", tr("About dupeGuru"), self.showAboutBoxTriggered),
(
"actionOpenDebugLog",
"",
"",
tr("Open Debug Log"),
self.openDebugLogTriggered,
),
]
createActions(ACTIONS, self)
def _update_options(self):
self.model.options["mix_file_kind"] = self.prefs.mix_file_kind
self.model.options["escape_filter_regexp"] = not self.prefs.use_regexp
self.model.options["clean_empty_dirs"] = self.prefs.remove_empty_folders
self.model.options[
"ignore_hardlink_matches"
] = self.prefs.ignore_hardlink_matches
self.model.options["copymove_dest_type"] = self.prefs.destination_type
self.model.options["scan_type"] = self.prefs.get_scan_type(self.model.app_mode)
self.model.options["min_match_percentage"] = self.prefs.filter_hardness
self.model.options["word_weighting"] = self.prefs.word_weighting
self.model.options["match_similar_words"] = self.prefs.match_similar
threshold = (
self.prefs.small_file_threshold if self.prefs.ignore_small_files else 0
)
self.model.options["size_threshold"] = (
threshold * 1024
) # threshold is in KB. the scanner wants bytes
2016-05-31 20:22:50 -05:00
scanned_tags = set()
if self.prefs.scan_tag_track:
scanned_tags.add("track")
2016-05-31 20:22:50 -05:00
if self.prefs.scan_tag_artist:
scanned_tags.add("artist")
2016-05-31 20:22:50 -05:00
if self.prefs.scan_tag_album:
scanned_tags.add("album")
2016-05-31 20:22:50 -05:00
if self.prefs.scan_tag_title:
scanned_tags.add("title")
2016-05-31 20:22:50 -05:00
if self.prefs.scan_tag_genre:
scanned_tags.add("genre")
2016-05-31 20:22:50 -05:00
if self.prefs.scan_tag_year:
scanned_tags.add("year")
self.model.options["scanned_tags"] = scanned_tags
self.model.options["match_scaled"] = self.prefs.match_scaled
self.model.options["picture_cache_type"] = self.prefs.picture_cache_type
2016-05-31 20:22:50 -05:00
Squashed commit of the following: commit ac941037ff51158b64daa65c244df26346af10cf Author: glubsy <glubsy@users.noreply.github.com> Date: Thu Jul 16 22:21:24 2020 +0200 Fix resize of top frame not updating scaled pixmap * Also limit viewing features such as zoom levels when files have different dimensions * GraphicsViewImageViewer is still a bit buggy: the scrollbars are toggled on when the pixmap is null in the reference viewer (we do not use that class right anyway) commit 733b3b0ed4fbd6de908c968402af03879df3336f Author: glubsy <glubsy@users.noreply.github.com> Date: Thu Jul 16 01:31:24 2020 +0200 Prevent zoom for images of differing dimensions * If images are not the same size, prevent zooming features from being used by disabling the normal size button, only enable swap commit 9168d72f38faaf0a12230cd544f14190cd29fca4 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 22:47:32 2020 +0200 Update preferences on show(), not in constructor * If the dialog window shouldn't have a titlebar during construction, update accordingly only when showing to fix Windows displaying a window without titlebar on first show * Only save geometry if the window is floating. Otherwise geometry while docked is saved whih gives weird results on subsequent starts, since it may be floating by default anyway (at least on Linux where titlebar being disabled is allowed while floating) * Vertical title bar doesn't seem to work on Windows, add note in preferences dialog commit 75621cc816120597f493e0debc6d88e2e0bbd30a Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 22:04:19 2020 +0200 Prevent Windows from floating if no decoration * Windows users cannot move a window which has no native decorations. Toggling a dock widget's titlebar off also removes native decorations on a floating window. Until we implement a replacement titlebar by overriding paintEvents, simply force the floating window to go back to docked state after we toggled the titlebar off. commit 3c816b2f11ddc66a78cdc6327ee102df46d1a552 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 21:43:01 2020 +0200 Fix computing and setting offset to 0 for tableview commit 85d6e05cd406b999e8f6ae421a9746a0c9f146bb Merge: 66127d02 3eddeb6a Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 21:25:44 2020 +0200 Merge branch 'dockable_windows' into details_dialog_improvements_dev commit 66127d025e9a497ee13126f955166946acdb35a8 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 20:22:13 2020 +0200 Add credit for icons used, upscale exchange icon * Jason Cho gave his express permission to use the icon (it was made 10 years ago and he doesn't have the source files anymore) * Used waifu2x to upscale the icon * Used GIMP to draw dark outline around the icon * Source files are included commit 58c675d1fa90a7247233d9887a460cf5a8e4cbf5 Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 05:25:47 2020 +0200 Add custom icons * Use custom icons on platforms which do not provide theme * Old zoom icons credits to "schollidesign" from icon pack Office and Entertainment (GPL licence). * Exchange icon credit to Jason Cho (Unknown license). * Use hack to resize viewers on first show() as well commit 95b8406c7b97aab170d127b466ff506b724def3c Author: glubsy <glubsy@users.noreply.github.com> Date: Wed Jul 15 04:14:24 2020 +0200 Fix scrollbar displayed while splitter maxed out * For some reason the table's height is a few pixel longer on Windows so we work around the issue by adding a small offset to the maximum height hint. * No idea about MacOS yet but this might need the same treatment. commit 3eddeb6aebc99126e62eb05af60333ba3bd22e82 Author: glubsy <glubsy@users.noreply.github.com> Date: Tue Jul 14 17:37:48 2020 +0200 Fix ME/SE details dialogs, add preferences * Fix ME and SE versions of details dialog not displaying their content properly after change to QDockWidget * Add option to toggle titlebar and orientation of titlebar in preferences dialog * Fix setting layout on PE details dialog window while layout already set, by removing the self (parent) reference in constructing the QSplitter commit 56912a71084415eac2f447650279d833d9857686 Author: glubsy <glubsy@users.noreply.github.com> Date: Mon Jul 13 05:06:04 2020 +0200 Make details dialog dockable
2020-07-16 15:31:54 -05:00
if self.details_dialog:
self.details_dialog.update_options()
# --- Private
2016-05-31 20:22:50 -05:00
def _get_details_dialog_class(self):
if self.model.app_mode == AppMode.Picture:
return DetailsDialogPicture
elif self.model.app_mode == AppMode.Music:
return DetailsDialogMusic
else:
return DetailsDialogStandard
def _get_preferences_dialog_class(self):
if self.model.app_mode == AppMode.Picture:
return PreferencesDialogPicture
elif self.model.app_mode == AppMode.Music:
return PreferencesDialogMusic
else:
return PreferencesDialogStandard
# --- Public
def add_selected_to_ignore_list(self):
self.model.add_selected_to_ignore_list()
def remove_selected(self):
self.model.remove_selected(self)
def confirm(self, title, msg, default_button=QMessageBox.Yes):
active = QApplication.activeWindow()
buttons = QMessageBox.Yes | QMessageBox.No
answer = QMessageBox.question(active, title, msg, buttons, default_button)
return answer == QMessageBox.Yes
def invokeCustomCommand(self):
self.model.invoke_custom_command()
def show_details(self):
if self.details_dialog is not None:
if not self.details_dialog.isVisible():
self.details_dialog.show()
else:
self.details_dialog.hide()
def showResultsWindow(self):
if self.resultWindow is not None:
2020-07-31 15:27:18 -05:00
if self.use_tabs:
if self.main_window.indexOfWidget(self.resultWindow) < 0:
self.main_window.addTab(
self.resultWindow, "Results", switch=True)
return
self.main_window.showTab(self.resultWindow)
else:
self.resultWindow.show()
def showDirectoriesWindow(self):
if self.directories_dialog is not None:
2020-07-31 15:27:18 -05:00
if self.use_tabs:
self.main_window.showTab(self.directories_dialog)
else:
self.directories_dialog.show()
def shutdown(self):
self.willSavePrefs.emit()
self.prefs.save()
self.model.save()
QApplication.quit()
# --- Signals
willSavePrefs = pyqtSignal()
SIGTERM = pyqtSignal()
# --- Events
def finishedLaunching(self):
if sys.getfilesystemencoding() == "ascii":
# No need to localize this, it's a debugging message.
msg = (
"Something is wrong with the way your system locale is set. If the files you're "
"scanning have accented letters, you'll probably get a crash. It is advised that "
"you set your system locale properly."
)
QMessageBox.warning(self.main_window if self.main_window
else self.directories_dialog,
"Wrong Locale", msg)
2016-05-31 19:55:32 -05:00
def clearPictureCacheTriggered(self):
title = tr("Clear Picture Cache")
msg = tr("Do you really want to remove all your cached picture analysis?")
if self.confirm(title, msg, QMessageBox.No):
self.model.clear_picture_cache()
active = QApplication.activeWindow()
QMessageBox.information(active, title, tr("Picture cache cleared."))
2012-03-14 11:47:21 -05:00
def ignoreListTriggered(self):
2020-07-31 15:27:18 -05:00
if self.use_tabs:
self.showTriggeredTabbedDialog(self.ignoreListDialog, "Ignore List")
else: # floating windows
self.model.ignore_list_dialog.show()
def excludeListTriggered(self):
if self.use_tabs:
self.showTriggeredTabbedDialog(self.excludeListDialog, "Exclusion Filters")
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")
desktop.open_path(debugLogPath)
def preferencesTriggered(self):
preferences_dialog = self._get_preferences_dialog_class()(
self.main_window if self.main_window else self.directories_dialog,
self
)
preferences_dialog.load()
result = preferences_dialog.exec()
if result == QDialog.Accepted:
preferences_dialog.save()
self.prefs.save()
self._update_options()
preferences_dialog.setParent(None)
def quitTriggered(self):
if self.details_dialog is not None:
self.details_dialog.close()
if self.main_window:
self.main_window.close()
else:
self.directories_dialog.close()
def showAboutBoxTriggered(self):
self.about_box.show()
def showHelpTriggered(self):
base_path = platform.HELP_PATH
help_path = op.abspath(op.join(base_path, "index.html"))
2017-06-20 10:49:11 -05:00
if op.exists(help_path):
url = QUrl.fromLocalFile(help_path)
else:
url = QUrl("https://www.hardcoded.net/dupeguru/help/en/")
QDesktopServices.openUrl(url)
def handleSIGTERM(self):
self.shutdown()
# --- model --> view
def get_default(self, key):
return self.prefs.get_value(key)
def set_default(self, key, value):
self.prefs.set_value(key, value)
def show_message(self, msg):
window = QApplication.activeWindow()
QMessageBox.information(window, "", msg)
def ask_yes_no(self, prompt):
return self.confirm("", prompt)
def create_results_window(self):
"""Creates resultWindow and details_dialog depending on the selected ``app_mode``.
"""
if self.details_dialog is not None:
# The object is not deleted entirely, avoid saving its geometry in the future
# self.willSavePrefs.disconnect(self.details_dialog.appWillSavePrefs)
# or simply delete it on close which is probably cleaner:
self.details_dialog.setAttribute(Qt.WA_DeleteOnClose)
self.details_dialog.close()
# if we don't do the following, Qt will crash when we recreate the Results dialog
self.details_dialog.setParent(None)
if self.resultWindow is not None:
self.resultWindow.close()
# This is better for tabs, as it takes care of duplicate items in menu bar
self.resultWindow.deleteLater() if self.use_tabs else self.resultWindow.setParent(None)
2020-07-31 15:27:18 -05:00
if self.use_tabs:
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()
2016-05-31 20:22:50 -05:00
self.details_dialog = self._get_details_dialog_class()(self.resultWindow, self)
def show_results_window(self):
self.showResultsWindow()
def show_problem_dialog(self):
self.problemDialog.show()
def select_dest_folder(self, prompt):
flags = QFileDialog.ShowDirsOnly
return QFileDialog.getExistingDirectory(self.resultWindow, prompt, "", flags)
def select_dest_file(self, prompt, extension):
files = tr("{} file (*.{})").format(extension.upper(), extension)
destination, chosen_filter = QFileDialog.getSaveFileName(
self.resultWindow, prompt, "", files
)
if not destination.endswith(".{}".format(extension)):
destination = "{}.{}".format(destination, extension)
2014-03-30 14:57:07 -05:00
return destination