Fix theme update for search widget

This commit is contained in:
Veronica Berglyd Olsen
2025-01-22 21:16:46 +01:00
parent 0f0b667fb8
commit f6edda3f97
2 changed files with 9 additions and 9 deletions
+8 -9
View File
@@ -35,12 +35,12 @@ from PyQt6.QtWidgets import (
) )
from novelwriter import CONFIG, SHARED from novelwriter import CONFIG, SHARED
from novelwriter.common import checkInt, cssCol, qtAddAction from novelwriter.common import checkInt, qtAddAction
from novelwriter.core.coretools import DocSearch from novelwriter.core.coretools import DocSearch
from novelwriter.core.item import NWItem from novelwriter.core.item import NWItem
from novelwriter.types import ( from novelwriter.types import (
QtAlignMiddle, QtAlignRight, QtHeaderStretch, QtHeaderToContents, QtAlignMiddle, QtAlignRight, QtHeaderStretch, QtHeaderToContents,
QtUserRole QtHexArgb, QtUserRole
) )
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -71,6 +71,9 @@ class GuiProjectSearch(QWidget):
self._blocked = False self._blocked = False
self._map: dict[str, tuple[int, float]] = {} self._map: dict[str, tuple[int, float]] = {}
self.setBackgroundRole(QPalette.ColorRole.Base)
self.setAutoFillBackground(True)
# Header # Header
self.viewLabel = QLabel(self.tr("Project Search"), self) self.viewLabel = QLabel(self.tr("Project Search"), self)
self.viewLabel.setFont(SHARED.theme.guiFontB) self.viewLabel.setFont(SHARED.theme.guiFontB)
@@ -138,7 +141,6 @@ class GuiProjectSearch(QWidget):
self.outerBox.setContentsMargins(0, 0, 0, 0) self.outerBox.setContentsMargins(0, 0, 0, 0)
self.outerBox.setSpacing(2) self.outerBox.setSpacing(2)
self.setAutoFillBackground(True)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.updateTheme() self.updateTheme()
@@ -152,12 +154,9 @@ class GuiProjectSearch(QWidget):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Update theme elements.""" """Update theme elements."""
palette = QApplication.palette()
qPalette = self.palette() colBase = palette.base().color().name(QtHexArgb)
colBase = cssCol(qPalette.base().color()) colFocus = palette.highlight().color().name(QtHexArgb)
colFocus = cssCol(qPalette.highlight().color())
qPalette.setBrush(QPalette.ColorRole.Window, qPalette.base())
self.setPalette(qPalette)
self.setStyleSheet( self.setStyleSheet(
"QToolBar {padding: 0; background: none;} " "QToolBar {padding: 0; background: none;} "
+1
View File
@@ -70,6 +70,7 @@ QtSelected = QStyle.StateFlag.State_Selected
# Qt Colour Types # Qt Colour Types
QtHexRgb = QColor.NameFormat.HexRgb QtHexRgb = QColor.NameFormat.HexRgb
QtHexArgb = QColor.NameFormat.HexArgb
# Qt Tree and Table Types # Qt Tree and Table Types