diff --git a/novelwriter/extensions/switch.py b/novelwriter/extensions/switch.py index ab32ddbb..5d020385 100644 --- a/novelwriter/extensions/switch.py +++ b/novelwriter/extensions/switch.py @@ -27,20 +27,20 @@ from PyQt5.QtGui import QMouseEvent, QPainter, QPaintEvent, QResizeEvent from PyQt5.QtCore import QEvent, QPropertyAnimation, Qt, pyqtProperty from PyQt5.QtWidgets import QAbstractButton, QSizePolicy, QWidget -from novelwriter import CONFIG +from novelwriter import CONFIG, SHARED class NSwitch(QAbstractButton): __slots__ = ("_xW", "_xH", "_xR", "_rB", "_rH", "_rR", "_offset") - def __init__(self, parent: QWidget | None = None, height: int = 0) -> None: + def __init__(self, parent: QWidget, height: int = 0) -> None: super().__init__(parent=parent) - self._xH = height or CONFIG.pxInt(20) + self._xH = height or SHARED.theme.baseButtonHeight self._xW = 2*self._xH self._xR = int(self._xH*0.5) - self._rB = int(CONFIG.guiScale*2) + self._rB = CONFIG.pxInt(2) self._rH = self._xH - 2*self._rB self._rR = self._xR - self._rB diff --git a/novelwriter/gui/sidebar.py b/novelwriter/gui/sidebar.py index e9129ef6..2030985e 100644 --- a/novelwriter/gui/sidebar.py +++ b/novelwriter/gui/sidebar.py @@ -54,7 +54,7 @@ class GuiSideBar(QWidget): self.mainGui = mainGui - iPx = CONFIG.pxInt(24) + iPx = int(1.2*SHARED.theme.baseButtonHeight) self.setContentsMargins(0, 0, 0, 0) self.installEventFilter(StatusTipFilter(mainGui)) diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 7a841ad6..3d530c4c 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -159,6 +159,7 @@ class GuiTheme: self.fontPointSize = self.guiFont.pointSizeF() self.fontPixelSize = int(round(qMetric.height())) self.baseIconSize = int(round(qMetric.ascent())) + self.baseButtonHeight = int(round(1.35*qMetric.ascent())) self.textNHeight = qMetric.boundingRect("N").height() self.textNWidth = qMetric.boundingRect("N").width() @@ -171,6 +172,7 @@ class GuiTheme: logger.debug("GUI Font Point Size: %.2f", self.fontPointSize) logger.debug("GUI Font Pixel Size: %d", self.fontPixelSize) logger.debug("GUI Base Icon Size: %d", self.baseIconSize) + logger.debug("GUI Base Button Height: %d", self.baseButtonHeight) logger.debug("Text 'N' Height: %d", self.textNHeight) logger.debug("Text 'N' Width: %d", self.textNWidth) diff --git a/novelwriter/tools/lipsum.py b/novelwriter/tools/lipsum.py index 617c81ca..06c4970d 100644 --- a/novelwriter/tools/lipsum.py +++ b/novelwriter/tools/lipsum.py @@ -53,12 +53,13 @@ class GuiLipsum(QDialog): self.setWindowTitle(self.tr("Insert Placeholder Text")) + vSp = CONFIG.pxInt(4) + nPx = CONFIG.pxInt(64) + self.innerBox = QHBoxLayout() self.innerBox.setSpacing(CONFIG.pxInt(16)) # Icon - nPx = CONFIG.pxInt(64) - vSp = CONFIG.pxInt(4) self.docIcon = QLabel() self.docIcon.setPixmap(SHARED.theme.getPixmap("proj_document", (nPx, nPx))) @@ -78,7 +79,7 @@ class GuiLipsum(QDialog): self.paraCount.setValue(5) self.randLabel = QLabel(self.tr("Randomise order")) - self.randSwitch = NSwitch() + self.randSwitch = NSwitch(self) self.formBox = QGridLayout() self.formBox.addWidget(self.headLabel, 0, 0, 1, 2, Qt.AlignLeft) diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py index 95f737e2..8dc36891 100644 --- a/novelwriter/tools/writingstats.py +++ b/novelwriter/tools/writingstats.py @@ -187,43 +187,43 @@ class GuiWritingStats(QDialog): self.infoForm.setRowStretch(6, 1) # Filter Options - sPx = SHARED.theme.baseIconSize + iPx = SHARED.theme.baseIconSize self.filterBox = QGroupBox(self.tr("Filters"), self) self.filterForm = QGridLayout(self) self.filterBox.setLayout(self.filterForm) - self.incNovel = NSwitch(self, height=sPx) + self.incNovel = NSwitch(self, height=iPx) self.incNovel.setChecked( pOptions.getBool("GuiWritingStats", "incNovel", True) ) self.incNovel.clicked.connect(self._updateListBox) - self.incNotes = NSwitch(self, height=sPx) + self.incNotes = NSwitch(self, height=iPx) self.incNotes.setChecked( pOptions.getBool("GuiWritingStats", "incNotes", True) ) self.incNotes.clicked.connect(self._updateListBox) - self.hideZeros = NSwitch(self, height=sPx) + self.hideZeros = NSwitch(self, height=iPx) self.hideZeros.setChecked( pOptions.getBool("GuiWritingStats", "hideZeros", True) ) self.hideZeros.clicked.connect(self._updateListBox) - self.hideNegative = NSwitch(self, height=sPx) + self.hideNegative = NSwitch(self, height=iPx) self.hideNegative.setChecked( pOptions.getBool("GuiWritingStats", "hideNegative", False) ) self.hideNegative.clicked.connect(self._updateListBox) - self.groupByDay = NSwitch(self, height=sPx) + self.groupByDay = NSwitch(self, height=iPx) self.groupByDay.setChecked( pOptions.getBool("GuiWritingStats", "groupByDay", False) ) self.groupByDay.clicked.connect(self._updateListBox) - self.showIdleTime = NSwitch(self, height=sPx) + self.showIdleTime = NSwitch(self, height=iPx) self.showIdleTime.setChecked( pOptions.getBool("GuiWritingStats", "showIdleTime", False) )