31 """ |
31 """ |
32 super().__init__(parent) |
32 super().__init__(parent) |
33 self.setupUi(self) |
33 self.setupUi(self) |
34 |
34 |
35 palette = self.iconView.palette() |
35 palette = self.iconView.palette() |
36 self.__baseBrush = palette.brush(QPalette.ColorRole.Base) |
36 self.__backgroundColor = palette.color(QPalette.ColorRole.Window) |
37 self.__textBrush = palette.brush(QPalette.ColorRole.Text) |
37 self.__foregroundColor = palette.color(QPalette.ColorRole.WindowText) |
38 self.__inverted = False |
38 self.__inverted = False |
39 |
39 |
40 self.directoryCombo.addItems(sorted(directories)) |
40 self.directoryCombo.addItems(sorted(directories)) |
41 |
41 |
42 @pyqtSlot(str) |
42 @pyqtSlot(str) |
52 for icon in directory.entryList(["*.svg", "*.svgz", "*.png"]): |
52 for icon in directory.entryList(["*.svg", "*.svgz", "*.png"]): |
53 itm = QListWidgetItem( |
53 itm = QListWidgetItem( |
54 QIcon(os.path.join(dirName, icon)), |
54 QIcon(os.path.join(dirName, icon)), |
55 icon, self.iconView) |
55 icon, self.iconView) |
56 if self.__inverted: |
56 if self.__inverted: |
57 itm.setForeground(self.__baseBrush) |
57 itm.setForeground(self.__backgroundColor) |
58 else: |
58 else: |
59 itm.setForeground(self.__textBrush) |
59 itm.setForeground(self.__foregroundColor) |
60 |
60 |
61 @pyqtSlot(bool) |
61 @pyqtSlot(bool) |
62 def on_invertButton_toggled(self, checked): |
62 def on_invertButton_toggled(self, checked): |
63 """ |
63 """ |
64 Private slot to show the icons on an inverted background. |
64 Private slot to show the icons on an inverted background. |
66 @param checked state of the button |
66 @param checked state of the button |
67 @type bool |
67 @type bool |
68 """ |
68 """ |
69 self.__inverted = checked |
69 self.__inverted = checked |
70 |
70 |
71 # TODO: change to use style sheets |
|
72 palette = self.iconView.palette() |
|
73 if self.__inverted: |
71 if self.__inverted: |
74 palette.setBrush(QPalette.ColorRole.Base, self.__textBrush) |
72 styleSheet = ( |
75 palette.setBrush(QPalette.ColorRole.Text, self.__baseBrush) |
73 f"color: {self.__backgroundColor.name()};" |
|
74 f"background-color: {self.__foregroundColor.name()}" |
|
75 ) |
76 else: |
76 else: |
77 palette.setBrush(QPalette.ColorRole.Base, self.__baseBrush) |
77 styleSheet = ( |
78 palette.setBrush(QPalette.ColorRole.Text, self.__textBrush) |
78 f"color: {self.__foregroundColor.name()};" |
79 self.iconView.viewport().setPalette(palette) |
79 f"background-color: {self.__backgroundColor.name()}" |
|
80 ) |
|
81 self.iconView.viewport().setStyleSheet(styleSheet) |
80 |
82 |
81 self.on_refreshButton_clicked() |
83 self.on_refreshButton_clicked() |
82 |
84 |
83 @pyqtSlot() |
85 @pyqtSlot() |
84 def on_refreshButton_clicked(self): |
86 def on_refreshButton_clicked(self): |