Skip to content

Commit e973f96

Browse files
committed
Settings dialog and application dialog now use Qt Designer ui files.
1 parent 97508ad commit e973f96

File tree

7 files changed

+78
-260
lines changed

7 files changed

+78
-260
lines changed

gui/application.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ kate -l(line) (file)</string>
6363
</layout>
6464
</item>
6565
<item>
66-
<widget class="QDialogButtonBox" name="buttonBox">
66+
<widget class="QDialogButtonBox" name="mButtons">
6767
<property name="orientation">
6868
<enum>Qt::Horizontal</enum>
6969
</property>
@@ -77,7 +77,7 @@ kate -l(line) (file)</string>
7777
<resources/>
7878
<connections>
7979
<connection>
80-
<sender>buttonBox</sender>
80+
<sender>mButtons</sender>
8181
<signal>accepted()</signal>
8282
<receiver>ApplicationDialog</receiver>
8383
<slot>accept()</slot>
@@ -93,7 +93,7 @@ kate -l(line) (file)</string>
9393
</hints>
9494
</connection>
9595
<connection>
96-
<sender>buttonBox</sender>
96+
<sender>mButtons</sender>
9797
<signal>rejected()</signal>
9898
<receiver>ApplicationDialog</receiver>
9999
<slot>reject()</slot>

gui/applicationdialog.cpp

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,13 @@ ApplicationDialog::ApplicationDialog(const QString &name,
3232
QWidget *parent) :
3333
QDialog(parent)
3434
{
35-
QVBoxLayout *layout = new QVBoxLayout();
36-
mName = new QLineEdit(name);
37-
mName->setMaxLength(100); // Should be plenty for app name
38-
mPath = new QLineEdit(QDir::toNativeSeparators(path));
39-
40-
QString guide = tr("Here you can add applications that can open error files.\n" \
41-
"Specify a name for the application and the application to execute.\n\n" \
42-
"The following texts are replaced with appriproate values when application is executed:\n" \
43-
"(file) - Filename containing the error\n" \
44-
"(line) - Line number containing the error\n" \
45-
"(message) - Error message\n" \
46-
"(severity) - Error severity\n" \
47-
"\n" \
48-
"Example opening a file with Kate and make Kate scroll to the correct line:\n" \
49-
"kate -l(line) (file)");
50-
51-
layout->addWidget(new QLabel(guide));
52-
53-
layout->addWidget(new QLabel(tr("Application's name")));
54-
layout->addWidget(mName);
55-
layout->addWidget(new QLabel(tr("Application to execute")));
56-
layout->addWidget(mPath);
57-
QPushButton *browse = new QPushButton(tr("Browse"));
58-
connect(browse, SIGNAL(clicked()), this, SLOT(Browse()));
59-
layout->addWidget(browse);
60-
61-
QPushButton *cancel = new QPushButton(tr("Cancel"));
62-
QPushButton *ok = new QPushButton(tr("Ok"));
63-
64-
//Add a layout for ok/cancel buttons
65-
QHBoxLayout *buttonLayout = new QHBoxLayout();
66-
buttonLayout->addWidget(ok);
67-
buttonLayout->addWidget(cancel);
68-
layout->addLayout(buttonLayout);
69-
70-
//Connect OK buttons
71-
connect(ok, SIGNAL(clicked()),
72-
this, SLOT(Ok()));
73-
connect(cancel, SIGNAL(clicked()),
74-
this, SLOT(reject()));
75-
setLayout(layout);
35+
mUI.setupUi(this);
36+
37+
connect(mUI.mButtonBrowse, SIGNAL(clicked()), this, SLOT(Browse()));
38+
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
39+
connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
40+
mUI.mPath->setText(path);
41+
mUI.mName->setText(name);
7642
setWindowTitle(title);
7743
}
7844

@@ -108,24 +74,24 @@ void ApplicationDialog::Browse()
10874
}
10975
#endif // Q_WS_WIN
11076

111-
mPath->setText(path);
77+
mUI.mPath->setText(path);
11278
}
11379
}
11480

11581
QString ApplicationDialog::GetName()
11682
{
117-
return mName->text();
83+
return mUI.mName->text();
11884
}
11985

12086

12187
QString ApplicationDialog::GetPath()
12288
{
123-
return mPath->text();
89+
return mUI.mPath->text();
12490
}
12591

12692
void ApplicationDialog::Ok()
12793
{
128-
if (mName->text().isEmpty() || mPath->text().isEmpty())
94+
if (mUI.mName->text().isEmpty() || mUI.mPath->text().isEmpty())
12995
{
13096
QMessageBox msg(QMessageBox::Warning,
13197
tr("Cppcheck"),
@@ -139,7 +105,7 @@ void ApplicationDialog::Ok()
139105
else
140106
{
141107
// Convert possible native (Windows) path to internal presentation format
142-
mPath->setText(QDir::fromNativeSeparators(mPath->text()));
108+
mUI.mPath->setText(QDir::fromNativeSeparators(mUI.mPath->text()));
143109
accept();
144110
}
145111
}

gui/applicationdialog.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <QDialog>
2323
#include <QLineEdit>
24+
#include "ui_application.h"
2425

2526
/**
2627
* @brief Dialog to edit a startable application.
@@ -70,18 +71,12 @@ protected slots:
7071
*/
7172
void Browse();
7273
protected:
73-
/**
74-
* @brief Editbox for the application's name
75-
* This is just a name to display the application. This has nothing to do
76-
* with executing the application.
77-
*/
78-
QLineEdit *mName;
7974

8075
/**
81-
* @brief Editbox for the application's path
82-
* This also contains all parameters user wants to specify.
76+
* @brief UI from the Qt designer
77+
*
8378
*/
84-
QLineEdit *mPath;
79+
Ui::ApplicationDialog mUI;
8580
private:
8681
};
8782

gui/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ void MainWindow::SetLanguage(int index)
580580

581581
if (languages.size() <= actions.size())
582582
{
583-
for (int i=0;i<languages.size();i++)
583+
for (int i = 0;i < languages.size();i++)
584584
{
585585
actions[i]->setText(tr(languages[i].toLatin1()));
586586
}

gui/settings.ui

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<item>
1818
<widget class="QTabWidget" name="tabWidget">
1919
<property name="currentIndex">
20-
<number>0</number>
20+
<number>1</number>
2121
</property>
2222
<widget class="QWidget" name="tab">
2323
<attribute name="title">
@@ -36,26 +36,26 @@
3636
</widget>
3737
</item>
3838
<item>
39-
<widget class="QLineEdit" name="lineEdit"/>
39+
<widget class="QLineEdit" name="mJobs"/>
4040
</item>
4141
</layout>
4242
</item>
4343
<item>
44-
<widget class="QCheckBox" name="checkBox">
44+
<widget class="QCheckBox" name="mForce">
4545
<property name="text">
4646
<string>Check all #ifdef configurations</string>
4747
</property>
4848
</widget>
4949
</item>
5050
<item>
51-
<widget class="QCheckBox" name="checkBox_2">
51+
<widget class="QCheckBox" name="mShowFullPath">
5252
<property name="text">
5353
<string>Show full path of files</string>
5454
</property>
5555
</widget>
5656
</item>
5757
<item>
58-
<widget class="QCheckBox" name="checkBox_3">
58+
<widget class="QCheckBox" name="mShowNoErrorsMessage">
5959
<property name="text">
6060
<string>Show &quot;No errors found&quot; message when no errors found</string>
6161
</property>
@@ -122,14 +122,14 @@
122122
</attribute>
123123
<layout class="QVBoxLayout" name="verticalLayout_3">
124124
<item>
125-
<widget class="QCheckBox" name="checkBox_4">
125+
<widget class="QCheckBox" name="mSaveAllErrors">
126126
<property name="text">
127127
<string>Save all errors when creating report</string>
128128
</property>
129129
</widget>
130130
</item>
131131
<item>
132-
<widget class="QCheckBox" name="checkBox_5">
132+
<widget class="QCheckBox" name="mSaveFullPath">
133133
<property name="text">
134134
<string>Save full path to files in reports</string>
135135
</property>
@@ -153,7 +153,7 @@
153153
</widget>
154154
</item>
155155
<item>
156-
<widget class="QDialogButtonBox" name="buttonBox">
156+
<widget class="QDialogButtonBox" name="mButtons">
157157
<property name="orientation">
158158
<enum>Qt::Horizontal</enum>
159159
</property>
@@ -167,7 +167,7 @@
167167
<resources/>
168168
<connections>
169169
<connection>
170-
<sender>buttonBox</sender>
170+
<sender>mButtons</sender>
171171
<signal>accepted()</signal>
172172
<receiver>Settings</receiver>
173173
<slot>accept()</slot>
@@ -183,7 +183,7 @@
183183
</hints>
184184
</connection>
185185
<connection>
186-
<sender>buttonBox</sender>
186+
<sender>mButtons</sender>
187187
<signal>rejected()</signal>
188188
<receiver>Settings</receiver>
189189
<slot>reject()</slot>

0 commit comments

Comments
 (0)