Skip to content

Commit 1f7d914

Browse files
committed
GUI: Have separate setting for editor app path and params.
Currently combined editor application path + params is a bit problematic (at least in Windows). We really don't know where the app path ends and parameters start. So proper quoting is not always possible. And application path and command line parameters are clearly different settings anyway. So make them separate settings. It has bunch of other positive sides too. Like one can now browse new path for the application without loosing the parameters. When starting Cppcheck version with these new settings user is warned that loading settings had problems and asked to check and fix the settings.
1 parent f34e9e6 commit 1f7d914

9 files changed

Lines changed: 289 additions & 185 deletions

gui/application.ui

Lines changed: 169 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,169 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<ui version="4.0">
3-
<class>ApplicationDialog</class>
4-
<widget class="QDialog" name="ApplicationDialog">
5-
<property name="windowModality">
6-
<enum>Qt::WindowModal</enum>
7-
</property>
8-
<property name="geometry">
9-
<rect>
10-
<x>0</x>
11-
<y>0</y>
12-
<width>569</width>
13-
<height>300</height>
14-
</rect>
15-
</property>
16-
<property name="windowTitle">
17-
<string>Add an application</string>
18-
</property>
19-
<layout class="QVBoxLayout" name="verticalLayout">
20-
<item>
21-
<widget class="QLabel" name="label">
22-
<property name="text">
23-
<string>Here you can add applications that can open error files.
24-
Specify a name for the application and the application to execute.
25-
26-
The following texts are replaced with appropriate values when application is executed:
27-
(file) - Filename containing the error
28-
(line) - Line number containing the error
29-
(message) - Error message
30-
(severity) - Error severity
31-
32-
Example opening a file with Kate and make Kate scroll to the correct line:
33-
kate -l(line) (file)</string>
34-
</property>
35-
<property name="textFormat">
36-
<enum>Qt::AutoText</enum>
37-
</property>
38-
</widget>
39-
</item>
40-
<item>
41-
<layout class="QHBoxLayout" name="horizontalLayout_2">
42-
<item>
43-
<layout class="QVBoxLayout" name="verticalLayout_3">
44-
<item>
45-
<widget class="QLabel" name="label_2">
46-
<property name="text">
47-
<string>Application's name:</string>
48-
</property>
49-
<property name="buddy">
50-
<cstring>mName</cstring>
51-
</property>
52-
</widget>
53-
</item>
54-
<item>
55-
<widget class="QLabel" name="label_3">
56-
<property name="text">
57-
<string>Command to execute:</string>
58-
</property>
59-
<property name="buddy">
60-
<cstring>mPath</cstring>
61-
</property>
62-
</widget>
63-
</item>
64-
</layout>
65-
</item>
66-
<item>
67-
<layout class="QVBoxLayout" name="verticalLayout_2">
68-
<item>
69-
<widget class="QLineEdit" name="mName"/>
70-
</item>
71-
<item>
72-
<widget class="QLineEdit" name="mPath"/>
73-
</item>
74-
</layout>
75-
</item>
76-
</layout>
77-
</item>
78-
<item>
79-
<layout class="QHBoxLayout" name="horizontalLayout">
80-
<item>
81-
<spacer name="horizontalSpacer">
82-
<property name="orientation">
83-
<enum>Qt::Horizontal</enum>
84-
</property>
85-
<property name="sizeHint" stdset="0">
86-
<size>
87-
<width>40</width>
88-
<height>20</height>
89-
</size>
90-
</property>
91-
</spacer>
92-
</item>
93-
<item>
94-
<widget class="QPushButton" name="mButtonBrowse">
95-
<property name="text">
96-
<string>Browse</string>
97-
</property>
98-
</widget>
99-
</item>
100-
</layout>
101-
</item>
102-
<item>
103-
<widget class="QDialogButtonBox" name="mButtons">
104-
<property name="orientation">
105-
<enum>Qt::Horizontal</enum>
106-
</property>
107-
<property name="standardButtons">
108-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
109-
</property>
110-
</widget>
111-
</item>
112-
</layout>
113-
</widget>
114-
<tabstops>
115-
<tabstop>mName</tabstop>
116-
<tabstop>mPath</tabstop>
117-
<tabstop>mButtonBrowse</tabstop>
118-
<tabstop>mButtons</tabstop>
119-
</tabstops>
120-
<resources/>
121-
<connections>
122-
<connection>
123-
<sender>mButtons</sender>
124-
<signal>accepted()</signal>
125-
<receiver>ApplicationDialog</receiver>
126-
<slot>accept()</slot>
127-
<hints>
128-
<hint type="sourcelabel">
129-
<x>248</x>
130-
<y>254</y>
131-
</hint>
132-
<hint type="destinationlabel">
133-
<x>157</x>
134-
<y>274</y>
135-
</hint>
136-
</hints>
137-
</connection>
138-
<connection>
139-
<sender>mButtons</sender>
140-
<signal>rejected()</signal>
141-
<receiver>ApplicationDialog</receiver>
142-
<slot>reject()</slot>
143-
<hints>
144-
<hint type="sourcelabel">
145-
<x>316</x>
146-
<y>260</y>
147-
</hint>
148-
<hint type="destinationlabel">
149-
<x>286</x>
150-
<y>274</y>
151-
</hint>
152-
</hints>
153-
</connection>
154-
</connections>
155-
</ui>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ApplicationDialog</class>
4+
<widget class="QDialog" name="ApplicationDialog">
5+
<property name="windowModality">
6+
<enum>Qt::WindowModal</enum>
7+
</property>
8+
<property name="geometry">
9+
<rect>
10+
<x>0</x>
11+
<y>0</y>
12+
<width>569</width>
13+
<height>303</height>
14+
</rect>
15+
</property>
16+
<property name="windowTitle">
17+
<string>Add an application</string>
18+
</property>
19+
<layout class="QVBoxLayout" name="verticalLayout">
20+
<item>
21+
<widget class="QLabel" name="label">
22+
<property name="text">
23+
<string>Here you can add applications that can open error files.
24+
Specify a name for the application and the application to execute.
25+
26+
The following texts are replaced with appropriate values when application is executed:
27+
(file) - Filename containing the error
28+
(line) - Line number containing the error
29+
(message) - Error message
30+
(severity) - Error severity
31+
32+
Example opening a file with Kate and make Kate scroll to the correct line:
33+
kate -l(line) (file)</string>
34+
</property>
35+
<property name="textFormat">
36+
<enum>Qt::AutoText</enum>
37+
</property>
38+
</widget>
39+
</item>
40+
<item>
41+
<layout class="QHBoxLayout" name="horizontalLayout_2">
42+
<item>
43+
<layout class="QVBoxLayout" name="verticalLayout_3">
44+
<item>
45+
<widget class="QLabel" name="label_2">
46+
<property name="text">
47+
<string>Application's name:</string>
48+
</property>
49+
<property name="buddy">
50+
<cstring>mName</cstring>
51+
</property>
52+
</widget>
53+
</item>
54+
<item>
55+
<widget class="QLabel" name="label_3">
56+
<property name="text">
57+
<string>Executable:</string>
58+
</property>
59+
<property name="buddy">
60+
<cstring>mPath</cstring>
61+
</property>
62+
</widget>
63+
</item>
64+
<item>
65+
<widget class="QLabel" name="label_4">
66+
<property name="text">
67+
<string>Parameters:</string>
68+
</property>
69+
<property name="buddy">
70+
<cstring>mParameters</cstring>
71+
</property>
72+
</widget>
73+
</item>
74+
</layout>
75+
</item>
76+
<item>
77+
<layout class="QVBoxLayout" name="verticalLayout_2">
78+
<item>
79+
<widget class="QLineEdit" name="mName"/>
80+
</item>
81+
<item>
82+
<widget class="QLineEdit" name="mPath"/>
83+
</item>
84+
<item>
85+
<widget class="QLineEdit" name="mParameters"/>
86+
</item>
87+
</layout>
88+
</item>
89+
</layout>
90+
</item>
91+
<item>
92+
<layout class="QHBoxLayout" name="horizontalLayout">
93+
<item>
94+
<spacer name="horizontalSpacer">
95+
<property name="orientation">
96+
<enum>Qt::Horizontal</enum>
97+
</property>
98+
<property name="sizeHint" stdset="0">
99+
<size>
100+
<width>40</width>
101+
<height>20</height>
102+
</size>
103+
</property>
104+
</spacer>
105+
</item>
106+
<item>
107+
<widget class="QPushButton" name="mButtonBrowse">
108+
<property name="text">
109+
<string>Browse</string>
110+
</property>
111+
</widget>
112+
</item>
113+
</layout>
114+
</item>
115+
<item>
116+
<widget class="QDialogButtonBox" name="mButtons">
117+
<property name="orientation">
118+
<enum>Qt::Horizontal</enum>
119+
</property>
120+
<property name="standardButtons">
121+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
122+
</property>
123+
</widget>
124+
</item>
125+
</layout>
126+
</widget>
127+
<tabstops>
128+
<tabstop>mName</tabstop>
129+
<tabstop>mPath</tabstop>
130+
<tabstop>mParameters</tabstop>
131+
<tabstop>mButtons</tabstop>
132+
<tabstop>mButtonBrowse</tabstop>
133+
</tabstops>
134+
<resources/>
135+
<connections>
136+
<connection>
137+
<sender>mButtons</sender>
138+
<signal>accepted()</signal>
139+
<receiver>ApplicationDialog</receiver>
140+
<slot>accept()</slot>
141+
<hints>
142+
<hint type="sourcelabel">
143+
<x>248</x>
144+
<y>254</y>
145+
</hint>
146+
<hint type="destinationlabel">
147+
<x>157</x>
148+
<y>274</y>
149+
</hint>
150+
</hints>
151+
</connection>
152+
<connection>
153+
<sender>mButtons</sender>
154+
<signal>rejected()</signal>
155+
<receiver>ApplicationDialog</receiver>
156+
<slot>reject()</slot>
157+
<hints>
158+
<hint type="sourcelabel">
159+
<x>316</x>
160+
<y>260</y>
161+
</hint>
162+
<hint type="destinationlabel">
163+
<x>286</x>
164+
<y>274</y>
165+
</hint>
166+
</hints>
167+
</connection>
168+
</connections>
169+
</ui>

gui/applicationdialog.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
ApplicationDialog::ApplicationDialog(const QString &name,
2929
const QString &path,
30+
const QString &params,
3031
const QString &title,
3132
QWidget *parent) :
3233
QDialog(parent)
@@ -38,6 +39,7 @@ ApplicationDialog::ApplicationDialog(const QString &name,
3839
connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
3940
mUI.mPath->setText(path);
4041
mUI.mName->setText(name);
42+
mUI.mParameters->setText(params);
4143
setWindowTitle(title);
4244
}
4345

@@ -88,13 +90,19 @@ QString ApplicationDialog::GetPath()
8890
return mUI.mPath->text();
8991
}
9092

93+
QString ApplicationDialog::GetParams()
94+
{
95+
return mUI.mParameters->text();
96+
}
97+
9198
void ApplicationDialog::Ok()
9299
{
93-
if (mUI.mName->text().isEmpty() || mUI.mPath->text().isEmpty())
100+
if (mUI.mName->text().isEmpty() || mUI.mPath->text().isEmpty() ||
101+
mUI.mParameters->text().isEmpty())
94102
{
95103
QMessageBox msg(QMessageBox::Warning,
96104
tr("Cppcheck"),
97-
tr("You must specify a name and a path for the application!"),
105+
tr("You must specify a name, a path and parameters for the application!"),
98106
QMessageBox::Ok,
99107
this);
100108

gui/applicationdialog.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ class ApplicationDialog : public QDialog
4444
*
4545
* @param name Default name for the application to start
4646
* @param path Path for the application
47+
* @param params Params for the application
4748
* @param title Title for the dialog
4849
* @param parent Parent widget
4950
*/
5051
ApplicationDialog(const QString &name,
5152
const QString &path,
53+
const QString &params,
5254
const QString &title,
5355
QWidget *parent = 0);
5456
virtual ~ApplicationDialog();
@@ -64,10 +66,18 @@ class ApplicationDialog : public QDialog
6466

6567
/**
6668
* @brief Get modified path
67-
* This also contains all parameters user wants to specify.
69+
* This contains the full path to the application executable.
6870
* @return Modified path
6971
*/
7072
QString GetPath();
73+
74+
/**
75+
* @brief Get modified parameters
76+
* This contains the parameters given to the application.
77+
* @return Modified path
78+
*/
79+
QString GetParams();
80+
7181
protected slots:
7282
void Ok();
7383

0 commit comments

Comments
 (0)