1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-03-12 03:31:37 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
efc99eee96 Merge pull request #978 from glubsy/fix_zoom_scrollbar
Fix image viewer scrollbar zoom
2022-03-14 20:43:40 -05:00
glubsy
ff7733bb73 Fix image viewer
When zooming in or out, the value computed might be a float instead
of an int, which is what the QScrollBar expect for its setValue method.
Simply casting to int should be enough here.
2022-03-12 22:36:17 +01:00
4b2fbe87ea Default to English on unsupported system language Fix #976
- Add check for supported language to system locale detection
- Fall-back to English when not a supported locale
2022-03-12 04:36:13 -06:00
2 changed files with 33 additions and 13 deletions

View File

@@ -150,7 +150,9 @@ def install_gettext_trans_under_qt(base_folder, lang=None):
if not lang:
lang = str(QLocale.system().name())[:2]
localename = get_locale_name(lang)
if localename is not None:
if localename is None:
lang = "en"
localename = get_locale_name(lang)
try:
locale.setlocale(locale.LC_ALL, localename)
except locale.Error:

View File

@@ -1041,26 +1041,44 @@ class ScrollAreaImageViewer(QScrollArea):
"""After scaling, no mouse position, default to center."""
# scrollBar.setMaximum(scrollBar.maximum() - scrollBar.minimum() + scrollBar.pageStep())
self._horizontalScrollBar.setValue(
int(factor * self._horizontalScrollBar.value() + ((factor - 1) * self._horizontalScrollBar.pageStep() / 2))
int(
factor * self._horizontalScrollBar.value()
+ ((factor - 1) * self._horizontalScrollBar.pageStep() / 2)
)
)
self._verticalScrollBar.setValue(
int(factor * self._verticalScrollBar.value() + ((factor - 1) * self._verticalScrollBar.pageStep() / 2))
int(
factor * self._verticalScrollBar.value()
+ ((factor - 1) * self._verticalScrollBar.pageStep() / 2)
)
)
def adjustScrollBarsScaled(self, delta):
"""After scaling with the mouse, update relative to mouse position."""
self._horizontalScrollBar.setValue(self._horizontalScrollBar.value() + delta.x())
self._verticalScrollBar.setValue(self._verticalScrollBar.value() + delta.y())
self._horizontalScrollBar.setValue(
int(self._horizontalScrollBar.value() + delta.x())
)
self._verticalScrollBar.setValue(
int(self._verticalScrollBar.value() + delta.y())
)
def adjustScrollBarsAuto(self):
"""After panning, update accordingly."""
self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() - self._mousePanningDelta.x())
self.verticalScrollBar().setValue(self.verticalScrollBar().value() - self._mousePanningDelta.y())
self.horizontalScrollBar().setValue(
int(self.horizontalScrollBar().value() - self._mousePanningDelta.x())
)
self.verticalScrollBar().setValue(
int(self.verticalScrollBar().value() - self._mousePanningDelta.y())
)
def adjustScrollBarCentered(self):
"""Just center in the middle."""
self._horizontalScrollBar.setValue(int(self._horizontalScrollBar.maximum() / 2))
self._verticalScrollBar.setValue(int(self._verticalScrollBar.maximum() / 2))
self._horizontalScrollBar.setValue(
int(self._horizontalScrollBar.maximum() / 2)
)
self._verticalScrollBar.setValue(
int(self._verticalScrollBar.maximum() / 2)
)
def resetCenter(self):
"""Resets origin"""