1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-12-21 10:59:03 +00:00

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
This commit is contained in:
glubsy 2020-07-15 05:25:47 +02:00
parent 95b8406c7b
commit 58c675d1fa
9 changed files with 39 additions and 23 deletions

BIN
images/exchange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

BIN
images/exchange_purple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/old_zoom_in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/old_zoom_out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -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.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>
</RCC>

View File

@ -90,23 +90,7 @@ class DetailsDialog(DetailsDialogBase):
# --- Override
def resizeEvent(self, event):
# HACK referenceViewer might be 1 pixel shorter in width
# due to the toolbar in the middle keeping the same width,
# so resizing in the GridLayout's engine leads to not enough space
# left for the panel on the right.
# This ensures same size while shrinking at least:
self.horizontalLayout.setColumnMinimumWidth(
0, self.selectedImageViewer.size().width())
self.horizontalLayout.setColumnMinimumWidth(
2, self.selectedImageViewer.size().width())
# This works when expanding but it's ugly:
if self.selectedImageViewer.size().width() > self.referenceImageViewer.size().width():
# print(f"""Before selected size: {self.selectedImageViewer.size()}\n""",
# f"""Before reference size: {self.referenceImageViewer.size()}""")
self.selectedImageViewer.resize(self.referenceImageViewer.size())
# print(f"""After selected size: {self.selectedImageViewer.size()}\n""",
# f"""After reference size: {self.referenceImageViewer.size()}""")
self.ensure_same_sizes()
if self.vController is None or not self.vController.bestFit:
return
# Only update the scaled down pixmaps
@ -122,8 +106,28 @@ class DetailsDialog(DetailsDialogBase):
# Windows seems to add a few pixels more to the table somehow
+ 5 if ISWINDOWS else 0)
DetailsDialogBase.show(self)
self.ensure_same_sizes()
self._update()
def ensure_same_sizes(self):
# HACK referenceViewer might be 1 pixel shorter in width
# due to the toolbar in the middle keeping the same width,
# so resizing in the GridLayout's engine leads to not enough space
# left for the panel on the right.
# This ensures same size while shrinking at least:
self.horizontalLayout.setColumnMinimumWidth(
0, self.selectedImageViewer.size().width())
self.horizontalLayout.setColumnMinimumWidth(
2, self.selectedImageViewer.size().width())
# This works when expanding but it's ugly:
if self.selectedImageViewer.size().width() > self.referenceImageViewer.size().width():
# print(f"""Before selected size: {self.selectedImageViewer.size()}\n""",
# f"""Before reference size: {self.referenceImageViewer.size()}""")
self.selectedImageViewer.resize(self.referenceImageViewer.size())
# print(f"""After selected size: {self.selectedImageViewer.size()}\n""",
# f"""After reference size: {self.referenceImageViewer.size()}""")
# model --> view
def refresh(self):
DetailsDialogBase.refresh(self)

View File

@ -10,6 +10,7 @@ from PyQt5.QtWidgets import (
QToolBar, QToolButton, QAction, QWidget, QScrollArea,
QApplication, QAbstractScrollArea, QStyle)
from hscommon.trans import trget
from hscommon.plat import ISLINUX
tr = trget("ui")
MAX_SCALE = 12.0
@ -21,7 +22,7 @@ def createActions(actions, target):
for name, shortcut, icon, desc, func in actions:
action = QAction(target)
if icon:
action.setIcon(QIcon.fromTheme(icon))
action.setIcon(icon)
if shortcut:
action.setShortcut(shortcut)
action.setText(desc)
@ -48,28 +49,32 @@ class ViewerToolBar(QToolBar):
(
"actionZoomIn",
QKeySequence.ZoomIn,
"zoom-in",
QIcon.fromTheme("zoom-in") if ISLINUX
else QIcon(QPixmap(":/" + "zoom_in")),
tr("Increase zoom"),
controller.zoomIn,
),
(
"actionZoomOut",
QKeySequence.ZoomOut,
"zoom-out",
QIcon.fromTheme("zoom-out") if ISLINUX
else QIcon(QPixmap(":/" + "zoom_out")),
tr("Decrease zoom"),
controller.zoomOut,
),
(
"actionNormalSize",
tr("Ctrl+/"),
"zoom-original",
QIcon.fromTheme("zoom-original") if ISLINUX
else QIcon(QPixmap(":/" + "zoom_original")),
tr("Normal size"),
controller.zoomNormalSize,
),
(
"actionBestFit",
tr("Ctrl+*"),
"zoom-best-fit",
QIcon.fromTheme("zoom-best-fit") if ISLINUX
else QIcon(QPixmap(":/" + "zoom_best_fit")),
tr("Best fit"),
controller.zoomBestFit,
)
@ -83,7 +88,9 @@ class ViewerToolBar(QToolBar):
self.buttonImgSwap.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.buttonImgSwap.setIcon(
QIcon.fromTheme('view-refresh',
self.style().standardIcon(QStyle.SP_BrowserReload)))
self.style().standardIcon(QStyle.SP_BrowserReload))
if ISLINUX
else QIcon(QPixmap(":/" + "exchange")))
self.buttonImgSwap.setText('Swap images')
self.buttonImgSwap.setToolTip('Swap images')
self.buttonImgSwap.pressed.connect(self.controller.swapImages)