Skip to content

Commit 68a28ab

Browse files
committed
GUI: Modify ApplicationDialog to get/return Application class.
1 parent 9134523 commit 68a28ab

3 files changed

Lines changed: 30 additions & 62 deletions

File tree

gui/applicationdialog.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
#include <QDebug>
2424
#include <QMessageBox>
2525
#include "applicationdialog.h"
26+
#include "application.h"
2627

2728

28-
ApplicationDialog::ApplicationDialog(const QString &name,
29-
const QString &path,
30-
const QString &params,
31-
const QString &title,
29+
ApplicationDialog::ApplicationDialog(const QString &title,
30+
const Application &app,
3231
QWidget *parent) :
3332
QDialog(parent)
3433
{
@@ -37,9 +36,9 @@ ApplicationDialog::ApplicationDialog(const QString &name,
3736
connect(mUI.mButtonBrowse, SIGNAL(clicked()), this, SLOT(Browse()));
3837
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
3938
connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
40-
mUI.mPath->setText(path);
41-
mUI.mName->setText(name);
42-
mUI.mParameters->setText(params);
39+
mUI.mPath->setText(app.getPath());
40+
mUI.mName->setText(app.getPath());
41+
mUI.mParameters->setText(app.getParameters());
4342
setWindowTitle(title);
4443
}
4544

@@ -69,20 +68,13 @@ void ApplicationDialog::Browse()
6968
}
7069
}
7170

72-
QString ApplicationDialog::GetName()
71+
Application ApplicationDialog::GetApplication() const
7372
{
74-
return mUI.mName->text();
75-
}
76-
77-
78-
QString ApplicationDialog::GetPath()
79-
{
80-
return mUI.mPath->text();
81-
}
82-
83-
QString ApplicationDialog::GetParams()
84-
{
85-
return mUI.mParameters->text();
73+
Application app;
74+
app.setName(mUI.mName->text());
75+
app.setPath(mUI.mPath->text());
76+
app.setParameters(mUI.mParameters->text());
77+
return app;
8678
}
8779

8880
void ApplicationDialog::Ok()

gui/applicationdialog.h

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QDialog>
2323
#include <QLineEdit>
2424
#include <QString>
25+
#include "application.h"
2526
#include "ui_application.h"
2627

2728
class QWidget;
@@ -38,62 +39,41 @@ class QWidget;
3839
class ApplicationDialog : public QDialog
3940
{
4041
Q_OBJECT
42+
4143
public:
4244
/**
43-
* @brief Constructor
44-
*
45-
* @param name Default name for the application to start
46-
* @param path Path for the application
47-
* @param params Params for the application
48-
* @param title Title for the dialog
49-
* @param parent Parent widget
45+
* @brief Constructor.
46+
* @param title Title for the dialog.
47+
* @param app Application definition.
48+
* @param parent Parent widget.
5049
*/
51-
ApplicationDialog(const QString &name,
52-
const QString &path,
53-
const QString &params,
54-
const QString &title,
50+
ApplicationDialog(const QString &title, const Application &app,
5551
QWidget *parent = 0);
5652
virtual ~ApplicationDialog();
5753

5854
/**
59-
* @brief Get modified name
60-
* This is just a name to display the application. This has nothing to do
61-
* with executing the application.
62-
*
55+
* @brief Get modified application
6356
* @return Modified name
6457
*/
65-
QString GetName();
66-
67-
/**
68-
* @brief Get modified path
69-
* This contains the full path to the application executable.
70-
* @return Modified path
71-
*/
72-
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();
58+
Application GetApplication() const;
8059

8160
protected slots:
61+
8262
void Ok();
8363

8464
/**
8565
* @brief Slot to browse for an application
8666
*
8767
*/
8868
void Browse();
69+
8970
protected:
9071

9172
/**
9273
* @brief UI from the Qt designer
9374
*
9475
*/
9576
Ui::ApplicationDialog mUI;
96-
private:
9777
};
9878
/// @}
9979
#endif // APPLICATIONDIALOG_H

gui/settingsdialog.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
198198

199199
void SettingsDialog::AddApplication()
200200
{
201-
ApplicationDialog dialog("", "", "", tr("Add a new application"), this);
201+
Application app;
202+
ApplicationDialog dialog(tr("Add a new application"), app, this);
202203

203204
if (dialog.exec() == QDialog::Accepted)
204205
{
205-
const Application app(dialog.GetName(), dialog.GetPath(),
206-
dialog.GetParams());
206+
const Application app = dialog.GetApplication();
207207
mTempApplications->AddApplication(app);
208-
mUI.mListWidget->addItem(dialog.GetName());
208+
mUI.mListWidget->addItem(app.getName());
209209
}
210210
}
211211

@@ -236,17 +236,13 @@ void SettingsDialog::EditApplication()
236236
{
237237
int row = mUI.mListWidget->row(item);
238238
const Application app = mTempApplications->GetApplication(row);
239-
ApplicationDialog dialog(app.getName(), app.getPath(),
240-
app.getParameters(),
241-
tr("Modify an application"), this);
239+
ApplicationDialog dialog(tr("Modify an application"), app, this);
242240

243241
if (dialog.exec() == QDialog::Accepted)
244242
{
245-
const Application app2(dialog.GetName(),
246-
dialog.GetPath(),
247-
dialog.GetParams());
243+
const Application app2 = dialog.GetApplication();
248244
mTempApplications->SetApplication(row, app2);
249-
item->setText(dialog.GetName());
245+
item->setText(app2.getName());
250246
}
251247
}
252248
}

0 commit comments

Comments
 (0)