10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSlot |
12 from PyQt5.QtCore import pyqtSlot |
13 from PyQt5.QtWidgets import QListWidgetItem |
13 from PyQt5.QtWidgets import QListWidgetItem |
14 |
14 |
15 from E5Gui.E5Completers import E5DirCompleter |
15 from E5Gui.E5PathPicker import E5PathPickerModes |
16 from E5Gui import E5FileDialog |
|
17 |
16 |
18 from .ConfigurationPageBase import ConfigurationPageBase |
17 from .ConfigurationPageBase import ConfigurationPageBase |
19 from .Ui_IconsPage import Ui_IconsPage |
18 from .Ui_IconsPage import Ui_IconsPage |
20 |
19 |
21 import Preferences |
20 import Preferences |
22 import Utilities |
|
23 import UI.PixmapCache |
|
24 |
21 |
25 |
22 |
26 class IconsPage(ConfigurationPageBase, Ui_IconsPage): |
23 class IconsPage(ConfigurationPageBase, Ui_IconsPage): |
27 """ |
24 """ |
28 Class implementing the Icons configuration page. |
25 Class implementing the Icons configuration page. |
33 """ |
30 """ |
34 super(IconsPage, self).__init__() |
31 super(IconsPage, self).__init__() |
35 self.setupUi(self) |
32 self.setupUi(self) |
36 self.setObjectName("IconsPage") |
33 self.setObjectName("IconsPage") |
37 |
34 |
38 self.iconDirectoryButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
35 self.iconDirectoryPicker.setMode(E5PathPickerModes.DiretoryMode) |
39 |
|
40 self.iconDirectoryCompleter = E5DirCompleter(self.iconDirectoryEdit) |
|
41 |
36 |
42 # set initial values |
37 # set initial values |
43 dirList = Preferences.getIcons("Path")[:] |
38 dirList = Preferences.getIcons("Path")[:] |
44 for dir in dirList: |
39 for dir in dirList: |
45 if dir: |
40 if dir: |
64 if row == -1: |
59 if row == -1: |
65 self.deleteIconDirectoryButton.setEnabled(False) |
60 self.deleteIconDirectoryButton.setEnabled(False) |
66 self.upButton.setEnabled(False) |
61 self.upButton.setEnabled(False) |
67 self.downButton.setEnabled(False) |
62 self.downButton.setEnabled(False) |
68 self.showIconsButton.setEnabled( |
63 self.showIconsButton.setEnabled( |
69 self.iconDirectoryEdit.text() != "") |
64 self.iconDirectoryPicker.text() != "") |
70 else: |
65 else: |
71 maxIndex = self.iconDirectoryList.count() - 1 |
66 maxIndex = self.iconDirectoryList.count() - 1 |
72 self.upButton.setEnabled(row != 0) |
67 self.upButton.setEnabled(row != 0) |
73 self.downButton.setEnabled(row != maxIndex) |
68 self.downButton.setEnabled(row != maxIndex) |
74 self.deleteIconDirectoryButton.setEnabled(True) |
69 self.deleteIconDirectoryButton.setEnabled(True) |
75 self.showIconsButton.setEnabled(True) |
70 self.showIconsButton.setEnabled(True) |
76 |
71 |
77 def on_iconDirectoryEdit_textChanged(self, txt): |
72 def on_iconDirectoryPicker_textChanged(self, txt): |
78 """ |
73 """ |
79 Private slot to handle the textChanged signal of the directory edit. |
74 Private slot to handle the textChanged signal of the directory picker. |
80 |
75 |
81 @param txt the text of the directory edit (string) |
76 @param txt the text of the directory picker (string) |
82 """ |
77 """ |
83 self.addIconDirectoryButton.setEnabled(txt != "") |
78 self.addIconDirectoryButton.setEnabled(txt != "") |
84 self.showIconsButton.setEnabled( |
79 self.showIconsButton.setEnabled( |
85 txt != "" or |
80 txt != "" or |
86 self.iconDirectoryList.currentRow() != -1) |
81 self.iconDirectoryList.currentRow() != -1) |
123 self.downButton.setEnabled(False) |
118 self.downButton.setEnabled(False) |
124 else: |
119 else: |
125 self.downButton.setEnabled(True) |
120 self.downButton.setEnabled(True) |
126 |
121 |
127 @pyqtSlot() |
122 @pyqtSlot() |
128 def on_iconDirectoryButton_clicked(self): |
|
129 """ |
|
130 Private slot to select an icon directory. |
|
131 """ |
|
132 dir = E5FileDialog.getExistingDirectory( |
|
133 None, |
|
134 self.tr("Select icon directory"), |
|
135 "", |
|
136 E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) |
|
137 |
|
138 if dir: |
|
139 self.iconDirectoryEdit.setText(Utilities.toNativeSeparators(dir)) |
|
140 |
|
141 @pyqtSlot() |
|
142 def on_addIconDirectoryButton_clicked(self): |
123 def on_addIconDirectoryButton_clicked(self): |
143 """ |
124 """ |
144 Private slot to add the icon directory displayed to the listbox. |
125 Private slot to add the icon directory displayed to the listbox. |
145 """ |
126 """ |
146 dir = self.iconDirectoryEdit.text() |
127 dir = self.iconDirectoryPicker.text() |
147 if dir: |
128 if dir: |
148 QListWidgetItem(dir, self.iconDirectoryList) |
129 QListWidgetItem(dir, self.iconDirectoryList) |
149 self.iconDirectoryEdit.clear() |
130 self.iconDirectoryPicker.clear() |
150 row = self.iconDirectoryList.currentRow() |
131 row = self.iconDirectoryList.currentRow() |
151 self.on_iconDirectoryList_currentRowChanged(row) |
132 self.on_iconDirectoryList_currentRowChanged(row) |
152 |
133 |
153 @pyqtSlot() |
134 @pyqtSlot() |
154 def on_deleteIconDirectoryButton_clicked(self): |
135 def on_deleteIconDirectoryButton_clicked(self): |