Skip to content

Commit abf0a2e

Browse files
committed
GUI: Add buttons to add new paths to ProjectFile dialog.
1 parent ba7a3b3 commit abf0a2e

3 files changed

Lines changed: 81 additions & 7 deletions

File tree

‎gui/projectfile.ui‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>400</width>
10-
<height>131</height>
10+
<height>159</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -46,6 +46,13 @@
4646
<item>
4747
<widget class="QLineEdit" name="mEditPaths"/>
4848
</item>
49+
<item>
50+
<widget class="QPushButton" name="mBtnBrowsePaths">
51+
<property name="text">
52+
<string>Browse...</string>
53+
</property>
54+
</widget>
55+
</item>
4956
</layout>
5057
</item>
5158
<item>
@@ -63,6 +70,13 @@
6370
<item>
6471
<widget class="QLineEdit" name="mEditIncludePaths"/>
6572
</item>
73+
<item>
74+
<widget class="QPushButton" name="mBtnBrowseIncludes">
75+
<property name="text">
76+
<string>Browse...</string>
77+
</property>
78+
</widget>
79+
</item>
6680
</layout>
6781
</item>
6882
<item>
@@ -110,7 +124,9 @@
110124
<tabstops>
111125
<tabstop>mEditProjectRoot</tabstop>
112126
<tabstop>mEditPaths</tabstop>
127+
<tabstop>mBtnBrowsePaths</tabstop>
113128
<tabstop>mEditIncludePaths</tabstop>
129+
<tabstop>mBtnBrowseIncludes</tabstop>
114130
<tabstop>mEditDefines</tabstop>
115131
<tabstop>mButtons</tabstop>
116132
</tabstops>
@@ -123,12 +139,12 @@
123139
<slot>accept()</slot>
124140
<hints>
125141
<hint type="sourcelabel">
126-
<x>248</x>
127-
<y>254</y>
142+
<x>257</x>
143+
<y>148</y>
128144
</hint>
129145
<hint type="destinationlabel">
130146
<x>157</x>
131-
<y>274</y>
147+
<y>158</y>
132148
</hint>
133149
</hints>
134150
</connection>
@@ -139,12 +155,12 @@
139155
<slot>reject()</slot>
140156
<hints>
141157
<hint type="sourcelabel">
142-
<x>316</x>
143-
<y>260</y>
158+
<x>325</x>
159+
<y>148</y>
144160
</hint>
145161
<hint type="destinationlabel">
146162
<x>286</x>
147-
<y>274</y>
163+
<y>158</y>
148164
</hint>
149165
</hints>
150166
</connection>

‎gui/projectfiledialog.cpp‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <QString>
2222
#include <QStringList>
2323
#include <QFileInfo>
24+
#include <QFileDialog>
25+
#include <QLineEdit>
2426
#include "projectfiledialog.h"
2527

2628
ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
@@ -34,6 +36,8 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
3436
setWindowTitle(title);
3537

3638
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
39+
connect(mUI.mBtnBrowseIncludes, SIGNAL(clicked()), this, SLOT(BrowseIncludes()));
40+
connect(mUI.mBtnBrowsePaths, SIGNAL(clicked()), this, SLOT(BrowsePaths()));
3741
}
3842

3943
QString ProjectFileDialog::GetRootPath() const
@@ -137,3 +141,35 @@ void ProjectFileDialog::SetPaths(const QStringList &paths)
137141
pathstr = pathstr.left(pathstr.length() - 1);
138142
mUI.mEditPaths->setText(pathstr);
139143
}
144+
145+
void ProjectFileDialog::BrowseIncludes()
146+
{
147+
QString selectedDir = QFileDialog::getExistingDirectory(this,
148+
tr("Select include directory"),
149+
QString());
150+
151+
if (!selectedDir.isEmpty())
152+
{
153+
AppendDirname(mUI.mEditIncludePaths, selectedDir);
154+
}
155+
}
156+
157+
void ProjectFileDialog::BrowsePaths()
158+
{
159+
QString selectedDir = QFileDialog::getExistingDirectory(this,
160+
tr("Select directory to check"),
161+
QString());
162+
163+
if (!selectedDir.isEmpty())
164+
{
165+
AppendDirname(mUI.mEditPaths, selectedDir);
166+
}
167+
}
168+
169+
void ProjectFileDialog::AppendDirname(QLineEdit *edit, const QString &dir)
170+
{
171+
QString wholeText = edit->text();
172+
wholeText += ";";
173+
wholeText += dir;
174+
edit->setText(wholeText);
175+
}

‎gui/projectfiledialog.h‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "ui_projectfile.h"
2727

2828
class ProjectFile;
29+
class QWidget;
30+
class QLineEdit;
2931

3032
/// @addtogroup GUI
3133
/// @{
@@ -88,6 +90,26 @@ class ProjectFileDialog : public QDialog
8890
*/
8991
void SetPaths(const QStringList &paths);
9092

93+
protected slots:
94+
/**
95+
* @brief Browse for include directory.
96+
* Allow user to choose new include directory.
97+
*/
98+
void BrowseIncludes();
99+
/**
100+
* @brief Browse for checked directory.
101+
* Allow user to choose new checked directory.
102+
*/
103+
void BrowsePaths();
104+
105+
protected:
106+
/**
107+
* @brief Append new path to the edit control.
108+
* @param edit Edit control to modify.
109+
* @param dir Path to add.
110+
*/
111+
void AppendDirname(QLineEdit *edit, const QString &dir);
112+
91113
private:
92114
Ui::ProjectFile mUI;
93115
};

0 commit comments

Comments
 (0)