18 |
18 |
19 class IconsPreviewDialog(QDialog, Ui_IconsPreviewDialog): |
19 class IconsPreviewDialog(QDialog, Ui_IconsPreviewDialog): |
20 """ |
20 """ |
21 Class implementing a dialog to preview the contents of an icon directory. |
21 Class implementing a dialog to preview the contents of an icon directory. |
22 """ |
22 """ |
|
23 |
23 def __init__(self, directories, parent=None): |
24 def __init__(self, directories, parent=None): |
24 """ |
25 """ |
25 Constructor |
26 Constructor |
26 |
27 |
27 @param directories list of directories to be shown |
28 @param directories list of directories to be shown |
28 @type list of str |
29 @type list of str |
29 @param parent parent widget |
30 @param parent parent widget |
30 @type QWidget |
31 @type QWidget |
31 """ |
32 """ |
32 super().__init__(parent) |
33 super().__init__(parent) |
33 self.setupUi(self) |
34 self.setupUi(self) |
34 |
35 |
35 palette = self.iconView.palette() |
36 palette = self.iconView.palette() |
36 self.__backgroundColor = palette.color(QPalette.ColorRole.Window) |
37 self.__backgroundColor = palette.color(QPalette.ColorRole.Window) |
37 self.__foregroundColor = palette.color(QPalette.ColorRole.WindowText) |
38 self.__foregroundColor = palette.color(QPalette.ColorRole.WindowText) |
38 self.__inverted = False |
39 self.__inverted = False |
39 |
40 |
40 self.directoryCombo.addItems(sorted(directories)) |
41 self.directoryCombo.addItems(sorted(directories)) |
41 |
42 |
42 @pyqtSlot(str) |
43 @pyqtSlot(str) |
43 def on_directoryCombo_currentTextChanged(self, dirName): |
44 def on_directoryCombo_currentTextChanged(self, dirName): |
44 """ |
45 """ |
45 Private slot to show the icons of the selected icon directory. |
46 Private slot to show the icons of the selected icon directory. |
46 |
47 |
47 @param dirName selected icon directory |
48 @param dirName selected icon directory |
48 @type str |
49 @type str |
49 """ |
50 """ |
50 self.iconView.clear() |
51 self.iconView.clear() |
51 directory = QDir(dirName) |
52 directory = QDir(dirName) |
52 for icon in directory.entryList(["*.svg", "*.svgz", "*.png"]): |
53 for icon in directory.entryList(["*.svg", "*.svgz", "*.png"]): |
53 itm = QListWidgetItem( |
54 itm = QListWidgetItem( |
54 QIcon(os.path.join(dirName, icon)), |
55 QIcon(os.path.join(dirName, icon)), icon, self.iconView |
55 icon, self.iconView) |
56 ) |
56 if self.__inverted: |
57 if self.__inverted: |
57 itm.setForeground(self.__backgroundColor) |
58 itm.setForeground(self.__backgroundColor) |
58 else: |
59 else: |
59 itm.setForeground(self.__foregroundColor) |
60 itm.setForeground(self.__foregroundColor) |
60 |
61 |
61 @pyqtSlot(bool) |
62 @pyqtSlot(bool) |
62 def on_invertButton_toggled(self, checked): |
63 def on_invertButton_toggled(self, checked): |
63 """ |
64 """ |
64 Private slot to show the icons on an inverted background. |
65 Private slot to show the icons on an inverted background. |
65 |
66 |
66 @param checked state of the button |
67 @param checked state of the button |
67 @type bool |
68 @type bool |
68 """ |
69 """ |
69 self.__inverted = checked |
70 self.__inverted = checked |
70 |
71 |
71 styleSheet = ( |
72 styleSheet = ( |
72 f"color: {self.__backgroundColor.name()};" |
73 f"color: {self.__backgroundColor.name()};" |
73 f"background-color: {self.__foregroundColor.name()}" |
74 f"background-color: {self.__foregroundColor.name()}" |
74 if self.__inverted else |
75 if self.__inverted |
75 f"color: {self.__foregroundColor.name()};" |
76 else f"color: {self.__foregroundColor.name()};" |
76 f"background-color: {self.__backgroundColor.name()}" |
77 f"background-color: {self.__backgroundColor.name()}" |
77 ) |
78 ) |
78 self.iconView.viewport().setStyleSheet(styleSheet) |
79 self.iconView.viewport().setStyleSheet(styleSheet) |
79 |
80 |
80 self.on_refreshButton_clicked() |
81 self.on_refreshButton_clicked() |
81 |
82 |
82 @pyqtSlot() |
83 @pyqtSlot() |
83 def on_refreshButton_clicked(self): |
84 def on_refreshButton_clicked(self): |
84 """ |
85 """ |
85 Private slot to refresh the view. |
86 Private slot to refresh the view. |
86 """ |
87 """ |