--- a/eric7/Preferences/ConfigurationPages/IconsPreviewDialog.py Tue Dec 28 16:44:16 2021 +0100 +++ b/eric7/Preferences/ConfigurationPages/IconsPreviewDialog.py Tue Dec 28 17:12:27 2021 +0100 @@ -33,8 +33,8 @@ self.setupUi(self) palette = self.iconView.palette() - self.__baseBrush = palette.brush(QPalette.ColorRole.Base) - self.__textBrush = palette.brush(QPalette.ColorRole.Text) + self.__backgroundColor = palette.color(QPalette.ColorRole.Window) + self.__foregroundColor = palette.color(QPalette.ColorRole.WindowText) self.__inverted = False self.directoryCombo.addItems(sorted(directories)) @@ -54,9 +54,9 @@ QIcon(os.path.join(dirName, icon)), icon, self.iconView) if self.__inverted: - itm.setForeground(self.__baseBrush) + itm.setForeground(self.__backgroundColor) else: - itm.setForeground(self.__textBrush) + itm.setForeground(self.__foregroundColor) @pyqtSlot(bool) def on_invertButton_toggled(self, checked): @@ -68,15 +68,17 @@ """ self.__inverted = checked - # TODO: change to use style sheets - palette = self.iconView.palette() if self.__inverted: - palette.setBrush(QPalette.ColorRole.Base, self.__textBrush) - palette.setBrush(QPalette.ColorRole.Text, self.__baseBrush) + styleSheet = ( + f"color: {self.__backgroundColor.name()};" + f"background-color: {self.__foregroundColor.name()}" + ) else: - palette.setBrush(QPalette.ColorRole.Base, self.__baseBrush) - palette.setBrush(QPalette.ColorRole.Text, self.__textBrush) - self.iconView.viewport().setPalette(palette) + styleSheet = ( + f"color: {self.__foregroundColor.name()};" + f"background-color: {self.__backgroundColor.name()}" + ) + self.iconView.viewport().setStyleSheet(styleSheet) self.on_refreshButton_clicked()