1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 06:37:17 +00:00

Add preference to turn off scrollbars in viewers

Refactor preference Display page to only include PE specific preferences in the PE mode.
This commit is contained in:
glubsy
2020-07-30 03:13:58 +02:00
parent eab5003e61
commit fa54e93236
5 changed files with 63 additions and 33 deletions

View File

@@ -20,6 +20,7 @@ tr = trget("ui")
class DetailsDialog(DetailsDialogBase):
def __init__(self, parent, app):
self.vController = None
self.app = app
super().__init__(parent, app)
def _setupUi(self):

View File

@@ -894,7 +894,7 @@ class ScrollAreaImageViewer(QScrollArea):
self._dragConnection = None
self._wheelConnection = None
self._instance_name = name
self.wantScrollBars = True
self.prefs = parent.app.prefs
self.bestFit = True
self.controller = None
self.label = ScalablePixmap(self)
@@ -906,11 +906,13 @@ class ScrollAreaImageViewer(QScrollArea):
self.setAlignment(Qt.AlignCenter)
self._verticalScrollBar = self.verticalScrollBar()
self._horizontalScrollBar = self.horizontalScrollBar()
if self.wantScrollBars:
if self.prefs.details_dialog_viewers_show_scrollbars:
self.toggleScrollBars()
else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setWidget(self.label)
self.setVisible(True)
@@ -918,7 +920,7 @@ class ScrollAreaImageViewer(QScrollArea):
return f'{self._instance_name}'
def toggleScrollBars(self, forceOn=False):
if not self.wantScrollBars:
if not self.prefs.details_dialog_viewers_show_scrollbars:
return
# Ensure that it's off on the first run
if self.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded:
@@ -1135,7 +1137,7 @@ class GraphicsViewViewer(QGraphicsView):
self._dragConnection = None
self._wheelConnection = None
self._instance_name = name
self.wantScrollBars = True
self.prefs = parent.app.prefs
self.bestFit = True
self.controller = None
self._centerPoint = QPointF()
@@ -1153,7 +1155,7 @@ class GraphicsViewViewer(QGraphicsView):
self._verticalScrollBar = self.verticalScrollBar()
self.ignore_signal = False
if self.wantScrollBars:
if self.prefs.details_dialog_viewers_show_scrollbars:
self.toggleScrollBars()
else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
@@ -1189,7 +1191,7 @@ class GraphicsViewViewer(QGraphicsView):
self.controller.onHScrollBarChanged, Qt.UniqueConnection)
def toggleScrollBars(self, forceOn=False):
if not self.wantScrollBars:
if not self.prefs.details_dialog_viewers_show_scrollbars:
return
# Ensure that it's off on the first run
if self.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded:

View File

@@ -6,6 +6,7 @@
from PyQt5.QtWidgets import QLabel
from hscommon.trans import trget
from hscommon.plat import ISLINUX
from qtlib.radio_box import RadioBox
from core.scanner import ScanType
from core.app import AppMode
@@ -45,6 +46,26 @@ class PreferencesDialog(PreferencesDialogBase):
self.widgetsVLayout.addWidget(self.cacheTypeRadio)
self._setupBottomPart()
def _setupDisplayPage(self):
super()._setupDisplayPage()
self._setupAddCheckbox("details_dialog_override_theme_icons",
tr("Override theme icons in viewer toolbar"))
self.details_dialog_override_theme_icons.setToolTip(
tr("Use our own internal icons instead of those provided by the theme engine"))
# Prevent changing this on platforms where themes are unpredictable
self.details_dialog_override_theme_icons.setEnabled(False if not ISLINUX else True)
# Insert this right after the vertical title bar option
index = self.displayVLayout.indexOf(self.details_dialog_vertical_titlebar)
self.displayVLayout.insertWidget(
index + 1, self.details_dialog_override_theme_icons)
self._setupAddCheckbox("details_dialog_viewers_show_scrollbars",
tr("Show scrollbars in image viewers"))
self.details_dialog_viewers_show_scrollbars.setToolTip(
tr("When the image displayed doesn't fit the viewport, \
show scrollbars to span the view around"))
self.displayVLayout.insertWidget(
index + 2, self.details_dialog_viewers_show_scrollbars)
def _load(self, prefs, setchecked, section):
setchecked(self.matchScaledBox, prefs.match_scaled)
self.cacheTypeRadio.selected_index = (
@@ -55,9 +76,17 @@ class PreferencesDialog(PreferencesDialogBase):
scan_type = prefs.get_scan_type(AppMode.Picture)
fuzzy_scan = scan_type == ScanType.FuzzyBlock
self.filterHardnessSlider.setEnabled(fuzzy_scan)
setchecked(self.details_dialog_override_theme_icons,
prefs.details_dialog_override_theme_icons)
setchecked(self.details_dialog_viewers_show_scrollbars,
prefs.details_dialog_viewers_show_scrollbars)
def _save(self, prefs, ischecked):
prefs.match_scaled = ischecked(self.matchScaledBox)
prefs.picture_cache_type = (
"shelve" if self.cacheTypeRadio.selected_index == 1 else "sqlite"
)
prefs.details_dialog_override_theme_icons =\
ischecked(self.details_dialog_override_theme_icons)
prefs.details_dialog_viewers_show_scrollbars =\
ischecked(self.details_dialog_viewers_show_scrollbars)