5 |
5 |
6 """ |
6 """ |
7 Module implementing the Editor APIs configuration page. |
7 Module implementing the Editor APIs configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import QDir, pyqtSlot, QFileInfo |
10 import pathlib |
11 from PyQt6.QtWidgets import QInputDialog |
11 |
|
12 from PyQt6.QtCore import pyqtSlot |
|
13 from PyQt6.QtWidgets import QDialog |
12 |
14 |
13 from EricWidgets.EricApplication import ericApp |
15 from EricWidgets.EricApplication import ericApp |
14 from EricWidgets import EricMessageBox |
16 from EricWidgets import EricMessageBox |
|
17 from EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
15 from EricWidgets.EricPathPicker import EricPathPickerModes |
18 from EricWidgets.EricPathPicker import EricPathPickerModes |
16 |
19 |
17 from .ConfigurationPageBase import ConfigurationPageBase |
20 from .ConfigurationPageBase import ConfigurationPageBase |
18 from .Ui_EditorAPIsPage import Ui_EditorAPIsPage |
21 from .Ui_EditorAPIsPage import Ui_EditorAPIsPage |
19 |
22 |
238 Private slot to add an API file from the list of installed API files |
241 Private slot to add an API file from the list of installed API files |
239 for the selected lexer language. |
242 for the selected lexer language. |
240 """ |
243 """ |
241 installedAPIFiles = self.__currentAPI.installedAPIFiles() |
244 installedAPIFiles = self.__currentAPI.installedAPIFiles() |
242 if installedAPIFiles: |
245 if installedAPIFiles: |
243 installedAPIFilesPath = QFileInfo(installedAPIFiles[0]).path() |
246 installedAPIFilesPath = pathlib.Path(installedAPIFiles[0]).parent |
244 installedAPIFilesShort = [] |
247 installedAPIFilesShort = [ |
245 for installedAPIFile in installedAPIFiles: |
248 pathlib.Path(f).name for f in installedAPIFiles |
246 installedAPIFilesShort.append( |
249 ] |
247 QFileInfo(installedAPIFile).fileName()) |
250 dlg = EricListSelectionDialog( |
248 file, ok = QInputDialog.getItem( |
251 sorted(installedAPIFilesShort), |
249 self, |
252 title=self.tr("Add from installed APIs"), |
250 self.tr("Add from installed APIs"), |
253 message=self.tr("Select from the list of installed API files"), |
251 self.tr("Select from the list of installed API files"), |
254 checkBoxSelection=True, |
252 installedAPIFilesShort, |
255 parent=self |
253 0, False) |
256 ) |
254 if ok: |
257 if dlg.exec() == QDialog.DialogCode.Accepted: |
255 self.apiList.addItem(Utilities.toNativeSeparators( |
258 self.apiList.addItems([ |
256 QFileInfo(QDir(installedAPIFilesPath), file) |
259 str(installedAPIFilesPath / s) for s in dlg.getSelection() |
257 .absoluteFilePath())) |
260 ]) |
258 else: |
261 else: |
259 EricMessageBox.warning( |
262 EricMessageBox.warning( |
260 self, |
263 self, |
261 self.tr("Add from installed APIs"), |
264 self.tr("Add from installed APIs"), |
262 self.tr("""There are no APIs installed yet.""" |
265 self.tr("""There are no APIs installed yet.""" |
270 Private slot to add an API file from the list of API files installed |
273 Private slot to add an API file from the list of API files installed |
271 by plugins for the selected lexer language. |
274 by plugins for the selected lexer language. |
272 """ |
275 """ |
273 pluginAPIFiles = self.pluginManager.getPluginApiFiles( |
276 pluginAPIFiles = self.pluginManager.getPluginApiFiles( |
274 self.__currentApiLanguage) |
277 self.__currentApiLanguage) |
275 pluginAPIFilesDict = {} |
278 pluginAPIFilesDict = { |
276 for apiFile in pluginAPIFiles: |
279 pathlib.Path(f).name:pathlib.Path(f) for f in pluginAPIFiles |
277 pluginAPIFilesDict[QFileInfo(apiFile).fileName()] = apiFile |
280 } |
278 file, ok = QInputDialog.getItem( |
281 dlg = EricListSelectionDialog( |
279 self, |
282 sorted(pluginAPIFilesDict.keys()), |
280 self.tr("Add from Plugin APIs"), |
283 title=self.tr("Add from Plugin APIs"), |
281 self.tr( |
284 message=self.tr( |
282 "Select from the list of API files installed by plugins"), |
285 "Select from the list of API files installed by plugins"), |
283 sorted(pluginAPIFilesDict.keys()), |
286 checkBoxSelection=True, |
284 0, False) |
287 parent=self |
285 if ok: |
288 ) |
286 self.apiList.addItem(Utilities.toNativeSeparators( |
289 if dlg.exec() == QDialog.DialogCode.Accepted: |
287 pluginAPIFilesDict[file])) |
290 self.apiList.addItems([ |
|
291 str(pluginAPIFilesDict[s]) for s in dlg.getSelection() |
|
292 ]) |
288 self.prepareApiButton.setEnabled(self.apiList.count() > 0) |
293 self.prepareApiButton.setEnabled(self.apiList.count() > 0) |
289 |
294 |
290 @pyqtSlot() |
295 @pyqtSlot() |
291 def on_prepareApiButton_clicked(self): |
296 def on_prepareApiButton_clicked(self): |
292 """ |
297 """ |