7 Module implementing the Start Program dialog. |
7 Module implementing the Start Program dialog. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox |
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog |
13 |
13 |
14 from E5Gui.E5PathPicker import E5PathPickerModes |
14 from E5Gui.E5PathPicker import E5PathPickerModes |
15 |
15 |
16 import Preferences |
16 import Preferences |
17 |
17 |
81 self.ui.workdirPicker.setSizeAdjustPolicy( |
81 self.ui.workdirPicker.setSizeAdjustPolicy( |
82 QComboBox.AdjustToMinimumContentsLength) |
82 QComboBox.AdjustToMinimumContentsLength) |
83 |
83 |
84 self.clearButton = self.ui.buttonBox.addButton( |
84 self.clearButton = self.ui.buttonBox.addButton( |
85 self.tr("Clear Histories"), QDialogButtonBox.ActionRole) |
85 self.tr("Clear Histories"), QDialogButtonBox.ActionRole) |
|
86 self.editButton = self.ui.buttonBox.addButton( |
|
87 self.tr("Edit History"), QDialogButtonBox.ActionRole) |
86 |
88 |
87 self.setWindowTitle(caption) |
89 self.setWindowTitle(caption) |
88 self.ui.cmdlineCombo.clear() |
90 self.ui.cmdlineCombo.clear() |
89 self.ui.cmdlineCombo.addItems(argvList) |
91 self.ui.cmdlineCombo.addItems(argvList) |
90 if len(argvList) > 0: |
92 if len(argvList) > 0: |
216 self.ui.environmentCombo.clear() |
218 self.ui.environmentCombo.clear() |
217 |
219 |
218 self.ui.cmdlineCombo.addItem(cmdLine) |
220 self.ui.cmdlineCombo.addItem(cmdLine) |
219 self.ui.workdirPicker.addItem(workdir) |
221 self.ui.workdirPicker.addItem(workdir) |
220 self.ui.environmentCombo.addItem(environment) |
222 self.ui.environmentCombo.addItem(environment) |
|
223 |
|
224 def __editHistory(self): |
|
225 """ |
|
226 Private slot to edit a history list. |
|
227 """ |
|
228 histories = [ |
|
229 "", |
|
230 self.tr("Command Line"), |
|
231 self.tr("Working Directory"), |
|
232 self.tr("Environment"), |
|
233 ] |
|
234 historyKind, ok = QInputDialog.getItem( |
|
235 self, |
|
236 self.tr("Edit History"), |
|
237 self.tr("Select the history list to be edited:"), |
|
238 histories, |
|
239 0, False) |
|
240 if ok and historyKind: |
|
241 historiesIndex = histories.index(historyKind) |
|
242 if historiesIndex == 2: |
|
243 history = self.ui.workdirPicker.getPathItems() |
|
244 else: |
|
245 history = [] |
|
246 if historiesIndex == 1: |
|
247 combo = self.ui.cmdlineCombo |
|
248 else: |
|
249 combo = self.ui.environmentCombo |
|
250 for index in range(combo.count()): |
|
251 history.append(combo.itemText(index)) |
|
252 |
|
253 from .StartHistoryEditDialog import StartHistoryEditDialog |
|
254 dlg = StartHistoryEditDialog(history, self) |
|
255 if dlg.exec_() == QDialog.Accepted: |
|
256 history = dlg.getHistory() |
|
257 if historiesIndex == 1: |
|
258 combo = self.ui.cmdlineCombo |
|
259 elif historiesIndex == 2: |
|
260 combo = self.ui.workdirPicker |
|
261 else: |
|
262 combo = self.ui.environmentCombo |
|
263 combo.clear() |
|
264 combo.addItems(history) |
221 |
265 |
222 def on_buttonBox_clicked(self, button): |
266 def on_buttonBox_clicked(self, button): |
223 """ |
267 """ |
224 Private slot called by a button of the button box clicked. |
268 Private slot called by a button of the button box clicked. |
225 |
269 |
226 @param button button that was clicked (QAbstractButton) |
270 @param button button that was clicked (QAbstractButton) |
227 """ |
271 """ |
228 if button == self.clearButton: |
272 if button == self.clearButton: |
229 self.__clearHistories() |
273 self.__clearHistories() |
|
274 elif button == self.editButton: |
|
275 self.__editHistory() |