Make sure all tool buttons scale to base icon size

This commit is contained in:
Veronica Berglyd Olsen
2024-04-01 17:48:12 +02:00
parent c000307f14
commit 1eafa1c8b6
5 changed files with 48 additions and 17 deletions
+9 -1
View File
@@ -27,7 +27,7 @@ from __future__ import annotations
import logging
from PyQt5.QtGui import QCloseEvent, QFont, QKeyEvent, QKeySequence
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt5.QtCore import QSize, Qt, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import (
QAbstractButton, QCompleter, QDialog, QDialogButtonBox, QFileDialog,
QFontDialog, QHBoxLayout, QLineEdit, QPushButton, QToolButton, QVBoxLayout,
@@ -133,6 +133,8 @@ class GuiPreferences(QDialog):
"""Build the settings form."""
section = 0
minWidth = CONFIG.pxInt(200)
iPx = SHARED.theme.baseIconSize
iconSize = QSize(iPx, iPx)
mIcon = SHARED.theme.getIcon("more")
# Label
@@ -177,6 +179,7 @@ class GuiPreferences(QDialog):
self.guiFont.setText(CONFIG.guiFont)
self.guiFontButton = QToolButton(self)
self.guiFontButton.setIcon(mIcon)
self.guiFontButton.setIconSize(iconSize)
self.guiFontButton.clicked.connect(self._selectGuiFont)
self.mainForm.addRow(
self.tr("Application font family"), self.guiFont,
@@ -238,6 +241,7 @@ class GuiPreferences(QDialog):
self.textFont.setText(CONFIG.textFont)
self.textFontButton = QToolButton(self)
self.textFontButton.setIcon(mIcon)
self.textFontButton.setIconSize(iconSize)
self.textFontButton.clicked.connect(self._selectTextFont)
self.mainForm.addRow(
self.tr("Document font family"), self.textFont,
@@ -679,6 +683,7 @@ class GuiPreferences(QDialog):
self.quoteSym["SO"].setText(CONFIG.fmtSQuoteOpen)
self.btnSingleStyleO = QToolButton(self)
self.btnSingleStyleO.setIcon(mIcon)
self.btnSingleStyleO.setIconSize(iconSize)
self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO"))
self.mainForm.addRow(
self.tr("Single quote open style"), self.quoteSym["SO"],
@@ -694,6 +699,7 @@ class GuiPreferences(QDialog):
self.quoteSym["SC"].setText(CONFIG.fmtSQuoteClose)
self.btnSingleStyleC = QToolButton(self)
self.btnSingleStyleC.setIcon(mIcon)
self.btnSingleStyleC.setIconSize(iconSize)
self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC"))
self.mainForm.addRow(
self.tr("Single quote close style"), self.quoteSym["SC"],
@@ -710,6 +716,7 @@ class GuiPreferences(QDialog):
self.quoteSym["DO"].setText(CONFIG.fmtDQuoteOpen)
self.btnDoubleStyleO = QToolButton(self)
self.btnDoubleStyleO.setIcon(mIcon)
self.btnDoubleStyleO.setIconSize(iconSize)
self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO"))
self.mainForm.addRow(
self.tr("Double quote open style"), self.quoteSym["DO"],
@@ -725,6 +732,7 @@ class GuiPreferences(QDialog):
self.quoteSym["DC"].setText(CONFIG.fmtDQuoteClose)
self.btnDoubleStyleC = QToolButton(self)
self.btnDoubleStyleC.setIcon(mIcon)
self.btnDoubleStyleC.setIconSize(iconSize)
self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC"))
self.mainForm.addRow(
self.tr("Double quote close style"), self.quoteSym["DC"],
+3 -2
View File
@@ -851,6 +851,7 @@ class GuiDocViewFooter(QWidget):
iPx = SHARED.theme.baseIconSize
hSp = CONFIG.pxInt(4)
mPx = CONFIG.pxInt(4)
iconSize = QSize(iPx, iPx)
# Main Widget Settings
self.setContentsMargins(0, 0, 0, 0)
@@ -867,7 +868,7 @@ class GuiDocViewFooter(QWidget):
self.showComments.setCheckable(True)
self.showComments.setChecked(CONFIG.viewComments)
self.showComments.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
self.showComments.setIconSize(QSize(iPx, iPx))
self.showComments.setIconSize(iconSize)
self.showComments.toggled.connect(self._doToggleComments)
self.showComments.setToolTip(self.tr("Show Comments"))
@@ -877,7 +878,7 @@ class GuiDocViewFooter(QWidget):
self.showSynopsis.setCheckable(True)
self.showSynopsis.setChecked(CONFIG.viewSynopsis)
self.showSynopsis.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
self.showSynopsis.setIconSize(QSize(iPx, iPx))
self.showSynopsis.setIconSize(iconSize)
self.showSynopsis.toggled.connect(self._doToggleSynopsis)
self.showSynopsis.setToolTip(self.tr("Show Synopsis Comments"))
+2 -2
View File
@@ -206,11 +206,11 @@ class GuiOutlineToolBar(QToolBar):
logger.debug("Create: GuiOutlineToolBar")
iPx = CONFIG.pxInt(22)
bPx = SHARED.theme.baseButtonHeight
mPx = CONFIG.pxInt(12)
self.setMovable(False)
self.setIconSize(QSize(iPx, iPx))
self.setIconSize(QSize(bPx, bPx))
self.setContentsMargins(0, 0, 0, 0)
stretch = QWidget(self)
+30 -12
View File
@@ -318,6 +318,7 @@ class _FilterTab(NFixedPage):
# Tree Settings
iPx = SHARED.theme.baseIconSize
cMg = CONFIG.pxInt(6)
iconSize = QSize(iPx, iPx)
# Tree Widget
self.optTree = QTreeWidget(self)
@@ -347,16 +348,19 @@ class _FilterTab(NFixedPage):
self.includedButton = QToolButton(self)
self.includedButton.setToolTip(self.tr("Always included"))
self.includedButton.setIcon(self._statusFlags[self.F_INCLUDED])
self.includedButton.setIconSize(iconSize)
self.includedButton.clicked.connect(lambda: self._setSelectedMode(self.F_INCLUDED))
self.excludedButton = QToolButton(self)
self.excludedButton.setToolTip(self.tr("Always excluded"))
self.excludedButton.setIcon(self._statusFlags[self.F_EXCLUDED])
self.excludedButton.setIconSize(iconSize)
self.excludedButton.clicked.connect(lambda: self._setSelectedMode(self.F_EXCLUDED))
self.resetButton = QToolButton(self)
self.resetButton.setToolTip(self.tr("Reset to default"))
self.resetButton.setIcon(SHARED.theme.getIcon("revert"))
self.resetButton.setIconSize(iconSize)
self.resetButton.clicked.connect(lambda: self._setSelectedMode(self.F_FILTERED))
self.modeBox = QHBoxLayout()
@@ -597,6 +601,9 @@ class _HeadingsTab(NScrollablePage):
sSp = CONFIG.pxInt(16)
vSp = CONFIG.pxInt(12)
bSp = CONFIG.pxInt(6)
iconSize = QSize(iPx, iPx)
editIcon = SHARED.theme.getIcon("edit")
trHide = self.tr("Hide")
# Format Boxes
# ============
@@ -608,9 +615,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtTitle = QLineEdit("", self)
self.fmtTitle.setReadOnly(True)
self.btnTitle = QToolButton(self)
self.btnTitle.setIcon(SHARED.theme.getIcon("edit"))
self.btnTitle.setIcon(editIcon)
self.btnTitle.setIconSize(iconSize)
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
self.hdeTitle = QLabel(self.tr("Hide"), self)
self.hdeTitle = QLabel(trHide, self)
self.hdeTitle.setIndent(bSp)
self.swtTitle = NSwitch(self, height=iPx)
@@ -625,9 +633,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtChapter = QLineEdit("", self)
self.fmtChapter.setReadOnly(True)
self.btnChapter = QToolButton(self)
self.btnChapter.setIcon(SHARED.theme.getIcon("edit"))
self.btnChapter.setIcon(editIcon)
self.btnChapter.setIconSize(iconSize)
self.btnChapter.clicked.connect(lambda: self._editHeading(self.EDIT_CHAPTER))
self.hdeChapter = QLabel(self.tr("Hide"), self)
self.hdeChapter = QLabel(trHide, self)
self.hdeChapter.setIndent(bSp)
self.swtChapter = NSwitch(self, height=iPx)
@@ -642,9 +651,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtUnnumbered = QLineEdit("", self)
self.fmtUnnumbered.setReadOnly(True)
self.btnUnnumbered = QToolButton(self)
self.btnUnnumbered.setIcon(SHARED.theme.getIcon("edit"))
self.btnUnnumbered.setIcon(editIcon)
self.btnUnnumbered.setIconSize(iconSize)
self.btnUnnumbered.clicked.connect(lambda: self._editHeading(self.EDIT_UNNUM))
self.hdeUnnumbered = QLabel(self.tr("Hide"), self)
self.hdeUnnumbered = QLabel(trHide, self)
self.hdeUnnumbered.setIndent(bSp)
self.swtUnnumbered = NSwitch(self, height=iPx)
@@ -659,9 +669,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtScene = QLineEdit("", self)
self.fmtScene.setReadOnly(True)
self.btnScene = QToolButton(self)
self.btnScene.setIcon(SHARED.theme.getIcon("edit"))
self.btnScene.setIcon(editIcon)
self.btnScene.setIconSize(iconSize)
self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE))
self.hdeScene = QLabel(self.tr("Hide"), self)
self.hdeScene = QLabel(trHide, self)
self.hdeScene.setIndent(bSp)
self.swtScene = NSwitch(self, height=iPx)
@@ -676,9 +687,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtHScene = QLineEdit("", self)
self.fmtHScene.setReadOnly(True)
self.btnHScene = QToolButton(self)
self.btnHScene.setIcon(SHARED.theme.getIcon("edit"))
self.btnHScene.setIcon(editIcon)
self.btnHScene.setIconSize(iconSize)
self.btnHScene.clicked.connect(lambda: self._editHeading(self.EDIT_HSCENE))
self.hdeHScene = QLabel(self.tr("Hide"), self)
self.hdeHScene = QLabel(trHide, self)
self.hdeHScene.setIndent(bSp)
self.swtHScene = NSwitch(self, height=iPx)
@@ -693,9 +705,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtSection = QLineEdit("", self)
self.fmtSection.setReadOnly(True)
self.btnSection = QToolButton(self)
self.btnSection.setIcon(SHARED.theme.getIcon("edit"))
self.btnSection.setIcon(editIcon)
self.btnSection.setIconSize(iconSize)
self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION))
self.hdeSection = QLabel(self.tr("Hide"), self)
self.hdeSection = QLabel(trHide, self)
self.hdeSection.setIndent(bSp)
self.swtSection = NSwitch(self, height=iPx)
@@ -983,6 +996,7 @@ class _ContentTab(NScrollableForm):
self._build = build
iPx = SHARED.theme.baseIconSize
iconSize = QSize(iPx, iPx)
# Text Content
self.incBodyText = NSwitch(self, height=iPx)
@@ -1001,6 +1015,7 @@ class _ContentTab(NScrollableForm):
self.ignoredKeywordsButton = QToolButton(self)
self.ignoredKeywordsButton.setIcon(SHARED.theme.getIcon("add"))
self.ignoredKeywordsButton.setIconSize(iconSize)
self.ignoredKeywordsButton.setMenu(self.mnKeywords)
self.ignoredKeywordsButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
@@ -1339,6 +1354,7 @@ class _OutputTab(NScrollableForm):
iPx = SHARED.theme.baseIconSize
spW = 6*SHARED.theme.textNWidth
iconSize = QSize(iPx, iPx)
# Open Document
self.addGroupLabel(self._build.getLabel("odt"))
@@ -1350,6 +1366,7 @@ class _OutputTab(NScrollableForm):
self.odtPageHeader.setMinimumWidth(CONFIG.pxInt(200))
self.btnPageHeader = QToolButton(self)
self.btnPageHeader.setIcon(SHARED.theme.getIcon("revert"))
self.btnPageHeader.setIconSize(iconSize)
self.btnPageHeader.clicked.connect(self._resetPageHeader)
self.addRow(
self._build.getLabel("odt.pageHeader"), self.odtPageHeader,
@@ -1395,6 +1412,7 @@ class _OutputTab(NScrollableForm):
self.htmlAddStyles.setChecked(self._build.getBool("html.addStyles"))
self.htmlPreserveTabs.setChecked(self._build.getBool("html.preserveTabs"))
self.mdPreserveBreaks.setChecked(self._build.getBool("md.preserveBreaks"))
self.odtPageHeader.setCursorPosition(0)
return
def saveContent(self) -> None:
+4
View File
@@ -561,6 +561,8 @@ class _NewProjectForm(QWidget):
iPx = SHARED.theme.baseIconSize
sPx = CONFIG.pxInt(16)
iconSize = QSize(iPx, iPx)
# Project Settings
# ================
@@ -581,6 +583,7 @@ class _NewProjectForm(QWidget):
self.browsePath = QToolButton(self)
self.browsePath.setIcon(SHARED.theme.getIcon("browse"))
self.browsePath.setIconSize(iconSize)
self.browsePath.clicked.connect(self._doBrowse)
self.pathBox = QHBoxLayout()
@@ -592,6 +595,7 @@ class _NewProjectForm(QWidget):
self.projFill.setReadOnly(True)
self.browseFill = QToolButton(self)
self.browseFill.setIconSize(iconSize)
self.browseFill.setIcon(SHARED.theme.getIcon("add_document"))
self.fillMenu = _PopLeftDirectionMenu(self.browseFill)