Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py

changeset 4593
cc745fa6c914
parent 4223
fafc5c2033f1
child 4631
5c1a96925da4
equal deleted inserted replaced
4590:9fdd473c68fb 4593:cc745fa6c914
14 import copy 14 import copy
15 15
16 from PyQt5.QtCore import pyqtSlot, Qt 16 from PyQt5.QtCore import pyqtSlot, Qt
17 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 17 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
18 18
19 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter 19 from E5Gui.E5PathPicker import E5PathPickerModes
20 from E5Gui import E5FileDialog
21 20
22 from .Ui_EricapiConfigDialog import Ui_EricapiConfigDialog 21 from .Ui_EricapiConfigDialog import Ui_EricapiConfigDialog
23 import Utilities 22 import Utilities
24 import UI.PixmapCache
25 import DocumentationTools 23 import DocumentationTools
26 24
27 from eric6config import getConfig 25 from eric6config import getConfig
28 26
29 27
40 @param parent parent widget of this dialog 38 @param parent parent widget of this dialog
41 """ 39 """
42 super(EricapiConfigDialog, self).__init__(parent) 40 super(EricapiConfigDialog, self).__init__(parent)
43 self.setupUi(self) 41 self.setupUi(self)
44 42
45 self.outputFileButton.setIcon(UI.PixmapCache.getIcon("open.png")) 43 self.outputFilePicker.setMode(E5PathPickerModes.SaveFileMode)
46 self.ignoreDirButton.setIcon(UI.PixmapCache.getIcon("open.png")) 44 self.outputFilePicker.setDefaultDirectory(project.getProjectPath())
45 self.outputFilePicker.setFilters(self.tr(
46 "API files (*.api);;All files (*)"))
47
48 self.ignoreDirPicker.setMode(E5PathPickerModes.DirectoryMode)
49 self.ignoreDirPicker.setDefaultDirectory(project.getProjectPath())
47 50
48 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 51 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
49 for language in sorted( 52 for language in sorted(
50 DocumentationTools.supportedExtensionsDictForApis.keys()): 53 DocumentationTools.supportedExtensionsDictForApis.keys()):
51 self.languagesList.addItem(language) 54 self.languagesList.addItem(language)
63 for key, value in list(parms.items()): 66 for key, value in list(parms.items()):
64 self.parameters[key] = parms[key] 67 self.parameters[key] = parms[key]
65 self.parameters['outputFile'] = \ 68 self.parameters['outputFile'] = \
66 Utilities.toNativeSeparators(self.parameters['outputFile']) 69 Utilities.toNativeSeparators(self.parameters['outputFile'])
67 70
68 self.outputFileCompleter = E5FileCompleter(self.outputFileEdit)
69 self.ignoreDirCompleter = E5DirCompleter(self.ignoreDirEdit)
70
71 self.recursionCheckBox.setChecked(self.parameters['useRecursion']) 71 self.recursionCheckBox.setChecked(self.parameters['useRecursion'])
72 self.includePrivateCheckBox.setChecked( 72 self.includePrivateCheckBox.setChecked(
73 self.parameters['includePrivate']) 73 self.parameters['includePrivate'])
74 self.outputFileEdit.setText(self.parameters['outputFile']) 74 self.outputFilePicker.setText(self.parameters['outputFile'])
75 self.baseEdit.setText(self.parameters['basePackage']) 75 self.baseEdit.setText(self.parameters['basePackage'])
76 self.ignoreDirsList.clear() 76 self.ignoreDirsList.clear()
77 for d in self.parameters['ignoreDirectories']: 77 for d in self.parameters['ignoreDirectories']:
78 self.ignoreDirsList.addItem(d) 78 self.ignoreDirsList.addItem(d)
79 self.sourceExtEdit.setText( 79 self.sourceExtEdit.setText(
179 args.append('--language={0}'.format(lang)) 179 args.append('--language={0}'.format(lang))
180 180
181 return (args, parms) 181 return (args, parms)
182 182
183 @pyqtSlot() 183 @pyqtSlot()
184 def on_outputFileButton_clicked(self): 184 def on_outputFilePicker_aboutToShowPathPickerDialog(self):
185 """ 185 """
186 Private slot to select the output file. 186 Private slot called before the file selection dialog is shown.
187 187 """
188 It displays a file selection dialog to 188 startFile = self.outputFilePicker.text()
189 select the file the api is written to.
190 """
191 startFile = Utilities.fromNativeSeparators(self.outputFileEdit.text())
192 if not startFile: 189 if not startFile:
193 startPath = Utilities.fromNativeSeparators( 190 self.outputFilePicker.setText(
194 self.project.getProjectPath()) 191 self.project.getProjectName() + ".api")
195 startFile = (startPath + "/" + 192
196 self.project.getProjectName() + ".api") 193 @pyqtSlot(str)
197 filename = E5FileDialog.getSaveFileName( 194 def on_outputFilePicker_pathSelected(self, path):
198 self, 195 """
199 self.tr("Select output file"), 196 Private slot handling the selection of an output file.
200 startFile, 197
201 self.tr("API files (*.api);;All files (*)")) 198 @param path path of the output file
202 199 @type str
203 if filename: 200 """
204 # make it relative, if it is in a subdirectory of the project path 201 # make it relative, if it is in a subdirectory of the project path
205 fn = Utilities.toNativeSeparators(filename) 202 fn = self.project.getRelativePath(path)
206 fn = self.project.getRelativePath(fn) 203 self.outputFilePicker.setText(fn)
207 self.outputFileEdit.setText(fn) 204
208 205 def on_outputFilePicker_textChanged(self, filename):
209 def on_outputFileEdit_textChanged(self, filename):
210 """ 206 """
211 Private slot to enable/disable the "OK" button. 207 Private slot to enable/disable the "OK" button.
212 208
213 @param filename name of the file (string) 209 @param filename name of the file (string)
214 """ 210 """
215 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(filename != "") 211 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(filename != "")
216 212
217 @pyqtSlot() 213 @pyqtSlot(str)
218 def on_ignoreDirButton_clicked(self): 214 def on_ignoreDirPicker_pathSelected(self, path):
219 """ 215 """
220 Private slot to select a directory to be ignored. 216 Private slot handling the selection of a directory to be ignored.
221 217
222 It displays a directory selection dialog to 218 @param path path of the directory to be ignored
223 select a directory to be ignored. 219 @type str
224 """ 220 """
225 startDir = Utilities.fromNativeSeparators(self.ignoreDirEdit.text()) 221 # make it relative, if it is in a subdirectory of the project path
226 if not startDir: 222 dn = self.project.getRelativePath(path)
227 startDir = self.ppath 223 while dn.endswith(os.sep):
228 directory = E5FileDialog.getExistingDirectory( 224 dn = dn[:-1]
229 self, 225 self.ignoreDirPicker.setText(dn)
230 self.tr("Select directory to exclude"),
231 startDir,
232 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
233
234 if directory:
235 # make it relative, if it is a subdirectory of the project path
236 dn = Utilities.toNativeSeparators(directory)
237 dn = self.project.getRelativePath(dn)
238 while dn.endswith(os.sep):
239 dn = dn[:-1]
240 self.ignoreDirEdit.setText(dn)
241 226
242 @pyqtSlot() 227 @pyqtSlot()
243 def on_addButton_clicked(self): 228 def on_addButton_clicked(self):
244 """ 229 """
245 Private slot to add the directory displayed to the listview. 230 Private slot to add the directory displayed to the listview.
246 231
247 The directory in the ignore directories 232 The directory in the ignore directories
248 line edit is moved to the listbox above and the edit is cleared. 233 line edit is moved to the listbox above and the edit is cleared.
249 """ 234 """
250 basename = os.path.basename(self.ignoreDirEdit.text()) 235 basename = os.path.basename(self.ignoreDirPicker.text())
251 if basename: 236 if basename:
252 self.ignoreDirsList.addItem(basename) 237 self.ignoreDirsList.addItem(basename)
253 self.ignoreDirEdit.clear() 238 self.ignoreDirPicker.clear()
254 239
255 @pyqtSlot() 240 @pyqtSlot()
256 def on_deleteButton_clicked(self): 241 def on_deleteButton_clicked(self):
257 """ 242 """
258 Private slot to delete the currently selected directory of the listbox. 243 Private slot to delete the currently selected directory of the listbox.
267 It saves the values in the parameters dictionary. 252 It saves the values in the parameters dictionary.
268 """ 253 """
269 self.parameters['useRecursion'] = self.recursionCheckBox.isChecked() 254 self.parameters['useRecursion'] = self.recursionCheckBox.isChecked()
270 self.parameters['includePrivate'] = \ 255 self.parameters['includePrivate'] = \
271 self.includePrivateCheckBox.isChecked() 256 self.includePrivateCheckBox.isChecked()
272 outfile = self.outputFileEdit.text() 257 outfile = self.outputFilePicker.text()
273 if outfile != '': 258 if outfile != '':
274 outfile = os.path.normpath(outfile) 259 outfile = os.path.normpath(outfile)
275 self.parameters['outputFile'] = outfile 260 self.parameters['outputFile'] = outfile
276 self.parameters['basePackage'] = self.baseEdit.text() 261 self.parameters['basePackage'] = self.baseEdit.text()
277 self.parameters['ignoreDirectories'] = [] 262 self.parameters['ignoreDirectories'] = []

eric ide

mercurial