11 |
11 |
12 from PyQt5.QtCore import QDir, pyqtSlot, QFileInfo |
12 from PyQt5.QtCore import QDir, pyqtSlot, QFileInfo |
13 from PyQt5.QtWidgets import QInputDialog |
13 from PyQt5.QtWidgets import QInputDialog |
14 |
14 |
15 from E5Gui.E5Application import e5App |
15 from E5Gui.E5Application import e5App |
16 from E5Gui.E5Completers import E5FileCompleter |
16 from E5Gui import E5MessageBox |
17 from E5Gui import E5FileDialog, E5MessageBox |
17 from E5Gui.E5PathPicker import E5PathPickerModes |
18 |
18 |
19 from .ConfigurationPageBase import ConfigurationPageBase |
19 from .ConfigurationPageBase import ConfigurationPageBase |
20 from .Ui_EditorAPIsPage import Ui_EditorAPIsPage |
20 from .Ui_EditorAPIsPage import Ui_EditorAPIsPage |
21 |
21 |
22 import Preferences |
22 import Preferences |
23 import Utilities |
23 import Utilities |
24 import UI.PixmapCache |
|
25 |
24 |
26 |
25 |
27 class EditorAPIsPage(ConfigurationPageBase, Ui_EditorAPIsPage): |
26 class EditorAPIsPage(ConfigurationPageBase, Ui_EditorAPIsPage): |
28 """ |
27 """ |
29 Class implementing the Editor APIs configuration page. |
28 Class implementing the Editor APIs configuration page. |
34 """ |
33 """ |
35 super(EditorAPIsPage, self).__init__() |
34 super(EditorAPIsPage, self).__init__() |
36 self.setupUi(self) |
35 self.setupUi(self) |
37 self.setObjectName("EditorAPIsPage") |
36 self.setObjectName("EditorAPIsPage") |
38 |
37 |
39 self.apiFileButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
38 self.apiFilePicker.setMode(E5PathPickerModes.OpenFileMode) |
|
39 self.apiFilePicker.setToolTip(self.tr( |
|
40 "Press to select an API file via a selection dialog")) |
|
41 self.apiFilePicker.setFilters(self.tr( |
|
42 "API File (*.api);;All Files (*)")) |
40 |
43 |
41 self.prepareApiButton.setText(self.tr("Compile APIs")) |
44 self.prepareApiButton.setText(self.tr("Compile APIs")) |
42 self.__currentAPI = None |
45 self.__currentAPI = None |
43 self.__inPreparation = False |
46 self.__inPreparation = False |
44 |
|
45 self.apiFileCompleter = E5FileCompleter(self.apiFileEdit) |
|
46 |
47 |
47 # set initial values |
48 # set initial values |
48 self.pluginManager = e5App().getObject("PluginManager") |
49 self.pluginManager = e5App().getObject("PluginManager") |
49 self.apiAutoPrepareCheckBox.setChecked( |
50 self.apiAutoPrepareCheckBox.setChecked( |
50 Preferences.getEditor("AutoPrepareAPIs")) |
51 Preferences.getEditor("AutoPrepareAPIs")) |
95 return |
96 return |
96 |
97 |
97 self.apiGroup.setEnabled(True) |
98 self.apiGroup.setEnabled(True) |
98 self.deleteApiFileButton.setEnabled(False) |
99 self.deleteApiFileButton.setEnabled(False) |
99 self.addApiFileButton.setEnabled(False) |
100 self.addApiFileButton.setEnabled(False) |
100 self.apiFileEdit.clear() |
101 self.apiFilePicker.clear() |
101 |
102 |
102 for api in self.apis[self.currentApiLanguage]: |
103 for api in self.apis[self.currentApiLanguage]: |
103 if api: |
104 if api: |
104 self.apiList.addItem(api) |
105 self.apiList.addItem(api) |
105 self.prepareApiButton.setEnabled(self.apiList.count() > 0) |
106 self.prepareApiButton.setEnabled(self.apiList.count() > 0) |
132 for row in range(self.apiList.count()): |
133 for row in range(self.apiList.count()): |
133 apis.append(self.apiList.item(row).text()) |
134 apis.append(self.apiList.item(row).text()) |
134 return apis |
135 return apis |
135 |
136 |
136 @pyqtSlot() |
137 @pyqtSlot() |
137 def on_apiFileButton_clicked(self): |
|
138 """ |
|
139 Private method to select an api file. |
|
140 """ |
|
141 file = E5FileDialog.getOpenFileName( |
|
142 self, |
|
143 self.tr("Select API file"), |
|
144 self.apiFileEdit.text(), |
|
145 self.tr("API File (*.api);;All Files (*)")) |
|
146 |
|
147 if file: |
|
148 self.apiFileEdit.setText(Utilities.toNativeSeparators(file)) |
|
149 |
|
150 @pyqtSlot() |
|
151 def on_addApiFileButton_clicked(self): |
138 def on_addApiFileButton_clicked(self): |
152 """ |
139 """ |
153 Private slot to add the api file displayed to the listbox. |
140 Private slot to add the api file displayed to the listbox. |
154 """ |
141 """ |
155 file = self.apiFileEdit.text() |
142 file = self.apiFilePicker.text() |
156 if file: |
143 if file: |
157 self.apiList.addItem(Utilities.toNativeSeparators(file)) |
144 self.apiList.addItem(Utilities.toNativeSeparators(file)) |
158 self.apiFileEdit.clear() |
145 self.apiFilePicker.clear() |
159 self.prepareApiButton.setEnabled(self.apiList.count() > 0) |
146 self.prepareApiButton.setEnabled(self.apiList.count() > 0) |
160 |
147 |
161 @pyqtSlot() |
148 @pyqtSlot() |
162 def on_deleteApiFileButton_clicked(self): |
149 def on_deleteApiFileButton_clicked(self): |
163 """ |
150 """ |
288 """ |
275 """ |
289 self.deleteApiFileButton.setEnabled( |
276 self.deleteApiFileButton.setEnabled( |
290 len(self.apiList.selectedItems()) > 0) |
277 len(self.apiList.selectedItems()) > 0) |
291 |
278 |
292 @pyqtSlot(str) |
279 @pyqtSlot(str) |
293 def on_apiFileEdit_textChanged(self, txt): |
280 def on_apiFilePicker_textChanged(self, txt): |
294 """ |
281 """ |
295 Private slot to handle the entering of an API file name. |
282 Private slot to handle the entering of an API file name. |
296 |
283 |
297 @param txt text of the line edit (string) |
284 @param txt text of the line edit (string) |
298 """ |
285 """ |