eric6/Preferences/ConfigurationPages/IconsPage.py

changeset 7521
17974c348101
parent 7360
9190402e4505
child 7759
51aa6c6b66f7
equal deleted inserted replaced
7520:6acaa89ff7da 7521:17974c348101
5 5
6 """ 6 """
7 Module implementing the Icons configuration page. 7 Module implementing the Icons configuration page.
8 """ 8 """
9 9
10 import os
10 11
11 from PyQt5.QtCore import pyqtSlot 12 from PyQt5.QtCore import pyqtSlot
12 from PyQt5.QtWidgets import QListWidgetItem 13 from PyQt5.QtWidgets import QListWidgetItem
13 14
14 from E5Gui.E5PathPicker import E5PathPickerModes 15 from E5Gui.E5PathPicker import E5PathPickerModes
16 from E5Gui.E5Application import e5App
15 17
16 from .ConfigurationPageBase import ConfigurationPageBase 18 from .ConfigurationPageBase import ConfigurationPageBase
17 from .Ui_IconsPage import Ui_IconsPage 19 from .Ui_IconsPage import Ui_IconsPage
18 20
19 import Preferences 21 import Preferences
22
23 from eric6config import getConfig
20 24
21 25
22 class IconsPage(ConfigurationPageBase, Ui_IconsPage): 26 class IconsPage(ConfigurationPageBase, Ui_IconsPage):
23 """ 27 """
24 Class implementing the Icons configuration page. 28 Class implementing the Icons configuration page.
32 self.setObjectName("IconsPage") 36 self.setObjectName("IconsPage")
33 37
34 self.iconDirectoryPicker.setMode(E5PathPickerModes.DirectoryMode) 38 self.iconDirectoryPicker.setMode(E5PathPickerModes.DirectoryMode)
35 39
36 # set initial values 40 # set initial values
41 defaultIconsPath = Preferences.getIcons("DefaultIconsPath")
42 if defaultIconsPath == "automatic":
43 self.defaultAutomaticButton.setChecked(True)
44 elif defaultIconsPath == "breeze-light":
45 self.defaultBreezeLightButton.setChecked(True)
46 elif defaultIconsPath == "breeze-dark":
47 self.defaultBreezeDarkButton.setChecked(True)
48 else:
49 self.defaultOxygenButton.setChecked(True)
50
37 dirList = Preferences.getIcons("Path")[:] 51 dirList = Preferences.getIcons("Path")[:]
38 for directory in dirList: 52 for directory in dirList:
39 if directory: 53 if directory:
40 QListWidgetItem(directory, self.iconDirectoryList) 54 QListWidgetItem(directory, self.iconDirectoryList)
41 55
42 def save(self): 56 def save(self):
43 """ 57 """
44 Public slot to save the Icons configuration. 58 Public slot to save the Icons configuration.
45 """ 59 """
60 Preferences.setIcons("DefaultIconsPath",
61 self.__getSelectedDefaultIconsPath())
62
46 dirList = [] 63 dirList = []
47 for i in range(self.iconDirectoryList.count()): 64 for i in range(self.iconDirectoryList.count()):
48 dirList.append(self.iconDirectoryList.item(i).text()) 65 dirList.append(self.iconDirectoryList.item(i).text())
49 Preferences.setIcons("Path", dirList) 66 Preferences.setIcons("Path", dirList)
50 67
68 def __getSelectedDefaultIconsPath(self):
69 """
70 Private method to determine the selected default icons path.
71
72 @return selected default icons path
73 @rtype str
74 """
75 if self.defaultAutomaticButton.isChecked():
76 return "automatic"
77 elif self.defaultBreezeLightButton.isChecked():
78 return "breeze-light"
79 elif self.defaultBreezeDarkButton.isChecked():
80 return "breeze-dark"
81 else:
82 return "oxygen"
83
51 def on_iconDirectoryList_currentRowChanged(self, row): 84 def on_iconDirectoryList_currentRowChanged(self, row):
52 """ 85 """
53 Private slot to handle the currentRowChanged signal of the icons 86 Private slot to handle the currentRowChanged signal of the icons
54 directory list. 87 directory list.
55 88
145 def on_showIconsButton_clicked(self): 178 def on_showIconsButton_clicked(self):
146 """ 179 """
147 Private slot to display a preview of an icons directory. 180 Private slot to display a preview of an icons directory.
148 """ 181 """
149 directory = self.iconDirectoryPicker.text() 182 directory = self.iconDirectoryPicker.text()
150 if not directory:
151 itm = self.iconDirectoryList.currentItem()
152 if itm is not None:
153 directory = itm.text()
154 if directory: 183 if directory:
184 directories = [directory]
185 else:
186 directories = []
187 for row in range(self.iconDirectoryList.count()):
188 directories.append(self.iconDirectoryList.item(row).text())
189 if directories:
155 from .IconsPreviewDialog import IconsPreviewDialog 190 from .IconsPreviewDialog import IconsPreviewDialog
156 dlg = IconsPreviewDialog(self, directory) 191 dlg = IconsPreviewDialog(directories, self)
157 dlg.exec_() 192 dlg.exec_()
158 193
194 @pyqtSlot()
195 def on_showDefaultIconsButton_clicked(self):
196 """
197 Private slot to display a preview of the selected default icons.
198 """
199 defaultIconsPath = self.__getSelectedDefaultIconsPath()
200 if defaultIconsPath == "automatic":
201 if e5App().usesDarkPalette():
202 defaultIconsPath = "breeze-dark"
203 else:
204 defaultIconsPath = "breeze-light"
205
206 from .IconsPreviewDialog import IconsPreviewDialog
207 dlg = IconsPreviewDialog([
208 os.path.join(getConfig('ericIconDir'), defaultIconsPath),
209 os.path.join(getConfig('ericIconDir'), defaultIconsPath,
210 "languages"),
211 ], self)
212 dlg.exec_()
213
159 214
160 def create(dlg): 215 def create(dlg):
161 """ 216 """
162 Module function to create the configuration page. 217 Module function to create the configuration page.
163 218

eric ide

mercurial