Debugger/StartDialog.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Start Program dialog.
8 """
9
10 import os
11
12 from PyQt4.QtCore import *
13 from PyQt4.QtGui import *
14
15 from E4Gui.E4Completers import E4DirCompleter
16
17 import Utilities
18 import Preferences
19
20 class StartDialog(QDialog):
21 """
22 Class implementing the Start Program dialog.
23
24 It implements a dialog that is used to start an
25 application for debugging. It asks the user to enter
26 the commandline parameters, the working directory and
27 whether exception reporting should be disabled.
28 """
29 def __init__(self, caption, argvList, wdList, envList, exceptions, parent = None,
30 type = 0, modfuncList = None, tracePython = False, autoClearShell = True,
31 autoContinue = True, autoFork = False, forkChild = False):
32 """
33 Constructor
34
35 @param caption the caption to be displayed (string)
36 @param argvList history list of commandline arguments (list of strings)
37 @param wdList history list of working directories (list of strings)
38 @param envList history list of environment settings (list of strings)
39 @param exceptions exception reporting flag (boolean)
40 @param parent parent widget of this dialog (QWidget)
41 @param type type of the start dialog
42 <ul>
43 <li>0 = start debug dialog</li>
44 <li>1 = start run dialog</li>
45 <li>2 = start coverage dialog</li>
46 <li>3 = start profile dialog</li>
47 </ul>
48 @keyparam modfuncList history list of module functions (list of strings)
49 @keyparam tracePython flag indicating if the Python library should
50 be traced as well (boolean)
51 @keyparam autoClearShell flag indicating, that the interpreter window should
52 be cleared automatically (boolean)
53 @keyparam autoContinue flag indicating, that the debugger should not stop at
54 the first executable line (boolean)
55 @keyparam autoFork flag indicating the automatic fork mode (boolean)
56 @keyparam forkChild flag indicating to debug the child after forking (boolean)
57 """
58 QDialog.__init__(self, parent)
59 self.setModal(True)
60
61 self.type = type
62 if type == 0:
63 from Ui_StartDebugDialog import Ui_StartDebugDialog
64 self.ui = Ui_StartDebugDialog()
65 elif type == 1:
66 from Ui_StartRunDialog import Ui_StartRunDialog
67 self.ui = Ui_StartRunDialog()
68 elif type == 2:
69 from Ui_StartCoverageDialog import Ui_StartCoverageDialog
70 self.ui = Ui_StartCoverageDialog()
71 elif type == 3:
72 from Ui_StartProfileDialog import Ui_StartProfileDialog
73 self.ui = Ui_StartProfileDialog()
74 self.ui.setupUi(self)
75
76 self.clearButton = self.ui.buttonBox.addButton(\
77 self.trUtf8("Clear Histories"), QDialogButtonBox.ActionRole)
78
79 self.workdirCompleter = E4DirCompleter(self.ui.workdirCombo)
80
81 self.setWindowTitle(caption)
82 self.ui.cmdlineCombo.clear()
83 self.ui.cmdlineCombo.addItems(argvList)
84 if len(argvList) > 0:
85 self.ui.cmdlineCombo.setCurrentIndex(0)
86 self.ui.workdirCombo.clear()
87 self.ui.workdirCombo.addItems(wdList)
88 if len(wdList) > 0:
89 self.ui.workdirCombo.setCurrentIndex(0)
90 self.ui.environmentCombo.clear()
91 self.ui.environmentCombo.addItems(envList)
92 self.ui.exceptionCheckBox.setChecked(exceptions)
93 self.ui.clearShellCheckBox.setChecked(autoClearShell)
94 self.ui.consoleCheckBox.setEnabled(
95 Preferences.getDebugger("ConsoleDbgCommand") != "")
96 self.ui.consoleCheckBox.setChecked(False)
97
98 if type == 0: # start debug dialog
99 self.ui.tracePythonCheckBox.setChecked(tracePython)
100 self.ui.tracePythonCheckBox.show()
101 self.ui.autoContinueCheckBox.setChecked(autoContinue)
102 self.ui.forkModeCheckBox.setChecked(autoFork)
103 self.ui.forkChildCheckBox.setChecked(forkChild)
104
105 if type == 3: # start coverage or profile dialog
106 self.ui.eraseCheckBox.setChecked(True)
107
108 self.__clearHistoryLists = False
109
110 @pyqtSlot()
111 def on_dirButton_clicked(self):
112 """
113 Private method used to open a directory selection dialog.
114 """
115 cwd = self.ui.workdirCombo.currentText()
116 d = QFileDialog.getExistingDirectory(\
117 self,
118 self.trUtf8("Working directory"),
119 cwd,
120 QFileDialog.Options(QFileDialog.ShowDirsOnly))
121
122 if d:
123 self.ui.workdirCombo.setEditText(Utilities.toNativeSeparators(d))
124
125 def on_modFuncCombo_editTextChanged(self):
126 """
127 Private slot to enable/disable the OK button.
128 """
129 self.ui.buttonBox.button(QDialogButtonBox.Ok).setDisabled(\
130 self.ui.modFuncCombo.currentText() == "")
131
132 def getData(self):
133 """
134 Public method to retrieve the data entered into this dialog.
135
136 @return a tuple of argv (string), workdir (string), environment (string),
137 exceptions flag (boolean), clear interpreter flag (boolean),
138 clear histories flag (boolean) and run in console flag (boolean)
139 """
140 cmdLine = self.ui.cmdlineCombo.currentText()
141 workdir = self.ui.workdirCombo.currentText()
142 environment = self.ui.environmentCombo.currentText()
143
144 return (cmdLine,
145 workdir,
146 environment,
147 self.ui.exceptionCheckBox.isChecked(),
148 self.ui.clearShellCheckBox.isChecked(),
149 self.__clearHistoryLists,
150 self.ui.consoleCheckBox.isChecked())
151
152 def getDebugData(self):
153 """
154 Public method to retrieve the debug related data entered into this dialog.
155
156 @return a tuple of a flag indicating, if the Python library should be traced
157 as well, a flag indicating, that the debugger should not stop at the
158 first executable line (boolean), a flag indicating, that the debugger
159 should fork automatically (boolean) and a flag indicating, that the
160 debugger should debug the child process after forking automatically (boolean)
161 """
162 if self.type == 0:
163 return (self.ui.tracePythonCheckBox.isChecked(),
164 self.ui.autoContinueCheckBox.isChecked(),
165 self.ui.forkModeCheckBox.isChecked(),
166 self.ui.forkChildCheckBox.isChecked())
167
168 def getCoverageData(self):
169 """
170 Public method to retrieve the coverage related data entered into this dialog.
171
172 @return flag indicating erasure of coverage info (boolean)
173 """
174 if self.type == 2:
175 return self.ui.eraseCheckBox.isChecked()
176
177 def getProfilingData(self):
178 """
179 Public method to retrieve the profiling related data entered into this dialog.
180
181 @return flag indicating erasure of profiling info (boolean)
182 """
183 if self.type == 3:
184 return self.ui.eraseCheckBox.isChecked()
185
186 def __clearHistories(self):
187 """
188 Private slot to clear the combo boxes lists and record a flag to
189 clear the lists.
190 """
191 self.__clearHistoryLists = True
192
193 cmdLine = self.ui.cmdlineCombo.currentText()
194 workdir = self.ui.workdirCombo.currentText()
195 environment = self.ui.environmentCombo.currentText()
196
197 self.ui.cmdlineCombo.clear()
198 self.ui.workdirCombo.clear()
199 self.ui.environmentCombo.clear()
200
201 self.ui.cmdlineCombo.addItem(cmdLine)
202 self.ui.workdirCombo.addItem(workdir)
203 self.ui.environmentCombo.addItem(environment)
204
205 def on_buttonBox_clicked(self, button):
206 """
207 Private slot called by a button of the button box clicked.
208
209 @param button button that was clicked (QAbstractButton)
210 """
211 if button == self.clearButton:
212 self.__clearHistories()

eric ide

mercurial