Clean up background colours in editor and sidebar

This commit is contained in:
Veronica Berglyd Olsen
2025-01-22 21:52:26 +01:00
parent 5dee5ecefe
commit eb34a32760
3 changed files with 10 additions and 28 deletions
+10 -21
View File
@@ -42,9 +42,9 @@ from PyQt6.QtCore import (
pyqtSlot pyqtSlot
) )
from PyQt6.QtGui import ( from PyQt6.QtGui import (
QAction, QColor, QCursor, QDragEnterEvent, QDragMoveEvent, QDropEvent, QAction, QCursor, QDragEnterEvent, QDragMoveEvent, QDropEvent, QKeyEvent,
QKeyEvent, QKeySequence, QMouseEvent, QPalette, QPixmap, QResizeEvent, QKeySequence, QMouseEvent, QPalette, QPixmap, QResizeEvent, QShortcut,
QShortcut, QTextBlock, QTextCursor, QTextDocument, QTextOption QTextBlock, QTextCursor, QTextDocument, QTextOption
) )
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QApplication, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QMenu, QApplication, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QMenu,
@@ -2662,10 +2662,11 @@ class GuiDocEditSearch(QFrame):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Update theme elements.""" """Update theme elements."""
qPalette = QApplication.palette() palette = QApplication.palette()
self.setPalette(qPalette)
self.searchBox.setPalette(qPalette) self.setPalette(palette)
self.replaceBox.setPalette(qPalette) self.searchBox.setPalette(palette)
self.replaceBox.setPalette(palette)
# Set icons # Set icons
self.toggleCase.setIcon(SHARED.theme.getIcon("search_case")) self.toggleCase.setIcon(SHARED.theme.getIcon("search_case"))
@@ -2683,21 +2684,9 @@ class GuiDocEditSearch(QFrame):
self.showReplace.setStyleSheet("QToolButton {border: none; background: transparent;}") self.showReplace.setStyleSheet("QToolButton {border: none; background: transparent;}")
# Construct Box Colours # Construct Box Colours
qPalette = self.searchBox.palette()
baseCol = qPalette.base().color()
rCol = baseCol.redF() + 0.1
gCol = baseCol.greenF() - 0.1
bCol = baseCol.blueF() - 0.1
mCol = max(rCol, gCol, bCol, 1.0)
errCol = QColor()
errCol.setRedF(rCol/mCol)
errCol.setGreenF(gCol/mCol)
errCol.setBlueF(bCol/mCol)
self.rxCol = { self.rxCol = {
True: baseCol, True: palette.base().color(),
False: errCol False: SHARED.theme.errorText.darker(200),
} }
return return
-5
View File
@@ -28,7 +28,6 @@ import logging
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from PyQt6.QtCore import QEvent, QPoint, QSize, pyqtSignal from PyQt6.QtCore import QEvent, QPoint, QSize, pyqtSignal
from PyQt6.QtGui import QPalette
from PyQt6.QtWidgets import QMenu, QVBoxLayout, QWidget from PyQt6.QtWidgets import QMenu, QVBoxLayout, QWidget
from novelwriter import SHARED from novelwriter import SHARED
@@ -125,10 +124,6 @@ class GuiSideBar(QWidget):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Initialise GUI elements that depend on specific settings.""" """Initialise GUI elements that depend on specific settings."""
qPalette = self.palette()
qPalette.setBrush(QPalette.ColorRole.Window, qPalette.base())
self.setPalette(qPalette)
buttonStyle = SHARED.theme.getStyleSheet(STYLES_BIG_TOOLBUTTON) buttonStyle = SHARED.theme.getStyleSheet(STYLES_BIG_TOOLBUTTON)
self.tbProject.setStyleSheet(buttonStyle) self.tbProject.setStyleSheet(buttonStyle)
-2
View File
@@ -1046,8 +1046,6 @@ class GuiMain(QMainWindow):
SHARED.project.tree.refreshAllItems() SHARED.project.tree.refreshAllItems()
if theme: if theme:
# We are doing this manually instead of connecting to
# paletteChanged since the processing order matters
SHARED.theme.loadTheme() SHARED.theme.loadTheme()
self.setPalette(QApplication.palette()) self.setPalette(QApplication.palette())
self.docEditor.updateTheme() self.docEditor.updateTheme()