Merge pull request #269 from vkbo/gui_font_size

GUI Font Size Settings
This commit is contained in:
Veronica K. Berglyd Olsen
2020-05-30 22:09:39 +02:00
committed by GitHub
4 changed files with 40 additions and 16 deletions
+15 -12
View File
@@ -36,7 +36,6 @@ from time import time
from PyQt5.Qt import PYQT_VERSION_STR from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo
from PyQt5.QtWidgets import QErrorMessage
from nw.constants import nwFiles, nwUnicode from nw.constants import nwFiles, nwUnicode
from nw.common import splitVersionNumber, formatTimeStamp from nw.common import splitVersionNumber, formatTimeStamp
@@ -82,11 +81,12 @@ class Config:
self.confChanged = False self.confChanged = False
## General ## General
self.guiTheme = "default" self.guiTheme = "default"
self.guiSyntax = "default_light" self.guiSyntax = "default_light"
self.guiIcons = "typicons_grey_light" self.guiIcons = "typicons_grey_light"
self.guiDark = False self.guiDark = False
self.guiLang = "en" # Hardcoded for now self.guiLang = "en" # Hardcoded for now
self.guiFontSize = 12
## Sizes ## Sizes
self.winGeometry = [1100, 650] self.winGeometry = [1100, 650]
@@ -202,7 +202,6 @@ class Config:
"""Initialise the config class. The manual setting of confPath """Initialise the config class. The manual setting of confPath
and dataPath is mainly intended for the test suite. and dataPath is mainly intended for the test suite.
""" """
if confPath is None: if confPath is None:
confRoot = QStandardPaths.writableLocation(QStandardPaths.ConfigLocation) confRoot = QStandardPaths.writableLocation(QStandardPaths.ConfigLocation)
self.confPath = path.join(path.abspath(confRoot), self.appHandle) self.confPath = path.join(path.abspath(confRoot), self.appHandle)
@@ -318,6 +317,9 @@ class Config:
self.guiDark = self._parseLine( self.guiDark = self._parseLine(
cnfParse, cnfSec, "guidark", self.CNF_BOOL, self.guiDark cnfParse, cnfSec, "guidark", self.CNF_BOOL, self.guiDark
) )
self.guiFontSize = self._parseLine(
cnfParse, cnfSec, "guifontsize", self.CNF_INT, self.guiFontSize
)
## Sizes ## Sizes
cnfSec = "Sizes" cnfSec = "Sizes"
@@ -464,11 +466,12 @@ class Config:
## Main ## Main
cnfSec = "Main" cnfSec = "Main"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"timestamp", formatTimeStamp(time())) cnfParse.set(cnfSec,"timestamp", formatTimeStamp(time()))
cnfParse.set(cnfSec,"theme", str(self.guiTheme)) cnfParse.set(cnfSec,"theme", str(self.guiTheme))
cnfParse.set(cnfSec,"syntax", str(self.guiSyntax)) cnfParse.set(cnfSec,"syntax", str(self.guiSyntax))
cnfParse.set(cnfSec,"icons", str(self.guiIcons)) cnfParse.set(cnfSec,"icons", str(self.guiIcons))
cnfParse.set(cnfSec,"guidark", str(self.guiDark)) cnfParse.set(cnfSec,"guidark", str(self.guiDark))
cnfParse.set(cnfSec,"guifontsize", str(self.guiFontSize))
## Sizes ## Sizes
cnfSec = "Sizes" cnfSec = "Sizes"
+18 -2
View File
@@ -183,6 +183,19 @@ class GuiConfigEditGeneralTab(QWidget):
"This may improve the look of icons on dark themes." "This may improve the look of icons on dark themes."
) )
## Font Size
self.guiFontSize = QSpinBox(self)
self.guiFontSize.setMinimum(8)
self.guiFontSize.setMaximum(60)
self.guiFontSize.setSingleStep(1)
self.guiFontSize.setValue(self.mainConf.guiFontSize)
self.mainForm.addRow(
"Font size",
self.guiFontSize,
"Changing this requires restarting %s." % nw.__package__,
theUnit="pt"
)
# GUI Settings # GUI Settings
# ============ # ============
self.mainForm.addGroupLabel("GUI Settings") self.mainForm.addGroupLabel("GUI Settings")
@@ -266,6 +279,7 @@ class GuiConfigEditGeneralTab(QWidget):
guiTheme = self.selectTheme.currentData() guiTheme = self.selectTheme.currentData()
guiIcons = self.selectIcons.currentData() guiIcons = self.selectIcons.currentData()
guiDark = self.preferDarkIcons.isChecked() guiDark = self.preferDarkIcons.isChecked()
guiFontSize = self.guiFontSize.value()
showFullPath = self.showFullPath.isChecked() showFullPath = self.showFullPath.isChecked()
autoSaveDoc = self.autoSaveDoc.value() autoSaveDoc = self.autoSaveDoc.value()
autoSaveProj = self.autoSaveProj.value() autoSaveProj = self.autoSaveProj.value()
@@ -276,10 +290,12 @@ class GuiConfigEditGeneralTab(QWidget):
# Check if restart is needed # Check if restart is needed
needsRestart |= self.mainConf.guiTheme != guiTheme needsRestart |= self.mainConf.guiTheme != guiTheme
needsRestart |= self.mainConf.guiIcons != guiIcons needsRestart |= self.mainConf.guiIcons != guiIcons
needsRestart |= self.mainConf.guiFontSize != guiFontSize
self.mainConf.guiTheme = guiTheme self.mainConf.guiTheme = guiTheme
self.mainConf.guiIcons = guiIcons self.mainConf.guiIcons = guiIcons
self.mainConf.guiDark = guiDark self.mainConf.guiDark = guiDark
self.mainConf.guiFontSize = guiFontSize
self.mainConf.showFullPath = showFullPath self.mainConf.showFullPath = showFullPath
self.mainConf.autoSaveDoc = autoSaveDoc self.mainConf.autoSaveDoc = autoSaveDoc
self.mainConf.autoSaveProj = autoSaveProj self.mainConf.autoSaveProj = autoSaveProj
@@ -353,8 +369,8 @@ class GuiConfigEditLayoutTab(QWidget):
## Font Size ## Font Size
self.textStyleSize = QSpinBox(self) self.textStyleSize = QSpinBox(self)
self.textStyleSize.setMinimum(5) self.textStyleSize.setMinimum(8)
self.textStyleSize.setMaximum(120) self.textStyleSize.setMaximum(60)
self.textStyleSize.setSingleStep(1) self.textStyleSize.setSingleStep(1)
self.textStyleSize.setValue(self.mainConf.textSize) self.textStyleSize.setValue(self.mainConf.textSize)
self.mainForm.addRow( self.mainForm.addRow(
+6 -2
View File
@@ -111,6 +111,11 @@ class GuiTheme:
self.confFile = None self.confFile = None
self.cssFile = None self.cssFile = None
# Set Font Size and Theme
self.guiFont = qApp.font()
self.guiFont.setPointSizeF(self.mainConf.guiFontSize)
qApp.setFont(self.guiFont)
self.updateTheme() self.updateTheme()
self.theIcons.updateTheme() self.theIcons.updateTheme()
@@ -119,8 +124,7 @@ class GuiTheme:
self.loadDecoration = self.theIcons.loadDecoration self.loadDecoration = self.theIcons.loadDecoration
# Extract Other Info # Extract Other Info
self.guiDPI = qApp.primaryScreen().physicalDotsPerInch() self.guiDPI = qApp.primaryScreen().physicalDotsPerInch()
self.guiFont = qApp.font()
qMetric = QFontMetrics(self.guiFont) qMetric = QFontMetrics(self.guiFont)
self.fontPointSize = self.guiFont.pointSizeF() self.fontPointSize = self.guiFont.pointSizeF()
+1
View File
@@ -4,6 +4,7 @@ theme = default
syntax = default_light syntax = default_light
icons = typicons_grey_light icons = typicons_grey_light
guidark = False guidark = False
guifontsize = 12
[Sizes] [Sizes]
geometry = 1100, 650 geometry = 1100, 650