--- a/src/eric7/Preferences/ConfigurationPages/IconsPage.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Preferences/ConfigurationPages/IconsPage.py Wed Jul 13 14:55:47 2022 +0200 @@ -27,6 +27,7 @@ """ Class implementing the Icons configuration page. """ + def __init__(self): """ Constructor @@ -34,9 +35,9 @@ super().__init__() self.setupUi(self) self.setObjectName("IconsPage") - + self.iconDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) - + # set initial values defaultIconsPath = Preferences.getIcons("DefaultIconsPath") if defaultIconsPath == "automatic": @@ -47,28 +48,27 @@ self.defaultBreezeDarkButton.setChecked(True) else: self.defaultOxygenButton.setChecked(True) - + dirList = Preferences.getIcons("Path")[:] for directory in dirList: if directory: QListWidgetItem(directory, self.iconDirectoryList) - + def save(self): """ Public slot to save the Icons configuration. """ - Preferences.setIcons("DefaultIconsPath", - self.__getSelectedDefaultIconsPath()) - + 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 """ @@ -80,38 +80,37 @@ return "breeze-dark" else: return "oxygen" - + def on_iconDirectoryList_currentRowChanged(self, row): """ Private slot to handle the currentRowChanged signal of the icons directory list. - + @param row the current row (integer) """ if row == -1: self.deleteIconDirectoryButton.setEnabled(False) self.upButton.setEnabled(False) self.downButton.setEnabled(False) - self.showIconsButton.setEnabled( - self.iconDirectoryPicker.text() != "") + self.showIconsButton.setEnabled(self.iconDirectoryPicker.text() != "") else: maxIndex = self.iconDirectoryList.count() - 1 self.upButton.setEnabled(row != 0) self.downButton.setEnabled(row != maxIndex) self.deleteIconDirectoryButton.setEnabled(True) self.showIconsButton.setEnabled(True) - + def on_iconDirectoryPicker_textChanged(self, txt): """ Private slot to handle the textChanged signal of the directory picker. - + @param txt the text of the directory picker (string) """ self.addIconDirectoryButton.setEnabled(txt != "") self.showIconsButton.setEnabled( - txt != "" or - self.iconDirectoryList.currentRow() != -1) - + txt != "" or self.iconDirectoryList.currentRow() != -1 + ) + @pyqtSlot() def on_upButton_clicked(self): """ @@ -121,7 +120,7 @@ if row == 0: # we're already at the top return - + itm = self.iconDirectoryList.takeItem(row) self.iconDirectoryList.insertItem(row - 1, itm) self.iconDirectoryList.setCurrentItem(itm) @@ -130,7 +129,7 @@ else: self.upButton.setEnabled(True) self.downButton.setEnabled(True) - + @pyqtSlot() def on_downButton_clicked(self): """ @@ -141,7 +140,7 @@ if row == rows - 1: # we're already at the end return - + itm = self.iconDirectoryList.takeItem(row) self.iconDirectoryList.insertItem(row + 1, itm) self.iconDirectoryList.setCurrentItem(itm) @@ -150,7 +149,7 @@ self.downButton.setEnabled(False) else: self.downButton.setEnabled(True) - + @pyqtSlot() def on_addIconDirectoryButton_clicked(self): """ @@ -162,7 +161,7 @@ self.iconDirectoryPicker.clear() row = self.iconDirectoryList.currentRow() self.on_iconDirectoryList_currentRowChanged(row) - + @pyqtSlot() def on_deleteIconDirectoryButton_clicked(self): """ @@ -173,7 +172,7 @@ del itm row = self.iconDirectoryList.currentRow() self.on_iconDirectoryList_currentRowChanged(row) - + @pyqtSlot() def on_showIconsButton_clicked(self): """ @@ -188,9 +187,10 @@ directories.append(self.iconDirectoryList.item(row).text()) if directories: from .IconsPreviewDialog import IconsPreviewDialog + dlg = IconsPreviewDialog(directories, self) dlg.exec() - + @pyqtSlot() def on_showDefaultIconsButton_clicked(self): """ @@ -202,20 +202,23 @@ 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 = IconsPreviewDialog( + [ + os.path.join(getConfig("ericIconDir"), defaultIconsPath), + os.path.join(getConfig("ericIconDir"), defaultIconsPath, "languages"), + ], + self, + ) dlg.exec() def create(dlg): """ Module function to create the configuration page. - + @param dlg reference to the configuration dialog @return reference to the instantiated page (ConfigurationPageBase) """