diff -r 6acaa89ff7da -r 17974c348101 eric6/Preferences/ConfigurationPages/IconsPage.py --- a/eric6/Preferences/ConfigurationPages/IconsPage.py Fri Apr 10 15:18:58 2020 +0200 +++ b/eric6/Preferences/ConfigurationPages/IconsPage.py Fri Apr 10 19:27:51 2020 +0200 @@ -7,17 +7,21 @@ Module implementing the Icons configuration page. """ +import os from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QListWidgetItem from E5Gui.E5PathPicker import E5PathPickerModes +from E5Gui.E5Application import e5App from .ConfigurationPageBase import ConfigurationPageBase from .Ui_IconsPage import Ui_IconsPage import Preferences +from eric6config import getConfig + class IconsPage(ConfigurationPageBase, Ui_IconsPage): """ @@ -34,6 +38,16 @@ self.iconDirectoryPicker.setMode(E5PathPickerModes.DirectoryMode) # set initial values + defaultIconsPath = Preferences.getIcons("DefaultIconsPath") + if defaultIconsPath == "automatic": + self.defaultAutomaticButton.setChecked(True) + elif defaultIconsPath == "breeze-light": + self.defaultBreezeLightButton.setChecked(True) + elif defaultIconsPath == "breeze-dark": + self.defaultBreezeDarkButton.setChecked(True) + else: + self.defaultOxygenButton.setChecked(True) + dirList = Preferences.getIcons("Path")[:] for directory in dirList: if directory: @@ -43,11 +57,30 @@ """ Public slot to save the Icons configuration. """ + Preferences.setIcons("DefaultIconsPath", + self.__getSelectedDefaultIconsPath()) + dirList = [] for i in range(self.iconDirectoryList.count()): dirList.append(self.iconDirectoryList.item(i).text()) Preferences.setIcons("Path", dirList) + + def __getSelectedDefaultIconsPath(self): + """ + Private method to determine the selected default icons path. + @return selected default icons path + @rtype str + """ + if self.defaultAutomaticButton.isChecked(): + return "automatic" + elif self.defaultBreezeLightButton.isChecked(): + return "breeze-light" + elif self.defaultBreezeDarkButton.isChecked(): + return "breeze-dark" + else: + return "oxygen" + def on_iconDirectoryList_currentRowChanged(self, row): """ Private slot to handle the currentRowChanged signal of the icons @@ -147,15 +180,37 @@ Private slot to display a preview of an icons directory. """ directory = self.iconDirectoryPicker.text() - if not directory: - itm = self.iconDirectoryList.currentItem() - if itm is not None: - directory = itm.text() if directory: + directories = [directory] + else: + directories = [] + for row in range(self.iconDirectoryList.count()): + directories.append(self.iconDirectoryList.item(row).text()) + if directories: from .IconsPreviewDialog import IconsPreviewDialog - dlg = IconsPreviewDialog(self, directory) + dlg = IconsPreviewDialog(directories, self) dlg.exec_() + @pyqtSlot() + def on_showDefaultIconsButton_clicked(self): + """ + Private slot to display a preview of the selected default icons. + """ + defaultIconsPath = self.__getSelectedDefaultIconsPath() + if defaultIconsPath == "automatic": + if e5App().usesDarkPalette(): + defaultIconsPath = "breeze-dark" + else: + defaultIconsPath = "breeze-light" + + from .IconsPreviewDialog import IconsPreviewDialog + dlg = IconsPreviewDialog([ + os.path.join(getConfig('ericIconDir'), defaultIconsPath), + os.path.join(getConfig('ericIconDir'), defaultIconsPath, + "languages"), + ], self) + dlg.exec_() + def create(dlg): """