Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image comparison features to details dialog #683

Merged
merged 70 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9b48e18
add zoom and swap buttons to details dialog
glubsy May 1, 2020
f42df12
attempt at double click on Qlabel
glubsy May 2, 2020
468a736
add normal size button
glubsy May 2, 2020
ea61976
drag mouse with ImageViewer class
glubsy May 2, 2020
02bd822
working zoom functions, mouse wheel event
glubsy Jun 4, 2020
c616291
working synchronized panning
glubsy Jun 4, 2020
a29f3fb
only update delta when mouse is being dragged to reduce paint events
glubsy Jun 4, 2020
60ddb9b
Working synchronized views.
glubsy Jun 5, 2020
c379791
Controller class to decouple from the dialog class
glubsy Jun 9, 2020
8103cb3
Disable unused methods from controller
glubsy Jun 10, 2020
b7abcf2
Use native QPixmap swap() method instead of manual setPixmap()
glubsy Jun 10, 2020
a706d0e
Implement mostly working ScrollArea viewer
glubsy Jun 16, 2020
970bb5e
Add mostly working ScrollArea imge viewers
glubsy Jun 20, 2020
aa79b31
Work around resizing down offset by 1 pixel.
glubsy Jun 21, 2020
977c20f
Add QSplitter to hide TableView in DetailsDialog
glubsy Jun 22, 2020
011939f
Keep scale accross files of the same dupe group.
glubsy Jun 23, 2020
9f15139
Fix view resetting when selecting reference only.
glubsy Jun 24, 2020
370b582
Add working zoom functions to GraphicsView viewers.
glubsy Jun 28, 2020
36ab844
Move buttons into the toolbar class.
glubsy Jun 28, 2020
e7b3252
Cleanup of details table
glubsy Jun 29, 2020
4ee9479
Add image comparison features to details dialog
glubsy Jul 2, 2020
b0a256f
Fix flake8 minor issues
glubsy Jul 2, 2020
7ab2998
Merge commit 'b0a256f0'
glubsy Jul 12, 2020
56912a7
Make details dialog dockable
glubsy Jul 13, 2020
3eddeb6
Fix ME/SE details dialogs, add preferences
glubsy Jul 14, 2020
95b8406
Fix scrollbar displayed while splitter maxed out
glubsy Jul 15, 2020
58c675d
Add custom icons
glubsy Jul 15, 2020
66127d0
Add credit for icons used, upscale exchange icon
glubsy Jul 15, 2020
85d6e05
Merge branch 'dockable_windows' into details_dialog_improvements_dev
glubsy Jul 15, 2020
3c816b2
Fix computing and setting offset to 0 for tableview
glubsy Jul 15, 2020
75621cc
Prevent Windows from floating if no decoration
glubsy Jul 15, 2020
9168d72
Update preferences on show(), not in constructor
glubsy Jul 15, 2020
733b3b0
Prevent zoom for images of differing dimensions
glubsy Jul 15, 2020
ac94103
Fix resize of top frame not updating scaled pixmap
glubsy Jul 16, 2020
6213d50
Squashed commit of the following:
glubsy Jul 16, 2020
3539263
Add tabs to preference dialog.
glubsy Jul 20, 2020
298f659
Fix Restore Default Preferences button
glubsy Jul 20, 2020
cf64565
Add option to use internal icons in details dialog
glubsy Jul 21, 2020
9ae0d7e
Add color picker buttons to preferences dialog
glubsy Jul 22, 2020
730fadf
Merge branch 'preferences_tabs' into details_dialog_improvements
glubsy Jul 22, 2020
7dc9f25
Merge branch 'master' into details_dialog_improvements
glubsy Jul 29, 2020
1823575
Fix swapping table view columns
glubsy Jul 29, 2020
1937120
Fix toggling details view via menu or shortcut
glubsy Jul 29, 2020
9795f14
Fix title bar toggling on/off when dialog
glubsy Jul 29, 2020
da8c493
Toggle visibility of details dialog
glubsy Jul 29, 2020
eab5003
Add color preference for delta in details table
glubsy Jul 29, 2020
fa54e93
Add preference to turn off scrollbars in viewers
glubsy Jul 30, 2020
79613f9
Fix crash quitting while details dialog active
glubsy Jul 30, 2020
9b8637f
Stretch last header section in Result window
glubsy Jul 30, 2020
7e4f371
Avoid crash when quitting
glubsy Jul 30, 2020
2364281
Remove unused properties in details table headers
glubsy Jul 30, 2020
1125438
Save dock panel position on quit
glubsy Jul 30, 2020
2620d00
Fix layout error
glubsy Jul 31, 2020
d2cdcc9
Fix 1 pixel sized color in color picker buttons
glubsy Aug 1, 2020
acdeb01
Tweak preference layout for better readability
glubsy Aug 1, 2020
628d772
Use FormLayout instead of GridLayout
glubsy Aug 1, 2020
3be1ee8
Merge branch 'master' into details_dialog_improvements
glubsy Aug 1, 2020
056fa81
Revert stretching last section in Result window
glubsy Aug 1, 2020
a3e402a
Group general interface options together
glubsy Aug 1, 2020
de5e612
Add stretch to bottom of General pref tab
glubsy Aug 1, 2020
fbd7c4f
Tweak visuals for cache selection item
glubsy Aug 1, 2020
0104d89
Fix alignment for combo box's label
glubsy Aug 1, 2020
866bf99
Prevent Directories tab from closing on MacOS
glubsy Aug 1, 2020
76fbfc2
Fix adding new Result tab if already existed
glubsy Aug 2, 2020
089f00a
Fix typo in class member reference
glubsy Aug 3, 2020
b8af2a4
Don't show parent window's context menu on viewers
glubsy Sep 2, 2020
a265b71
Improve comment reflecting modification of function
glubsy Oct 28, 2020
92feba5
Remove obsolete UI setup code
glubsy Oct 28, 2020
59ce740
Remove print debug statements
glubsy Oct 28, 2020
cf5ba03
Remove icon credits from about box
glubsy Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ cocoa/autogen

*.pyd
*.exe
*.spec
*.spec

.vscode
2 changes: 2 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
To know who contributed to dupeGuru, you can look at the commit log, but not all contributions
result in a commit. This file lists contributors who don't necessarily appear in the commit log.

* Jason Cho, Exchange icon
* schollidesign (https://findicons.com/pack/1035/human_o2), Zoom-in, Zoom-out, Zoom-best-fit, Zoom-original icons
* Jérôme Cantin, Main icon
* Gregor Tätzner, German localization
* Frank Weber, German localization
Expand Down
Binary file added images/exchange.icns
Binary file not shown.
Binary file added images/exchange.ico
Binary file not shown.
Binary file added images/exchange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/exchange_purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/exchange_purple_upscaled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/exchange_purple_waifu_s4_tta8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/exchange_purple_waifu_s4_tta8.xcf
Binary file not shown.
Binary file added images/exchange_waifu_s4_tta8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/old_zoom_best_fit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/old_zoom_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/old_zoom_original.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/old_zoom_out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 21 additions & 9 deletions qt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import os.path as op

from PyQt5.QtCore import QTimer, QObject, QUrl, pyqtSignal
from PyQt5.QtCore import QTimer, QObject, QUrl, pyqtSignal, Qt
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QMessageBox

Expand Down Expand Up @@ -58,11 +58,11 @@ def __init__(self, **kwargs):
def _setup(self):
core.pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto
self._setupActions()
self.details_dialog = None
self._update_options()
self.recentResults = Recent(self, "recentResults")
self.recentResults.mustOpenItem.connect(self.model.load_from)
self.resultWindow = None
self.details_dialog = 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
Expand Down Expand Up @@ -177,6 +177,9 @@ def _update_options(self):
self.model.options["match_scaled"] = self.prefs.match_scaled
self.model.options["picture_cache_type"] = self.prefs.picture_cache_type

if self.details_dialog:
self.details_dialog.update_options()

# --- Private
def _get_details_dialog_class(self):
if self.model.app_mode == AppMode.Picture:
Expand Down Expand Up @@ -212,22 +215,22 @@ def invokeCustomCommand(self):

def show_details(self):
if self.details_dialog is not None:
self.details_dialog.show()
if not self.details_dialog.isVisible():
self.details_dialog.show()
else:
self.details_dialog.hide()

def showResultsWindow(self):
if self.resultWindow is not None:
if self.use_tabs:
self.main_window.addTab(
self.resultWindow, "Results", switch=True)
self.main_window.showTab(self.resultWindow)
else:
self.resultWindow.show()

def showDirectoriesWindow(self):
if self.directories_dialog is not None:
if self.use_tabs:
index = self.main_window.indexOfWidget(self.directories_dialog)
self.main_window.setTabVisible(index, True)
self.main_window.setCurrentIndex(index)
self.main_window.showTab(self.directories_dialog)
else:
self.directories_dialog.show()

Expand Down Expand Up @@ -295,6 +298,9 @@ def preferencesTriggered(self):
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:
Expand Down Expand Up @@ -333,14 +339,20 @@ 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()
self.details_dialog.setParent(None)
# self.details_dialog.setParent(None) # seems unnecessary
if self.resultWindow is not None:
self.resultWindow.close()
self.resultWindow.setParent(None)
if self.use_tabs:
self.resultWindow = self.main_window.createPage(
"ResultWindow", parent=self.main_window, app=self)
self.main_window.addTab(
self.resultWindow, "Results", switch=False)
else: # We don't use a tab widget, regular floating QMainWindow
self.resultWindow = ResultWindow(self.directories_dialog, self)
self.directories_dialog._updateActionsState()
Expand Down
39 changes: 34 additions & 5 deletions qt/details_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,63 @@
# http://www.gnu.org/licenses/gpl-3.0.html

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QDockWidget, QWidget

from .details_table import DetailsModel
from hscommon.plat import ISLINUX


class DetailsDialog(QDialog):
class DetailsDialog(QDockWidget):
def __init__(self, parent, app, **kwargs):
super().__init__(parent, Qt.Tool, **kwargs)
self.parent = parent
self.app = app
self.model = app.model.details_panel
self.setAllowedAreas(Qt.AllDockWidgetAreas)
self._setupUi()
# To avoid saving uninitialized geometry on appWillSavePrefs, we track whether our dialog
# has been shown. If it has, we know that our geometry should be saved.
self._shown_once = False
self.app.prefs.restoreGeometry("DetailsWindowRect", self)
self.tableModel = DetailsModel(self.model)
self._wasDocked, area = self.app.prefs.restoreGeometry("DetailsWindowRect", self)
self.tableModel = DetailsModel(self.model, app)
# tableView is defined in subclasses
self.tableView.setModel(self.tableModel)
self.model.view = self

self.app.willSavePrefs.connect(self.appWillSavePrefs)
# self.setAttribute(Qt.WA_DeleteOnClose)
parent.addDockWidget(
area if self._wasDocked else Qt.BottomDockWidgetArea, self)

def _setupUi(self): # Virtual
pass

def show(self):
if not self._shown_once and self._wasDocked:
self.setFloating(False)
self._shown_once = True
super().show()
self.update_options()

def update_options(self):
# This disables the title bar (if we had not set one before already)
# essentially making it a simple floating window, not dockable anymore
if not self.app.prefs.details_dialog_titlebar_enabled:
if not self.titleBarWidget(): # default title bar
self.setTitleBarWidget(QWidget()) # disables title bar
# Windows (and MacOS?) users cannot move a floating window which
# has not native decoration so we force it to dock for now
if not ISLINUX:
self.setFloating(False)
elif self.titleBarWidget() is not None: # title bar is disabled
self.setTitleBarWidget(None) # resets to the default title bar
elif not self.titleBarWidget() and not self.app.prefs.details_dialog_titlebar_enabled:
self.setTitleBarWidget(QWidget())

features = self.features()
if self.app.prefs.details_dialog_vertical_titlebar:
self.setFeatures(features | QDockWidget.DockWidgetVerticalTitleBar)
elif features & QDockWidget.DockWidgetVerticalTitleBar:
self.setFeatures(features ^ QDockWidget.DockWidgetVerticalTitleBar)

# --- Events
def appWillSavePrefs(self):
Expand Down
9 changes: 4 additions & 5 deletions qt/details_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from PyQt5.QtCore import Qt, QAbstractTableModel
from PyQt5.QtWidgets import QHeaderView, QTableView
from PyQt5.QtGui import QFont, QBrush, QColor
from PyQt5.QtGui import QFont, QBrush

from hscommon.trans import trget

Expand All @@ -18,9 +18,10 @@


class DetailsModel(QAbstractTableModel):
def __init__(self, model, **kwargs):
def __init__(self, model, app, **kwargs):
super().__init__(**kwargs)
self.model = model
self.prefs = app.prefs

def columnCount(self, parent):
return len(HEADER)
Expand All @@ -43,7 +44,7 @@ def data(self, index, role):
if role == Qt.DisplayRole:
return self.model.row(row)[column]
if role == Qt.ForegroundRole and self.model.row(row)[1] != self.model.row(row)[2]:
return QBrush(QColor(250, 20, 20)) # red
return QBrush(self.prefs.details_table_delta_foreground_color)
if role == Qt.FontRole and self.model.row(row)[1] != self.model.row(row)[2]:
font = QFont(self.model.view.font()) # or simply QFont()
font.setBold(True)
Expand Down Expand Up @@ -85,8 +86,6 @@ def setModel(self, model):
# The model needs to be set to set header stuff
hheader = self.horizontalHeader()
hheader.setHighlightSections(False)
hheader.setStretchLastSection(False)
hheader.resizeSection(0, 100)
hheader.setSectionResizeMode(0, QHeaderView.Stretch)
hheader.setSectionResizeMode(1, QHeaderView.Stretch)
vheader = self.verticalHeader()
Expand Down
5 changes: 5 additions & 0 deletions qt/dg.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
<file alias="plus">../images/plus_8.png</file>
<file alias="minus">../images/minus_8.png</file>
<file alias="search_clear_13">../qtlib/images/search_clear_13.png</file>
<file alias="exchange">../images/exchange_purple_upscaled.png</file>
<file alias="zoom_in">../images/old_zoom_in.png</file>
<file alias="zoom_out">../images/old_zoom_out.png</file>
<file alias="zoom_original">../images/old_zoom_original.png</file>
<file alias="zoom_best_fit">../images/old_zoom_best_fit.png</file>
</qresource>
glubsy marked this conversation as resolved.
Show resolved Hide resolved
</RCC>
7 changes: 2 additions & 5 deletions qt/me/details_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# http://www.gnu.org/licenses/gpl-3.0.html

from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView
from PyQt5.QtWidgets import QAbstractItemView

from hscommon.trans import trget
from ..details_dialog import DetailsDialog as DetailsDialogBase
Expand All @@ -19,11 +19,8 @@ def _setupUi(self):
self.setWindowTitle(tr("Details"))
self.resize(502, 295)
self.setMinimumSize(QSize(250, 250))
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.tableView = DetailsTable(self)
self.tableView.setAlternatingRowColors(True)
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tableView.setShowGrid(False)
self.verticalLayout.addWidget(self.tableView)
self.setWidget(self.tableView)
2 changes: 1 addition & 1 deletion qt/me/preferences_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _setupPreferenceWidgets(self):
self.widgetsVLayout.addWidget(self.debugModeBox)
self._setupBottomPart()

def _load(self, prefs, setchecked):
def _load(self, prefs, setchecked, section):
setchecked(self.tagTrackBox, prefs.scan_tag_track)
setchecked(self.tagArtistBox, prefs.scan_tag_artist)
setchecked(self.tagAlbumBox, prefs.scan_tag_album)
Expand Down
Loading