src/eric7/Preferences/ConfigurationPages/EditorAPIsPage.py

Tue, 18 Oct 2022 16:06:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 18 Oct 2022 16:06:21 +0200
branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
permissions
-rw-r--r--

Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8366
diff changeset
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Editor APIs configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9185
8975ed45c22d Fixed an issue causing the standalone configuration script to crash on the API page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
10 import contextlib
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
11 import pathlib
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
12
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
13 from PyQt6.QtCore import pyqtSlot
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
14 from PyQt6.QtWidgets import QDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
16 from eric7.EricWidgets.EricApplication import ericApp
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
17 from eric7.EricWidgets import EricMessageBox
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
18 from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
19 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
21 from .ConfigurationPageBase import ConfigurationPageBase
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
22 from .Ui_EditorAPIsPage import Ui_EditorAPIsPage
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
24 from eric7 import Preferences, Utilities
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
26
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 class EditorAPIsPage(ConfigurationPageBase, Ui_EditorAPIsPage):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Class implementing the Editor APIs configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8151
diff changeset
36 super().__init__()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setObjectName("EditorAPIsPage")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
39
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
40 self.apiFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
41 self.apiFilePicker.setToolTip(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42 self.tr("Press to select an API file via a selection dialog")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
43 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
44 self.apiFilePicker.setFilters(self.tr("API File (*.api);;All Files (*)"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
46 self.prepareApiButton.setText(self.tr("Compile APIs"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__currentAPI = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__inPreparation = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 # set initial values
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
51 self.pluginManager = ericApp().getObject("PluginManager")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
52 self.apiAutoPrepareCheckBox.setChecked(Preferences.getEditor("AutoPrepareAPIs"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
54 from eric7.QScintilla import Lexers
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.apis = {}
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
57 apiLanguages = sorted([""] + list(Lexers.getSupportedApiLanguages()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 for lang in apiLanguages:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
59 self.apiLanguageComboBox.addItem(Lexers.getLanguageIcon(lang, False), lang)
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
60 self.__currentApiLanguage = ""
8151
8c1445825e7b Changed code to not use QComboBox.activated[str] and QComboBoc.highlighted[str] signals but the int variants instead.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
61 self.on_apiLanguageComboBox_activated(0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
62
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
63 def __apiKey(self, language, projectType):
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
64 """
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
65 Private method to generate a key for the apis dictionary.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
66
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
67 @param language programming language of the API
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
68 @type str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
69 @param projectType project type of the API
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
70 @type str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
71 @return key to be used
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
72 @rtype str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
73 """
8234
fcb6b4b96274 Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
74 key = (language, projectType) if projectType else (language, "")
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
75 return key
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
76
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def save(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Public slot to save the Editor APIs configuration.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
81 Preferences.setEditor(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
82 "AutoPrepareAPIs", self.apiAutoPrepareCheckBox.isChecked()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
84
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
85 language = self.apiLanguageComboBox.currentText()
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
86 projectType = self.projectTypeComboBox.itemData(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
87 self.projectTypeComboBox.currentIndex()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88 )
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
89 key = self.__apiKey(language, projectType)
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
90 self.apis[key] = self.__editorGetApisFromApiList()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
92 for (language, projectType), apis in self.apis.items():
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
93 Preferences.setEditorAPI(language, projectType, apis)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
94
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
95 @pyqtSlot(int)
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
96 def on_projectTypeComboBox_activated(self, index):
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
97 """
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
98 Private slot to handle the selection of a project type.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
100 @param index index of the selected entry
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
101 @type str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
102 """
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
103 if self.__currentApiProjectTypeIndex == index:
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
104 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
105
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
106 self.__currentApiProjectTypeIndex = index
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
107 self.__fillApisList()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
108
8151
8c1445825e7b Changed code to not use QComboBox.activated[str] and QComboBoc.highlighted[str] signals but the int variants instead.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
109 @pyqtSlot(int)
8c1445825e7b Changed code to not use QComboBox.activated[str] and QComboBoc.highlighted[str] signals but the int variants instead.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
110 def on_apiLanguageComboBox_activated(self, index):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 Private slot to fill the api listbox of the api page.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113
8151
8c1445825e7b Changed code to not use QComboBox.activated[str] and QComboBoc.highlighted[str] signals but the int variants instead.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
114 @param index index of the selected entry
8c1445825e7b Changed code to not use QComboBox.activated[str] and QComboBoc.highlighted[str] signals but the int variants instead.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
115 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
8151
8c1445825e7b Changed code to not use QComboBox.activated[str] and QComboBoc.highlighted[str] signals but the int variants instead.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
117 language = self.apiLanguageComboBox.itemText(index)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
119 if self.__currentApiLanguage == language:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
121
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
122 self.__fillProjectTypeComboBox(language)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
123
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
124 def __fillProjectTypeComboBox(self, language):
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
125 """
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
126 Private slot to fill the selection of available project types for the
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
127 given language.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
128
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
129 @param language selected API language
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
130 @type str
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
131 """
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
132 self.projectTypeComboBox.clear()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
133
9185
8975ed45c22d Fixed an issue causing the standalone configuration script to crash on the API page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
134 apiProjectTypes = [("", "")]
8975ed45c22d Fixed an issue causing the standalone configuration script to crash on the API page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
135 with contextlib.suppress(KeyError):
8975ed45c22d Fixed an issue causing the standalone configuration script to crash on the API page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
136 apiProjectTypes += sorted(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137 (trans, ptype)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
138 for ptype, trans in ericApp()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
139 .getObject("Project")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
140 .getProjectTypes(language)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141 .items()
9185
8975ed45c22d Fixed an issue causing the standalone configuration script to crash on the API page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
142 )
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
143 for projectTypeStr, projectType in apiProjectTypes:
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
144 self.projectTypeComboBox.addItem(projectTypeStr, projectType)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
145
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
146 self.__currentApiProjectTypeIndex = -1
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
147 self.__currentApiProjectType = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
148
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
149 self.on_projectTypeComboBox_activated(0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
150
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
151 def __fillApisList(self):
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
152 """
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
153 Private slot to fill the list of API files.
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
154 """
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
155 self.apis[
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
156 self.__apiKey(self.__currentApiLanguage, self.__currentApiProjectType)
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
157 ] = self.__editorGetApisFromApiList()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
158
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
159 self.__currentApiLanguage = self.apiLanguageComboBox.currentText()
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
160 self.__currentApiProjectType = self.projectTypeComboBox.itemData(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161 self.projectTypeComboBox.currentIndex()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
162 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.apiList.clear()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
164
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
165 if not self.__currentApiLanguage:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.apiGroup.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
168
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.apiGroup.setEnabled(True)
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
170 self.deleteApiFileButton.setEnabled(False)
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
171 self.addApiFileButton.setEnabled(False)
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4554
diff changeset
172 self.apiFilePicker.clear()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
174 key = self.__apiKey(self.__currentApiLanguage, self.__currentApiProjectType)
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
175 if key not in self.apis:
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
176 # populate on demand
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
177 self.apis[key] = Preferences.getEditorAPI(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
178 self.__currentApiLanguage, projectType=self.__currentApiProjectType
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
179 )[:]
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
180 for api in self.apis[key]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 if api:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.apiList.addItem(api)
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
183 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
184
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
185 from eric7.QScintilla.APIsManager import APIsManager
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
187 self.__currentAPI = APIsManager().getAPIs(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
188 self.__currentApiLanguage, projectType=self.__currentApiProjectType
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
189 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 if self.__currentAPI is not None:
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 130
diff changeset
191 self.__currentAPI.apiPreparationFinished.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192 self.__apiPreparationFinished
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
193 )
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 130
diff changeset
194 self.__currentAPI.apiPreparationCancelled.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195 self.__apiPreparationCancelled
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196 )
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 130
diff changeset
197 self.__currentAPI.apiPreparationStarted.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
198 self.__apiPreparationStarted
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
199 )
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
200 self.addInstalledApiFileButton.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201 len(self.__currentAPI.installedAPIFiles()) > 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
202 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.addInstalledApiFileButton.setEnabled(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
205
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 self.addPluginApiFileButton.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
207 len(self.pluginManager.getPluginApiFiles(self.__currentApiLanguage)) > 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
208 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
209
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def __editorGetApisFromApiList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Private slot to retrieve the api filenames from the list.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
213
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @return list of api filenames (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 apis = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 for row in range(self.apiList.count()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 apis.append(self.apiList.item(row).text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 return apis
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
220
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 def on_addApiFileButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 Private slot to add the api file displayed to the listbox.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 """
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4554
diff changeset
226 file = self.apiFilePicker.text()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 if file:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 self.apiList.addItem(Utilities.toNativeSeparators(file))
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4554
diff changeset
229 self.apiFilePicker.clear()
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
230 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
231
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 def on_deleteApiFileButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 Private slot to delete the currently selected file of the listbox.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 crow = self.apiList.currentRow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 if crow >= 0:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
239 itm = self.apiList.takeItem(crow) # __IGNORE_WARNING__
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 del itm
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
241 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
242
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 def on_addInstalledApiFileButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 Private slot to add an API file from the list of installed API files
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 for the selected lexer language.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 installedAPIFiles = self.__currentAPI.installedAPIFiles()
1118
2ff50209a57f Fixed a bug in the editor APIs page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
250 if installedAPIFiles:
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
251 installedAPIFilesPath = pathlib.Path(installedAPIFiles[0]).parent
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
252 installedAPIFilesShort = [pathlib.Path(f).name for f in installedAPIFiles]
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
253 dlg = EricListSelectionDialog(
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
254 sorted(installedAPIFilesShort),
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
255 title=self.tr("Add from installed APIs"),
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
256 message=self.tr("Select from the list of installed API files"),
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
257 checkBoxSelection=True,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
258 parent=self,
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
259 )
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
260 if dlg.exec() == QDialog.DialogCode.Accepted:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
261 self.apiList.addItems(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
262 [str(installedAPIFilesPath / s) for s in dlg.getSelection()]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
263 )
1118
2ff50209a57f Fixed a bug in the editor APIs page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
264 else:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
265 EricMessageBox.warning(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
266 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
267 self.tr("Add from installed APIs"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
268 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
269 """There are no APIs installed yet."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
270 """ Selection is not available."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
271 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
272 )
1118
2ff50209a57f Fixed a bug in the editor APIs page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
273 self.addInstalledApiFileButton.setEnabled(False)
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
274 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
275
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 def on_addPluginApiFileButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 Private slot to add an API file from the list of API files installed
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 by plugins for the selected lexer language.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
282 pluginAPIFiles = self.pluginManager.getPluginApiFiles(self.__currentApiLanguage)
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
283 pluginAPIFilesDict = {
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9151
diff changeset
284 pathlib.Path(f).name: pathlib.Path(f) for f in pluginAPIFiles
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
285 }
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
286 dlg = EricListSelectionDialog(
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
287 sorted(pluginAPIFilesDict.keys()),
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
288 title=self.tr("Add from Plugin APIs"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
289 message=self.tr("Select from the list of API files installed by plugins"),
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
290 checkBoxSelection=True,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
291 parent=self,
9151
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
292 )
8c5296fe3056 Changed API configuration page to allow to select multiple API files at once.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
293 if dlg.exec() == QDialog.DialogCode.Accepted:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
294 self.apiList.addItems(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
295 [str(pluginAPIFilesDict[s]) for s in dlg.getSelection()]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
296 )
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
297 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
298
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 def on_prepareApiButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
302 Private slot to prepare the API file for the currently selected
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
303 language.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 if self.__inPreparation:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 self.__currentAPI and self.__currentAPI.cancelPreparation()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 if self.__currentAPI is not None:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
309 self.__currentAPI.prepareAPIs(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
310 ondemand=True, rawList=self.__editorGetApisFromApiList()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
311 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
312
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 def __apiPreparationFinished(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 Private method called after the API preparation has finished.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self.prepareApiProgressBar.reset()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 self.prepareApiProgressBar.setRange(0, 100)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.prepareApiProgressBar.setValue(0)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
320 self.prepareApiButton.setText(self.tr("Compile APIs"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 self.__inPreparation = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
322
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 def __apiPreparationCancelled(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 Private slot called after the API preparation has been cancelled.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.__apiPreparationFinished()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
328
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 def __apiPreparationStarted(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 Private method called after the API preparation has started.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 self.prepareApiProgressBar.setRange(0, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 self.prepareApiProgressBar.setValue(0)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
335 self.prepareApiButton.setText(self.tr("Cancel compilation"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 self.__inPreparation = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
337
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 def saveState(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 Public method to save the current state of the widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
341
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
342 @return tuple containing the index of the selected lexer language
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
343 and the index of the selected project type
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
344 @rtype tuple of int and int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
346 return (
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
347 self.apiLanguageComboBox.currentIndex(),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
348 self.projectTypeComboBox.currentIndex(),
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
349 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
350
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 def setState(self, state):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 Public method to set the state of the widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
354
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 @param state state data generated by saveState
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 """
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
357 self.apiLanguageComboBox.setCurrentIndex(state[0])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
358 self.on_apiLanguageComboBox_activated(self.apiLanguageComboBox.currentIndex())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
359
7164
6da6a0a5a448 Made "MicroPython" a selectable programming language in order to not mess with the normal API selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
360 self.projectTypeComboBox.setCurrentIndex(state[1])
5350
57e82ffafdfc Adjusted the APIs configuration page to support project type specific API sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
361 self.on_projectTypeComboBox_activated(state[1])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
362
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
363 @pyqtSlot()
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
364 def on_apiList_itemSelectionChanged(self):
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
365 """
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
366 Private slot to react on changes of API selections.
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
367 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
368 self.deleteApiFileButton.setEnabled(len(self.apiList.selectedItems()) > 0)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
369
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
370 @pyqtSlot(str)
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4554
diff changeset
371 def on_apiFilePicker_textChanged(self, txt):
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
372 """
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
373 Private slot to handle the entering of an API file name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
374
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
375 @param txt text of the line edit (string)
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
376 """
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
377 enable = txt != ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
378
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
379 if enable:
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
380 # check for already added file
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
381 for row in range(self.apiList.count()):
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
382 if txt == self.apiList.item(row).text():
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
383 enable = False
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
384 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
385
3098
02ee75d31584 Fixed a bug in the APIs configuration page of the config dialog and improved its functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
386 self.addApiFileButton.setEnabled(enable)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
387
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
388
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 def create(dlg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 Module function to create the configuration page.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
392
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 @param dlg reference to the configuration dialog
2964
84b65fb9e780 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2408
diff changeset
394 @return reference to the instantiated page (ConfigurationPageBase)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 page = EditorAPIsPage()
880
52ed20236a1c Added the option to not use the native file dialog to prevent crashes on Linux.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
397 return page

eric ide

mercurial