Skip to content

Commit 0404b3b

Browse files
committed
Allow to specify working directory for the application ValveSoftware#208
1 parent 434dcc5 commit 0404b3b

5 files changed

+157
-86
lines changed

src/vogleditor/vogleditor.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,9 @@ VoglEditor::Prompt_Result VoglEditor::prompt_generate_trace()
471471
#endif
472472

473473
QString cmdLine = m_pLaunchTracerDialog->get_command_line();
474+
QString workingDir = m_pLaunchTracerDialog->get_application_working_dir();
474475
QProcessEnvironment env = m_pLaunchTracerDialog->get_process_environment();
475-
bool bSuccess = launch_application_to_generate_trace(cmdLine, env);
476+
bool bSuccess = launch_application_to_generate_trace(cmdLine, workingDir, env);
476477
QFileInfo fileInfo(m_pLaunchTracerDialog->get_trace_file_path());
477478
if (bSuccess && fileInfo.exists())
478479
{
@@ -494,7 +495,7 @@ VoglEditor::Prompt_Result VoglEditor::prompt_generate_trace()
494495
return vogleditor_prompt_success;
495496
}
496497

497-
bool VoglEditor::launch_application_to_generate_trace(const QString &cmdLine, const QProcessEnvironment &environment)
498+
bool VoglEditor::launch_application_to_generate_trace(const QString &cmdLine, const QString &workingDir, const QProcessEnvironment &environment)
498499
{
499500
vogleditor_output_message("Tracing application:");
500501
vogleditor_output_message(cmdLine.toStdString().c_str());
@@ -505,6 +506,10 @@ bool VoglEditor::launch_application_to_generate_trace(const QString &cmdLine, co
505506
m_pVoglReplayProcess->setProcessEnvironment(environment);
506507

507508
bool bCompleted = false;
509+
if (!workingDir.isEmpty())
510+
{
511+
m_pVoglReplayProcess->setWorkingDirectory(workingDir);
512+
}
508513
m_pVoglReplayProcess->start(cmdLine);
509514
if (m_pVoglReplayProcess->waitForStarted() == false)
510515
{

src/vogleditor/vogleditor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private
151151
bool displayBuffer(GLuint64 bufferHandle, bool bBringTabToFront);
152152
bool resetApiCallTreeModel();
153153

154-
bool launch_application_to_generate_trace(const QString &cmdLine, const QProcessEnvironment &environment);
154+
bool launch_application_to_generate_trace(const QString &cmdLine, const QString &workingDir, const QProcessEnvironment &environment);
155155

156156
Prompt_Result prompt_load_new_trace(const char *tracefile);
157157

src/vogleditor/vogleditor_qlaunchtracerdialog.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ QString vogleditor_QLaunchTracerDialog::get_application_to_launch()
152152
return ui->applicationLineEdit->text();
153153
}
154154

155+
QString vogleditor_QLaunchTracerDialog::get_application_working_dir()
156+
{
157+
return ui->workingDirLineEdit->text();
158+
}
159+
155160
void vogleditor_QLaunchTracerDialog::on_applicationLineEdit_textChanged(const QString &text)
156161
{
157162
check_inputs();
@@ -162,6 +167,11 @@ void vogleditor_QLaunchTracerDialog::on_traceFileLineEdit_textChanged(const QStr
162167
check_inputs();
163168
}
164169

170+
void vogleditor_QLaunchTracerDialog::on_workingDirLineEdit_textChanged(const QString &text)
171+
{
172+
check_inputs();
173+
}
174+
165175
void vogleditor_QLaunchTracerDialog::check_inputs()
166176
{
167177
bool applicationFileEntered = ui->applicationLineEdit->text().size() != 0;
@@ -182,6 +192,18 @@ void vogleditor_QLaunchTracerDialog::on_findApplicationButton_clicked()
182192
}
183193
}
184194

195+
void vogleditor_QLaunchTracerDialog::on_findWorkingDirButton_clicked()
196+
{
197+
// open file dialog
198+
QString suggestedName = ui->workingDirLineEdit->text();
199+
QString selectedName = QFileDialog::getExistingDirectory(this, tr("Find Application working directory"), suggestedName);
200+
201+
if (!selectedName.isEmpty())
202+
{
203+
ui->workingDirLineEdit->setText(selectedName);
204+
}
205+
}
206+
185207
void vogleditor_QLaunchTracerDialog::on_findTraceFileButton_clicked()
186208
{
187209
// open file dialog

src/vogleditor/vogleditor_qlaunchtracerdialog.h

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class vogleditor_QLaunchTracerDialog : public QDialog
1818
~vogleditor_QLaunchTracerDialog();
1919

2020
QString get_application_to_launch();
21+
QString get_application_working_dir();
2122
QString get_command_line();
2223
QProcessEnvironment get_process_environment();
2324
QString get_trace_file_path();
@@ -28,8 +29,12 @@ private
2829

2930
void on_traceFileLineEdit_textChanged(const QString &text);
3031

32+
void on_workingDirLineEdit_textChanged(const QString &text);
33+
3134
void on_findApplicationButton_clicked();
3235

36+
void on_findWorkingDirButton_clicked();
37+
3338
void on_findTraceFileButton_clicked();
3439

3540
void on_vogltraceCheckBox_clicked(bool checked);

src/vogleditor/vogleditor_qlaunchtracerdialog.ui

+122-83
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,24 @@
2020
<property name="verticalSpacing">
2121
<number>0</number>
2222
</property>
23-
<item row="2" column="1">
24-
<widget class="QLineEdit" name="traceFileLineEdit">
23+
<item row="4" column="0">
24+
<widget class="QLabel" name="label_4">
2525
<property name="text">
26-
<string/>
26+
<string>Vogl options:</string>
27+
</property>
28+
<property name="alignment">
29+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
2730
</property>
2831
</widget>
2932
</item>
30-
<item row="2" column="2">
31-
<widget class="QPushButton" name="findTraceFileButton">
33+
<item row="2" column="2" colspan="2">
34+
<widget class="QLineEdit" name="argumentsLineEdit">
3235
<property name="sizePolicy">
33-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
36+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
3437
<horstretch>0</horstretch>
3538
<verstretch>0</verstretch>
3639
</sizepolicy>
3740
</property>
38-
<property name="minimumSize">
39-
<size>
40-
<width>0</width>
41-
<height>0</height>
42-
</size>
43-
</property>
44-
<property name="maximumSize">
45-
<size>
46-
<width>20</width>
47-
<height>16777215</height>
48-
</size>
49-
</property>
50-
<property name="text">
51-
<string>...</string>
52-
</property>
5341
</widget>
5442
</item>
5543
<item row="0" column="0">
@@ -71,21 +59,7 @@
7159
</property>
7260
</widget>
7361
</item>
74-
<item row="5" column="1">
75-
<widget class="QCheckBox" name="forceDebugContextCheckBox">
76-
<property name="text">
77-
<string>Force debug context</string>
78-
</property>
79-
</widget>
80-
</item>
81-
<item row="7" column="1">
82-
<widget class="QCheckBox" name="disableProgramBinaryCheckBox">
83-
<property name="text">
84-
<string>Disable glProgramBinary</string>
85-
</property>
86-
</widget>
87-
</item>
88-
<item row="0" column="2">
62+
<item row="0" column="3">
8963
<widget class="QPushButton" name="findApplicationButton">
9064
<property name="sizePolicy">
9165
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@@ -104,86 +78,72 @@
10478
</property>
10579
</widget>
10680
</item>
107-
<item row="1" column="0">
108-
<widget class="QLabel" name="label_2">
81+
<item row="3" column="3">
82+
<widget class="QPushButton" name="findTraceFileButton">
10983
<property name="sizePolicy">
110-
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
84+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
11185
<horstretch>0</horstretch>
11286
<verstretch>0</verstretch>
11387
</sizepolicy>
11488
</property>
115-
<property name="text">
116-
<string>Application arguments:</string>
117-
</property>
118-
<property name="alignment">
119-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
89+
<property name="minimumSize">
90+
<size>
91+
<width>0</width>
92+
<height>0</height>
93+
</size>
12094
</property>
121-
</widget>
122-
</item>
123-
<item row="0" column="1">
124-
<widget class="QLineEdit" name="applicationLineEdit">
125-
<property name="sizePolicy">
126-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
127-
<horstretch>1</horstretch>
128-
<verstretch>0</verstretch>
129-
</sizepolicy>
95+
<property name="maximumSize">
96+
<size>
97+
<width>20</width>
98+
<height>16777215</height>
99+
</size>
130100
</property>
131101
<property name="text">
132-
<string/>
102+
<string>...</string>
133103
</property>
134104
</widget>
135105
</item>
136-
<item row="2" column="0">
137-
<widget class="QLabel" name="label_3">
106+
<item row="3" column="2">
107+
<widget class="QLineEdit" name="traceFileLineEdit">
138108
<property name="text">
139-
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;Output trace file:</string>
140-
</property>
141-
<property name="alignment">
142-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
109+
<string/>
143110
</property>
144111
</widget>
145112
</item>
146-
<item row="3" column="0">
147-
<widget class="QLabel" name="label_4">
113+
<item row="4" column="2">
114+
<widget class="QCheckBox" name="vogltraceCheckBox">
115+
<property name="statusTip">
116+
<string/>
117+
</property>
148118
<property name="text">
149-
<string>Vogl options:</string>
119+
<string>Use vogl tool</string>
150120
</property>
151-
<property name="alignment">
152-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
121+
<property name="checked">
122+
<bool>false</bool>
153123
</property>
154124
</widget>
155125
</item>
156-
<item row="6" column="1">
157-
<widget class="QCheckBox" name="gatherCallStacksCheckBox">
126+
<item row="6" column="2">
127+
<widget class="QCheckBox" name="forceDebugContextCheckBox">
158128
<property name="text">
159-
<string>Gather call stacks</string>
129+
<string>Force debug context</string>
160130
</property>
161131
</widget>
162132
</item>
163-
<item row="1" column="1" colspan="2">
164-
<widget class="QLineEdit" name="argumentsLineEdit">
133+
<item row="0" column="2">
134+
<widget class="QLineEdit" name="applicationLineEdit">
165135
<property name="sizePolicy">
166136
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
167-
<horstretch>0</horstretch>
137+
<horstretch>1</horstretch>
168138
<verstretch>0</verstretch>
169139
</sizepolicy>
170140
</property>
171-
</widget>
172-
</item>
173-
<item row="3" column="1">
174-
<widget class="QCheckBox" name="vogltraceCheckBox">
175-
<property name="statusTip">
176-
<string/>
177-
</property>
178141
<property name="text">
179-
<string>Use vogl tool</string>
180-
</property>
181-
<property name="checked">
182-
<bool>false</bool>
142+
<string/>
183143
</property>
184144
</widget>
185145
</item>
186-
<item row="8" column="0" colspan="2">
146+
<item row="9" column="0" colspan="3">
187147
<widget class="QFrame" name="frame">
188148
<property name="frameShape">
189149
<enum>QFrame::NoFrame</enum>
@@ -250,6 +210,85 @@
250210
</layout>
251211
</widget>
252212
</item>
213+
<item row="3" column="0">
214+
<widget class="QLabel" name="label_3">
215+
<property name="text">
216+
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;Output trace file:</string>
217+
</property>
218+
<property name="alignment">
219+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
220+
</property>
221+
</widget>
222+
</item>
223+
<item row="7" column="2">
224+
<widget class="QCheckBox" name="gatherCallStacksCheckBox">
225+
<property name="text">
226+
<string>Gather call stacks</string>
227+
</property>
228+
</widget>
229+
</item>
230+
<item row="2" column="0">
231+
<widget class="QLabel" name="label_2">
232+
<property name="sizePolicy">
233+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
234+
<horstretch>0</horstretch>
235+
<verstretch>0</verstretch>
236+
</sizepolicy>
237+
</property>
238+
<property name="text">
239+
<string>Application arguments:</string>
240+
</property>
241+
<property name="alignment">
242+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
243+
</property>
244+
</widget>
245+
</item>
246+
<item row="8" column="2">
247+
<widget class="QCheckBox" name="disableProgramBinaryCheckBox">
248+
<property name="text">
249+
<string>Disable glProgramBinary</string>
250+
</property>
251+
</widget>
252+
</item>
253+
<item row="1" column="0">
254+
<widget class="QLabel" name="label_5">
255+
<property name="text">
256+
<string>Application working dir:</string>
257+
</property>
258+
<property name="alignment">
259+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
260+
</property>
261+
</widget>
262+
</item>
263+
<item row="1" column="2">
264+
<widget class="QLineEdit" name="workingDirLineEdit">
265+
<property name="sizePolicy">
266+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
267+
<horstretch>1</horstretch>
268+
<verstretch>0</verstretch>
269+
</sizepolicy>
270+
</property>
271+
</widget>
272+
</item>
273+
<item row="1" column="3">
274+
<widget class="QPushButton" name="findWorkingDirButton">
275+
<property name="sizePolicy">
276+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
277+
<horstretch>0</horstretch>
278+
<verstretch>0</verstretch>
279+
</sizepolicy>
280+
</property>
281+
<property name="maximumSize">
282+
<size>
283+
<width>20</width>
284+
<height>16777215</height>
285+
</size>
286+
</property>
287+
<property name="text">
288+
<string>...</string>
289+
</property>
290+
</widget>
291+
</item>
253292
</layout>
254293
</widget>
255294
<tabstops>

0 commit comments

Comments
 (0)