Tue, 21 Dec 2021 20:42:09 +0100
Changed some widgets to work with style sheets instead of manipulating the palette.
eric7/Preferences/ConfigurationPages/DiffColoursPage.py | file | annotate | diff | comparison | revisions | |
eric7/QScintilla/SearchReplaceWidget.py | file | annotate | diff | comparison | revisions |
--- a/eric7/Preferences/ConfigurationPages/DiffColoursPage.py Tue Dec 21 15:21:28 2021 +0100 +++ b/eric7/Preferences/ConfigurationPages/DiffColoursPage.py Tue Dec 21 20:42:09 2021 +0100 @@ -8,7 +8,6 @@ """ from PyQt6.QtCore import pyqtSlot -from PyQt6.QtGui import QPalette from PyQt6.QtWidgets import QColorDialog from .ConfigurationPageBase import ConfigurationPageBase @@ -33,9 +32,14 @@ monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont") self.__allSamples = ( - self.textSample, self.addedSample, self.removedSample, - self.replacedSample, self.contextSample, self.headerSample, - self.whitespaceSample) + self.textSample, + self.addedSample, + self.removedSample, + self.replacedSample, + self.contextSample, + self.headerSample, + self.whitespaceSample + ) for sample in self.__allSamples: sample.setFont(monospacedFont) @@ -154,11 +158,16 @@ @type str """ colour = self.__coloursDict[colourKey][0] - for sample in self.__allSamples: - pl = sample.palette() - pl.setColor(QPalette.ColorRole.Text, colour) - sample.setPalette(pl) - sample.repaint() + for key in self.__coloursDict: + if key == "TextColor": + self.__coloursDict[key][1].setStyleSheet( + "QLineEdit {{ color: {0}; }}".format(colour.name()) + ) + else: + self.__coloursDict[key][1].setStyleSheet( + "QLineEdit {{ color: {0}; background-color: {1}; }}" + .format(colour.name(), self.__coloursDict[key][0].name()) + ) def __updateSampleBackgroundColour(self, colourKey): """ @@ -170,10 +179,11 @@ sample = self.__coloursDict[colourKey][1] if sample: colour = self.__coloursDict[colourKey][0] - pl = sample.palette() - pl.setColor(QPalette.ColorRole.Base, colour) - sample.setPalette(pl) - sample.repaint() + sample.setStyleSheet( + "QLineEdit {{ color: {0}; background-color: {1}; }}" + .format(self.__coloursDict["TextColor"][0].name(), + colour.name()) + ) def create(dlg):
--- a/eric7/QScintilla/SearchReplaceWidget.py Tue Dec 21 15:21:28 2021 +0100 +++ b/eric7/QScintilla/SearchReplaceWidget.py Tue Dec 21 20:42:09 2021 +0100 @@ -11,7 +11,6 @@ import contextlib from PyQt6.QtCore import pyqtSignal, Qt, pyqtSlot, QEvent -from PyQt6.QtGui import QColor, QPalette from PyQt6.QtWidgets import ( QWidget, QHBoxLayout, QToolButton, QScrollArea, QSizePolicy, QFrame ) @@ -163,6 +162,10 @@ self.ui.regexpCheckBox.toggled.connect( self.__updateQuickSearchMarkers) + self.__findtextStyleSheet = ( + self.ui.findtextCombo.lineEdit().styleSheet() + ) + # define actions self.findNextAct = EricAction( self.tr('Find Next'), @@ -436,19 +439,12 @@ @type bool """ if not ok: - palette = self.ui.findtextCombo.lineEdit().palette() - palette.setColor(QPalette.ColorRole.Base, QColor("red")) - palette.setColor(QPalette.ColorRole.Text, QColor("white")) - self.ui.findtextCombo.lineEdit().setPalette(palette) + self.ui.findtextCombo.lineEdit().setStyleSheet( + "QLineEdit { color: #ffffff; background-color: #ff0000; }" + ) else: - palette = self.ui.findtextCombo.lineEdit().palette() - palette.setColor( - QPalette.ColorRole.Base, - self.ui.findtextCombo.palette().color(QPalette.ColorRole.Base)) - palette.setColor( - QPalette.ColorRole.Text, - self.ui.findtextCombo.palette().color(QPalette.ColorRole.Text)) - self.ui.findtextCombo.lineEdit().setPalette(palette) + self.ui.findtextCombo.lineEdit().setStyleSheet( + self.__findtextStyleSheet) @pyqtSlot() def on_extendButton_clicked(self):