2016-06-01 01:22:50 +00:00
|
|
|
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-01-23 15:09:47 +00:00
|
|
|
import sys
|
2009-06-01 09:55:11 +00:00
|
|
|
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 20:31:54 +00:00
|
|
|
from PyQt5.QtCore import QTimer, QObject, QUrl, pyqtSignal, Qt
|
2022-01-25 01:14:30 +00:00
|
|
|
from PyQt5.QtGui import QColor, QDesktopServices, QPalette
|
|
|
|
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QMessageBox, QStyleFactory, QToolTip
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon.trans import trget
|
2022-01-25 01:14:30 +00:00
|
|
|
from hscommon import desktop, plat
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2022-05-09 00:22:08 +00:00
|
|
|
from qt.about_box import AboutBox
|
|
|
|
from qt.recent import Recent
|
|
|
|
from qt.util import create_actions
|
|
|
|
from qt.progress_window import ProgressWindow
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2016-06-01 01:43:24 +00:00
|
|
|
from core.app import AppMode, DupeGuru as DupeGuruModel
|
2016-06-01 02:32:37 +00:00
|
|
|
import core.pe.photo
|
2022-05-09 06:40:08 +00:00
|
|
|
from qt import platform
|
|
|
|
from qt.preferences import Preferences
|
|
|
|
from qt.result_window import ResultWindow
|
|
|
|
from qt.directories_dialog import DirectoriesDialog
|
|
|
|
from qt.problem_dialog import ProblemDialog
|
|
|
|
from qt.ignore_list_dialog import IgnoreListDialog
|
|
|
|
from qt.exclude_list_dialog import ExcludeListDialog
|
|
|
|
from qt.deletion_options import DeletionOptions
|
|
|
|
from qt.se.details_dialog import DetailsDialog as DetailsDialogStandard
|
|
|
|
from qt.me.details_dialog import DetailsDialog as DetailsDialogMusic
|
|
|
|
from qt.pe.details_dialog import DetailsDialog as DetailsDialogPicture
|
|
|
|
from qt.se.preferences_dialog import PreferencesDialog as PreferencesDialogStandard
|
|
|
|
from qt.me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic
|
|
|
|
from qt.pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture
|
|
|
|
from qt.pe.photo import File as PlatSpecificPhoto
|
|
|
|
from qt.tabbed_window import TabBarWindow, TabWindow
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
tr = trget("ui")
|
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
|
2011-09-20 19:06:29 +00:00
|
|
|
class DupeGuru(QObject):
|
2020-01-01 02:16:27 +00:00
|
|
|
LOGO_NAME = "logo_se"
|
|
|
|
NAME = "dupeGuru"
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2013-10-20 19:53:59 +00:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super().__init__(**kwargs)
|
2016-06-01 01:22:50 +00:00
|
|
|
self.prefs = Preferences()
|
2011-01-24 10:30:45 +00:00
|
|
|
self.prefs.load()
|
2020-07-12 14:58:01 +00:00
|
|
|
# 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
|
2021-08-18 02:04:09 +00:00
|
|
|
self.model = DupeGuruModel(view=self, portable=self.prefs.portable)
|
2009-06-01 09:55:11 +00:00
|
|
|
self._setup()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Private
|
2009-06-01 09:55:11 +00:00
|
|
|
def _setup(self):
|
2016-06-01 02:32:37 +00:00
|
|
|
core.pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto
|
2011-01-15 15:29:35 +00:00
|
|
|
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 20:31:54 +00:00
|
|
|
self.details_dialog = None
|
2009-06-01 09:55:11 +00:00
|
|
|
self._update_options()
|
2020-01-01 02:16:27 +00:00
|
|
|
self.recentResults = Recent(self, "recentResults")
|
2011-09-20 19:06:29 +00:00
|
|
|
self.recentResults.mustOpenItem.connect(self.model.load_from)
|
2016-05-30 02:37:38 +00:00
|
|
|
self.resultWindow = None
|
2020-07-12 14:58:01 +00:00
|
|
|
if self.use_tabs:
|
2021-08-15 09:10:18 +00:00
|
|
|
self.main_window = TabBarWindow(self) if not self.prefs.tabs_default_pos else TabWindow(self)
|
2020-07-12 14:58:01 +00:00
|
|
|
parent_window = self.main_window
|
2021-08-15 09:10:18 +00:00
|
|
|
self.directories_dialog = self.main_window.createPage("DirectoriesDialog", app=self)
|
|
|
|
self.main_window.addTab(self.directories_dialog, tr("Directories"), switch=False)
|
2020-07-31 03:08:08 +00:00
|
|
|
self.actionDirectoriesWindow.setEnabled(False)
|
2020-07-12 14:58:01 +00:00
|
|
|
else: # floating windows only
|
|
|
|
self.main_window = None
|
|
|
|
self.directories_dialog = DirectoriesDialog(self)
|
|
|
|
parent_window = self.directories_dialog
|
|
|
|
|
2021-01-06 05:21:44 +00:00
|
|
|
self.progress_window = ProgressWindow(parent_window, self.model.progress_window)
|
2021-08-15 09:10:18 +00:00
|
|
|
self.problemDialog = ProblemDialog(parent=parent_window, model=self.model.problem_dialog)
|
2020-07-31 20:27:18 +00:00
|
|
|
if self.use_tabs:
|
2020-07-12 14:58:01 +00:00
|
|
|
self.ignoreListDialog = self.main_window.createPage(
|
|
|
|
"IgnoreListDialog",
|
|
|
|
parent=self.main_window,
|
2021-01-06 05:21:44 +00:00
|
|
|
model=self.model.ignore_list_dialog,
|
|
|
|
)
|
2020-07-28 14:33:28 +00:00
|
|
|
|
|
|
|
self.excludeListDialog = self.main_window.createPage(
|
|
|
|
"ExcludeListDialog",
|
|
|
|
app=self,
|
|
|
|
parent=self.main_window,
|
2021-01-06 05:21:44 +00:00
|
|
|
model=self.model.exclude_list_dialog,
|
|
|
|
)
|
2020-07-12 14:58:01 +00:00
|
|
|
else:
|
2021-08-15 09:10:18 +00:00
|
|
|
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)
|
2020-07-12 14:58:01 +00:00
|
|
|
|
2021-08-15 09:10:18 +00:00
|
|
|
self.deletionOptions = DeletionOptions(parent=parent_window, model=self.model.deletion_options)
|
2020-07-12 14:58:01 +00:00
|
|
|
self.about_box = AboutBox(parent_window, self)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-12 14:58:01 +00:00
|
|
|
parent_window.show()
|
2011-09-20 19:06:29 +00:00
|
|
|
self.model.load()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2017-06-20 16:04:38 +00:00
|
|
|
self.SIGTERM.connect(self.handleSIGTERM)
|
|
|
|
|
2014-10-13 19:08:59 +00:00
|
|
|
# The timer scheme is because if the nag is not shown before the application is
|
2011-09-21 17:42:54 +00:00
|
|
|
# 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)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def _setupActions(self):
|
|
|
|
# Setup actions that are common to both the directory dialog and the results window.
|
|
|
|
# (name, shortcut, icon, desc, func)
|
|
|
|
ACTIONS = [
|
2020-01-01 02:16:27 +00:00
|
|
|
("actionQuit", "Ctrl+Q", "", tr("Quit"), self.quitTriggered),
|
|
|
|
(
|
|
|
|
"actionPreferences",
|
|
|
|
"Ctrl+P",
|
|
|
|
"",
|
|
|
|
tr("Options"),
|
|
|
|
self.preferencesTriggered,
|
|
|
|
),
|
|
|
|
("actionIgnoreList", "", "", tr("Ignore List"), self.ignoreListTriggered),
|
2021-01-06 05:21:44 +00:00
|
|
|
(
|
|
|
|
"actionDirectoriesWindow",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
tr("Directories"),
|
|
|
|
self.showDirectoriesWindow,
|
|
|
|
),
|
2020-01-01 02:16:27 +00:00
|
|
|
(
|
2021-10-29 04:22:12 +00:00
|
|
|
"actionClearCache",
|
2020-01-01 02:16:27 +00:00
|
|
|
"Ctrl+Shift+P",
|
|
|
|
"",
|
2021-10-29 04:22:12 +00:00
|
|
|
tr("Clear Cache"),
|
|
|
|
self.clearCacheTriggered,
|
2020-01-01 02:16:27 +00:00
|
|
|
),
|
2021-01-06 05:21:44 +00:00
|
|
|
(
|
|
|
|
"actionExcludeList",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
tr("Exclusion Filters"),
|
|
|
|
self.excludeListTriggered,
|
|
|
|
),
|
2020-01-01 02:16:27 +00:00
|
|
|
("actionShowHelp", "F1", "", tr("dupeGuru Help"), self.showHelpTriggered),
|
|
|
|
("actionAbout", "", "", tr("About dupeGuru"), self.showAboutBoxTriggered),
|
|
|
|
(
|
|
|
|
"actionOpenDebugLog",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
tr("Open Debug Log"),
|
|
|
|
self.openDebugLogTriggered,
|
|
|
|
),
|
2011-01-15 15:29:35 +00:00
|
|
|
]
|
2021-08-24 05:12:23 +00:00
|
|
|
create_actions(ACTIONS, self)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def _update_options(self):
|
2020-01-01 02:16:27 +00:00
|
|
|
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
|
2021-08-15 09:10:18 +00:00
|
|
|
self.model.options["ignore_hardlink_matches"] = self.prefs.ignore_hardlink_matches
|
2020-01-01 02:16:27 +00:00
|
|
|
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
|
2021-08-15 09:10:18 +00:00
|
|
|
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
|
2021-08-27 10:35:54 +00:00
|
|
|
large_threshold = self.prefs.large_file_threshold if self.prefs.ignore_large_files else 0
|
|
|
|
self.model.options["large_size_threshold"] = (
|
|
|
|
large_threshold * 1024 * 1024
|
|
|
|
) # threshold is in MB. The Scanner wants bytes
|
2021-08-15 09:10:18 +00:00
|
|
|
big_file_size_threshold = self.prefs.big_file_size_threshold if self.prefs.big_file_partial_hashes else 0
|
2021-06-21 17:03:21 +00:00
|
|
|
self.model.options["big_file_size_threshold"] = (
|
2021-08-15 09:10:18 +00:00
|
|
|
big_file_size_threshold
|
|
|
|
* 1024
|
|
|
|
* 1024
|
2021-06-21 17:03:21 +00:00
|
|
|
# threshold is in MiB. The scanner wants bytes
|
|
|
|
)
|
2016-06-01 01:22:50 +00:00
|
|
|
scanned_tags = set()
|
|
|
|
if self.prefs.scan_tag_track:
|
2020-01-01 02:16:27 +00:00
|
|
|
scanned_tags.add("track")
|
2016-06-01 01:22:50 +00:00
|
|
|
if self.prefs.scan_tag_artist:
|
2020-01-01 02:16:27 +00:00
|
|
|
scanned_tags.add("artist")
|
2016-06-01 01:22:50 +00:00
|
|
|
if self.prefs.scan_tag_album:
|
2020-01-01 02:16:27 +00:00
|
|
|
scanned_tags.add("album")
|
2016-06-01 01:22:50 +00:00
|
|
|
if self.prefs.scan_tag_title:
|
2020-01-01 02:16:27 +00:00
|
|
|
scanned_tags.add("title")
|
2016-06-01 01:22:50 +00:00
|
|
|
if self.prefs.scan_tag_genre:
|
2020-01-01 02:16:27 +00:00
|
|
|
scanned_tags.add("genre")
|
2016-06-01 01:22:50 +00:00
|
|
|
if self.prefs.scan_tag_year:
|
2020-01-01 02:16:27 +00:00
|
|
|
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-06-01 01:22:50 +00: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 20:31:54 +00:00
|
|
|
if self.details_dialog:
|
|
|
|
self.details_dialog.update_options()
|
|
|
|
|
2022-01-25 01:14:30 +00:00
|
|
|
self._set_style("dark" if self.prefs.use_dark_style else "light")
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Private
|
2016-06-01 01:22:50 +00:00
|
|
|
def _get_details_dialog_class(self):
|
2021-08-21 23:02:02 +00:00
|
|
|
if self.model.app_mode == AppMode.PICTURE:
|
2016-06-01 01:22:50 +00:00
|
|
|
return DetailsDialogPicture
|
2021-08-21 23:02:02 +00:00
|
|
|
elif self.model.app_mode == AppMode.MUSIC:
|
2016-06-01 01:22:50 +00:00
|
|
|
return DetailsDialogMusic
|
|
|
|
else:
|
|
|
|
return DetailsDialogStandard
|
|
|
|
|
|
|
|
def _get_preferences_dialog_class(self):
|
2021-08-21 23:02:02 +00:00
|
|
|
if self.model.app_mode == AppMode.PICTURE:
|
2016-06-01 01:22:50 +00:00
|
|
|
return PreferencesDialogPicture
|
2021-08-21 23:02:02 +00:00
|
|
|
elif self.model.app_mode == AppMode.MUSIC:
|
2016-06-01 01:22:50 +00:00
|
|
|
return PreferencesDialogMusic
|
|
|
|
else:
|
|
|
|
return PreferencesDialogStandard
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2022-01-25 01:14:30 +00:00
|
|
|
def _set_style(self, style="light"):
|
|
|
|
# Only support this feature on windows for now
|
|
|
|
if not plat.ISWINDOWS:
|
|
|
|
return
|
|
|
|
if style == "dark":
|
|
|
|
QApplication.setStyle(QStyleFactory.create("Fusion"))
|
|
|
|
palette = QApplication.style().standardPalette()
|
|
|
|
palette.setColor(QPalette.ColorRole.Window, QColor(53, 53, 53))
|
|
|
|
palette.setColor(QPalette.ColorRole.WindowText, Qt.white)
|
|
|
|
palette.setColor(QPalette.ColorRole.Base, QColor(25, 25, 25))
|
|
|
|
palette.setColor(QPalette.ColorRole.AlternateBase, QColor(53, 53, 53))
|
|
|
|
palette.setColor(QPalette.ColorRole.ToolTipBase, QColor(53, 53, 53))
|
|
|
|
palette.setColor(QPalette.ColorRole.ToolTipText, Qt.white)
|
|
|
|
palette.setColor(QPalette.ColorRole.Text, Qt.white)
|
|
|
|
palette.setColor(QPalette.ColorRole.Button, QColor(53, 53, 53))
|
|
|
|
palette.setColor(QPalette.ColorRole.ButtonText, Qt.white)
|
|
|
|
palette.setColor(QPalette.ColorRole.BrightText, Qt.red)
|
|
|
|
palette.setColor(QPalette.ColorRole.Link, QColor(42, 130, 218))
|
|
|
|
palette.setColor(QPalette.ColorRole.Highlight, QColor(42, 130, 218))
|
|
|
|
palette.setColor(QPalette.ColorRole.HighlightedText, Qt.black)
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Text, QColor(164, 166, 168))
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.WindowText, QColor(164, 166, 168))
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, QColor(164, 166, 168))
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.HighlightedText, QColor(164, 166, 168))
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Base, QColor(68, 68, 68))
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Window, QColor(68, 68, 68))
|
|
|
|
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Highlight, QColor(68, 68, 68))
|
|
|
|
else:
|
|
|
|
QApplication.setStyle(QStyleFactory.create("windowsvista" if plat.ISWINDOWS else "Fusion"))
|
|
|
|
palette = QApplication.style().standardPalette()
|
|
|
|
QToolTip.setPalette(palette)
|
|
|
|
QApplication.setPalette(palette)
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Public
|
2010-02-06 11:12:20 +00:00
|
|
|
def add_selected_to_ignore_list(self):
|
2012-03-10 15:58:08 +00:00
|
|
|
self.model.add_selected_to_ignore_list()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-02-06 11:44:21 +00:00
|
|
|
def remove_selected(self):
|
2012-03-10 15:58:08 +00:00
|
|
|
self.model.remove_selected(self)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
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
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-04-13 08:02:09 +00:00
|
|
|
def invokeCustomCommand(self):
|
2012-03-10 15:58:08 +00:00
|
|
|
self.model.invoke_custom_command()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def show_details(self):
|
2016-05-30 02:37:38 +00:00
|
|
|
if self.details_dialog is not None:
|
2020-07-29 18:43:18 +00:00
|
|
|
if not self.details_dialog.isVisible():
|
|
|
|
self.details_dialog.show()
|
|
|
|
else:
|
|
|
|
self.details_dialog.hide()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def showResultsWindow(self):
|
2016-05-30 02:37:38 +00:00
|
|
|
if self.resultWindow is not None:
|
2020-07-31 20:27:18 +00:00
|
|
|
if self.use_tabs:
|
2020-08-20 15:12:39 +00:00
|
|
|
if self.main_window.indexOfWidget(self.resultWindow) < 0:
|
2021-08-15 09:10:18 +00:00
|
|
|
self.main_window.addTab(self.resultWindow, tr("Results"), switch=True)
|
2020-08-20 15:12:39 +00:00
|
|
|
return
|
2020-08-02 14:12:47 +00:00
|
|
|
self.main_window.showTab(self.resultWindow)
|
2020-07-12 14:58:01 +00:00
|
|
|
else:
|
|
|
|
self.resultWindow.show()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-31 03:08:08 +00:00
|
|
|
def showDirectoriesWindow(self):
|
|
|
|
if self.directories_dialog is not None:
|
2020-07-31 20:27:18 +00:00
|
|
|
if self.use_tabs:
|
2020-08-02 14:12:47 +00:00
|
|
|
self.main_window.showTab(self.directories_dialog)
|
2020-07-31 03:08:08 +00:00
|
|
|
else:
|
|
|
|
self.directories_dialog.show()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-08-15 01:11:24 +00:00
|
|
|
def shutdown(self):
|
|
|
|
self.willSavePrefs.emit()
|
|
|
|
self.prefs.save()
|
|
|
|
self.model.save()
|
2021-10-29 04:22:12 +00:00
|
|
|
self.model.close()
|
2021-04-16 15:54:49 +00:00
|
|
|
# Workaround for #857, hide() or close().
|
|
|
|
if self.details_dialog is not None:
|
|
|
|
self.details_dialog.close()
|
2016-08-15 01:11:24 +00:00
|
|
|
QApplication.quit()
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Signals
|
2010-08-15 10:27:15 +00:00
|
|
|
willSavePrefs = pyqtSignal()
|
2017-06-20 16:04:38 +00:00
|
|
|
SIGTERM = pyqtSignal()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Events
|
2011-09-21 17:42:54 +00:00
|
|
|
def finishedLaunching(self):
|
2020-01-01 02:16:27 +00:00
|
|
|
if sys.getfilesystemencoding() == "ascii":
|
2011-12-07 17:04:02 +00:00
|
|
|
# No need to localize this, it's a debugging message.
|
2020-01-01 02:16:27 +00:00
|
|
|
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 "
|
2014-10-13 19:08:59 +00:00
|
|
|
"you set your system locale properly."
|
2020-01-01 02:16:27 +00:00
|
|
|
)
|
2021-01-06 05:21:44 +00:00
|
|
|
QMessageBox.warning(
|
|
|
|
self.main_window if self.main_window else self.directories_dialog,
|
|
|
|
"Wrong Locale",
|
|
|
|
msg,
|
|
|
|
)
|
2021-08-19 00:24:14 +00:00
|
|
|
# Load results on open if passed a .dupeguru file
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
results = sys.argv[1]
|
|
|
|
if results.endswith(".dupeguru"):
|
|
|
|
self.model.load_from(results)
|
|
|
|
self.recentResults.insertItem(results)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2021-10-29 04:22:12 +00:00
|
|
|
def clearCacheTriggered(self):
|
|
|
|
title = tr("Clear Cache")
|
|
|
|
msg = tr("Do you really want to clear the cache? This will remove all cached file hashes and picture analysis.")
|
2016-06-01 00:55:32 +00:00
|
|
|
if self.confirm(title, msg, QMessageBox.No):
|
|
|
|
self.model.clear_picture_cache()
|
2021-10-29 04:22:12 +00:00
|
|
|
self.model.clear_hash_cache()
|
2016-06-01 00:55:32 +00:00
|
|
|
active = QApplication.activeWindow()
|
2021-10-29 04:22:12 +00:00
|
|
|
QMessageBox.information(active, title, tr("Cache cleared."))
|
2016-06-01 00:55:32 +00:00
|
|
|
|
2012-03-14 16:47:21 +00:00
|
|
|
def ignoreListTriggered(self):
|
2020-07-31 20:27:18 +00:00
|
|
|
if self.use_tabs:
|
2021-03-18 01:21:29 +00:00
|
|
|
self.showTriggeredTabbedDialog(self.ignoreListDialog, tr("Ignore List"))
|
2020-08-23 14:49:43 +00:00
|
|
|
else: # floating windows
|
2020-07-12 14:58:01 +00:00
|
|
|
self.model.ignore_list_dialog.show()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-28 14:33:28 +00:00
|
|
|
def excludeListTriggered(self):
|
2020-08-20 15:12:39 +00:00
|
|
|
if self.use_tabs:
|
2021-08-15 09:10:18 +00:00
|
|
|
self.showTriggeredTabbedDialog(self.excludeListDialog, tr("Exclusion Filters"))
|
2020-08-23 14:49:43 +00:00
|
|
|
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
|
2021-08-15 09:10:18 +00:00
|
|
|
if index < 0: # or (not dialog.isVisible() and not self.main_window.isTabVisible(index)):
|
2020-08-23 14:49:43 +00:00
|
|
|
index = self.main_window.addTab(dialog, desc_string, switch=True)
|
|
|
|
# Show the tab for that widget
|
|
|
|
self.main_window.setCurrentIndex(index)
|
2020-07-28 14:33:28 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def openDebugLogTriggered(self):
|
2021-08-24 05:12:23 +00:00
|
|
|
debug_log_path = op.join(self.model.appdata, "debug.log")
|
|
|
|
desktop.open_path(debug_log_path)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def preferencesTriggered(self):
|
2020-01-01 02:16:27 +00:00
|
|
|
preferences_dialog = self._get_preferences_dialog_class()(
|
2021-01-06 05:21:44 +00:00
|
|
|
self.main_window if self.main_window else self.directories_dialog, self
|
2020-01-01 02:16:27 +00:00
|
|
|
)
|
2016-05-30 02:37:38 +00:00
|
|
|
preferences_dialog.load()
|
|
|
|
result = preferences_dialog.exec()
|
2011-01-15 15:29:35 +00:00
|
|
|
if result == QDialog.Accepted:
|
2016-05-30 02:37:38 +00:00
|
|
|
preferences_dialog.save()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.prefs.save()
|
|
|
|
self._update_options()
|
2016-05-30 02:37:38 +00:00
|
|
|
preferences_dialog.setParent(None)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def quitTriggered(self):
|
2020-07-30 13:30:09 +00:00
|
|
|
if self.details_dialog is not None:
|
|
|
|
self.details_dialog.close()
|
2020-08-01 16:29:22 +00:00
|
|
|
|
2020-07-12 14:58:01 +00:00
|
|
|
if self.main_window:
|
|
|
|
self.main_window.close()
|
|
|
|
else:
|
|
|
|
self.directories_dialog.close()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def showAboutBoxTriggered(self):
|
|
|
|
self.about_box.show()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def showHelpTriggered(self):
|
2011-11-30 16:06:08 +00:00
|
|
|
base_path = platform.HELP_PATH
|
2020-01-01 02:16:27 +00:00
|
|
|
help_path = op.abspath(op.join(base_path, "index.html"))
|
2017-06-20 15:49:11 +00:00
|
|
|
if op.exists(help_path):
|
|
|
|
url = QUrl.fromLocalFile(help_path)
|
|
|
|
else:
|
2021-01-06 05:21:44 +00:00
|
|
|
url = QUrl("https://dupeguru.voltaicideas.net/help/en/")
|
2011-01-15 15:29:35 +00:00
|
|
|
QDesktopServices.openUrl(url)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2017-06-20 16:04:38 +00:00
|
|
|
def handleSIGTERM(self):
|
|
|
|
self.shutdown()
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- model --> view
|
2011-09-20 19:06:29 +00:00
|
|
|
def get_default(self, key):
|
|
|
|
return self.prefs.get_value(key)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-09-20 19:06:29 +00:00
|
|
|
def set_default(self, key, value):
|
|
|
|
self.prefs.set_value(key, value)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-09-22 14:35:17 +00:00
|
|
|
def show_message(self, msg):
|
|
|
|
window = QApplication.activeWindow()
|
2020-01-01 02:16:27 +00:00
|
|
|
QMessageBox.information(window, "", msg)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-10 15:58:08 +00:00
|
|
|
def ask_yes_no(self, prompt):
|
2020-01-01 02:16:27 +00:00
|
|
|
return self.confirm("", prompt)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-30 02:37:38 +00:00
|
|
|
def create_results_window(self):
|
2021-01-06 05:21:44 +00:00
|
|
|
"""Creates resultWindow and details_dialog depending on the selected ``app_mode``."""
|
2016-05-30 02:37:38 +00:00
|
|
|
if self.details_dialog is not None:
|
2020-07-30 18:25:20 +00:00
|
|
|
# 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)
|
2016-05-30 02:37:38 +00:00
|
|
|
self.details_dialog.close()
|
2020-08-20 15:12:39 +00:00
|
|
|
# if we don't do the following, Qt will crash when we recreate the Results dialog
|
|
|
|
self.details_dialog.setParent(None)
|
2016-05-30 02:37:38 +00:00
|
|
|
if self.resultWindow is not None:
|
|
|
|
self.resultWindow.close()
|
2020-08-31 19:17:08 +00:00
|
|
|
# This is better for tabs, as it takes care of duplicate items in menu bar
|
2021-08-15 09:10:18 +00:00
|
|
|
self.resultWindow.deleteLater() if self.use_tabs else self.resultWindow.setParent(None)
|
2020-07-31 20:27:18 +00:00
|
|
|
if self.use_tabs:
|
2021-08-15 09:10:18 +00:00
|
|
|
self.resultWindow = self.main_window.createPage("ResultWindow", parent=self.main_window, app=self)
|
2020-07-12 14:58:01 +00:00
|
|
|
else: # We don't use a tab widget, regular floating QMainWindow
|
|
|
|
self.resultWindow = ResultWindow(self.directories_dialog, self)
|
|
|
|
self.directories_dialog._updateActionsState()
|
2016-06-01 01:22:50 +00:00
|
|
|
self.details_dialog = self._get_details_dialog_class()(self.resultWindow, self)
|
2016-05-30 02:37:38 +00:00
|
|
|
|
2012-03-09 18:47:28 +00:00
|
|
|
def show_results_window(self):
|
|
|
|
self.showResultsWindow()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-09 18:47:28 +00:00
|
|
|
def show_problem_dialog(self):
|
|
|
|
self.problemDialog.show()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-10 19:32:56 +00:00
|
|
|
def select_dest_folder(self, prompt):
|
|
|
|
flags = QFileDialog.ShowDirsOnly
|
2020-01-01 02:16:27 +00:00
|
|
|
return QFileDialog.getExistingDirectory(self.resultWindow, prompt, "", flags)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-07-31 20:46:51 +00:00
|
|
|
def select_dest_file(self, prompt, extension):
|
|
|
|
files = tr("{} file (*.{})").format(extension.upper(), extension)
|
2021-08-15 09:10:18 +00:00
|
|
|
destination, chosen_filter = QFileDialog.getSaveFileName(self.resultWindow, prompt, "", files)
|
2022-04-28 01:53:12 +00:00
|
|
|
if not destination.endswith(f".{extension}"):
|
|
|
|
destination = f"{destination}.{extension}"
|
2014-03-30 19:57:07 +00:00
|
|
|
return destination
|