Remove computed GUI scaling

This commit is contained in:
Veronica Berglyd Olsen
2025-01-12 15:39:10 +01:00
parent a1d94d63a3
commit 60130f067b
3 changed files with 15 additions and 86 deletions
+15 -20
View File
@@ -115,7 +115,6 @@ class Config:
self.guiTheme = "default" # GUI theme
self.guiSyntax = "default_light" # Syntax theme
self.guiFont = QFont() # Main GUI font
self.guiScale = 1.0 # Set automatically by Theme class
self.hideVScroll = False # Hide vertical scroll bars on main widgets
self.hideHScroll = False # Hide horizontal scroll bars on main widgets
self.lastNotes = "0x0" # The latest release notes that have been shown
@@ -272,27 +271,27 @@ class Config:
@property
def mainWinSize(self) -> list[int]:
return [int(x*self.guiScale) for x in self._mainWinSize]
return self._mainWinSize
@property
def welcomeWinSize(self) -> list[int]:
return [int(x*self.guiScale) for x in self._welcomeSize]
return self._welcomeSize
@property
def preferencesWinSize(self) -> list[int]:
return [int(x*self.guiScale) for x in self._prefsWinSize]
return self._prefsWinSize
@property
def mainPanePos(self) -> list[int]:
return [int(x*self.guiScale) for x in self._mainPanePos]
return self._mainPanePos
@property
def viewPanePos(self) -> list[int]:
return [int(x*self.guiScale) for x in self._viewPanePos]
return self._viewPanePos
@property
def outlinePanePos(self) -> list[int]:
return [int(x*self.guiScale) for x in self._outlnPanePos]
return self._outlnPanePos
##
# Getters
@@ -323,8 +322,6 @@ class Config:
adjust it a bit, and we don't want the main window to shrink or
grow each time the app is opened.
"""
width = int(width/self.guiScale)
height = int(height/self.guiScale)
if abs(self._mainWinSize[0] - width) > 5:
self._mainWinSize[0] = width
if abs(self._mainWinSize[1] - height) > 5:
@@ -333,29 +330,27 @@ class Config:
def setWelcomeWinSize(self, width: int, height: int) -> None:
"""Set the size of the Preferences dialog window."""
self._welcomeSize[0] = int(width/self.guiScale)
self._welcomeSize[1] = int(height/self.guiScale)
self._welcomeSize = [width, height]
return
def setPreferencesWinSize(self, width: int, height: int) -> None:
"""Set the size of the Preferences dialog window."""
self._prefsWinSize[0] = int(width/self.guiScale)
self._prefsWinSize[1] = int(height/self.guiScale)
self._prefsWinSize = [width, height]
return
def setMainPanePos(self, pos: list[int]) -> None:
"""Set the position of the main GUI splitter."""
self._mainPanePos = [int(x/self.guiScale) for x in pos]
self._mainPanePos = pos
return
def setViewPanePos(self, pos: list[int]) -> None:
"""Set the position of the viewer meta data splitter."""
self._viewPanePos = [int(x/self.guiScale) for x in pos]
self._viewPanePos = pos
return
def setOutlinePanePos(self, pos: list[int]) -> None:
"""Set the position of the outline details splitter."""
self._outlnPanePos = [int(x/self.guiScale) for x in pos]
self._outlnPanePos = pos
return
def setLastPath(self, key: str, path: str | Path) -> None:
@@ -427,12 +422,12 @@ class Config:
##
def pxInt(self, value: int) -> int:
"""Scale fixed gui sizes by the screen scale factor."""
return int(value*self.guiScale)
"""Deprecated. Do not use."""
return value
def rpxInt(self, value: int) -> int:
"""Un-scale fixed gui sizes by the screen scale factor."""
return int(value/self.guiScale)
"""Deprecated. Do not use."""
return value
def homePath(self) -> Path:
"""The user's home folder."""
-7
View File
@@ -143,13 +143,6 @@ class GuiTheme:
self.getHeaderDecoration = self.iconCache.getHeaderDecoration
self.getHeaderDecorationNarrow = self.iconCache.getHeaderDecorationNarrow
# Extract Other Info
self.guiDPI = QApplication.primaryScreen().logicalDotsPerInchX()
self.guiScale = QApplication.primaryScreen().logicalDotsPerInchX()/96.0
CONFIG.guiScale = self.guiScale
logger.debug("GUI DPI: %.1f", self.guiDPI)
logger.debug("GUI Scale: %.2f", self.guiScale)
# Fonts
self.guiFont = QApplication.font()
self.guiFontB = QApplication.font()
-59
View File
@@ -245,35 +245,13 @@ def testBaseConfig_SettersGetters(fncPath):
tstConf = Config()
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
# GUI Scaling
# ===========
tstConf.guiScale = 1.0
assert tstConf.pxInt(10) == 10
assert tstConf.pxInt(13) == 13
assert tstConf.rpxInt(10) == 10
assert tstConf.rpxInt(13) == 13
tstConf.guiScale = 2.0
assert tstConf.pxInt(10) == 20
assert tstConf.pxInt(13) == 26
assert tstConf.rpxInt(10) == 5
assert tstConf.rpxInt(13) == 6
# Setter + Getter Combos
# ======================
# Window Size
tstConf.guiScale = 1.0
tstConf.setMainWinSize(1205, 655)
assert tstConf.mainWinSize == [1200, 650]
tstConf.guiScale = 2.0
tstConf.setMainWinSize(70, 70)
assert tstConf.mainWinSize == [70, 70]
assert tstConf._mainWinSize == [35, 35]
tstConf.guiScale = 1.0
tstConf.setMainWinSize(70, 70)
assert tstConf.mainWinSize == [70, 70]
assert tstConf._mainWinSize == [70, 70]
@@ -281,12 +259,6 @@ def testBaseConfig_SettersGetters(fncPath):
tstConf.setMainWinSize(1200, 650)
# Welcome Window Size
tstConf.guiScale = 2.0
tstConf.setWelcomeWinSize(70, 70)
assert tstConf.welcomeWinSize == [70, 70]
assert tstConf._welcomeSize == [35, 35]
tstConf.guiScale = 1.0
tstConf.setWelcomeWinSize(70, 70)
assert tstConf.welcomeWinSize == [70, 70]
assert tstConf._welcomeSize == [70, 70]
@@ -294,12 +266,6 @@ def testBaseConfig_SettersGetters(fncPath):
tstConf.setWelcomeWinSize(800, 500)
# Preferences Size
tstConf.guiScale = 2.0
tstConf.setPreferencesWinSize(70, 70)
assert tstConf.preferencesWinSize == [70, 70]
assert tstConf._prefsWinSize == [35, 35]
tstConf.guiScale = 1.0
tstConf.setPreferencesWinSize(70, 70)
assert tstConf.preferencesWinSize == [70, 70]
assert tstConf._prefsWinSize == [70, 70]
@@ -307,12 +273,6 @@ def testBaseConfig_SettersGetters(fncPath):
tstConf.setPreferencesWinSize(700, 615)
# Main Pane Splitter
tstConf.guiScale = 2.0
tstConf.setMainPanePos([200, 700])
assert tstConf.mainPanePos == [200, 700]
assert tstConf._mainPanePos == [100, 350]
tstConf.guiScale = 1.0
tstConf.setMainPanePos([200, 700])
assert tstConf.mainPanePos == [200, 700]
assert tstConf._mainPanePos == [200, 700]
@@ -320,12 +280,6 @@ def testBaseConfig_SettersGetters(fncPath):
tstConf.setMainPanePos([300, 800])
# View Pane Splitter
tstConf.guiScale = 2.0
tstConf.setViewPanePos([400, 250])
assert tstConf.viewPanePos == [400, 250]
assert tstConf._viewPanePos == [200, 125]
tstConf.guiScale = 1.0
tstConf.setViewPanePos([400, 250])
assert tstConf.viewPanePos == [400, 250]
assert tstConf._viewPanePos == [400, 250]
@@ -333,12 +287,6 @@ def testBaseConfig_SettersGetters(fncPath):
tstConf.setViewPanePos([500, 150])
# Outline Pane Splitter
tstConf.guiScale = 2.0
tstConf.setOutlinePanePos([400, 250])
assert tstConf.outlinePanePos == [400, 250]
assert tstConf._outlnPanePos == [200, 125]
tstConf.guiScale = 1.0
tstConf.setOutlinePanePos([400, 250])
assert tstConf.outlinePanePos == [400, 250]
assert tstConf._outlnPanePos == [400, 250]
@@ -348,18 +296,11 @@ def testBaseConfig_SettersGetters(fncPath):
# Getters Only
# ============
tstConf.guiScale = 1.0
assert tstConf.getTextWidth(False) == 700
assert tstConf.getTextWidth(True) == 800
assert tstConf.getTextMargin() == 40
assert tstConf.getTabWidth() == 40
tstConf.guiScale = 2.0
assert tstConf.getTextWidth(False) == 1400
assert tstConf.getTextWidth(True) == 1600
assert tstConf.getTextMargin() == 80
assert tstConf.getTabWidth() == 80
@pytest.mark.base
def testBaseConfig_Internal(monkeypatch, fncPath):