-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtargetmaker.cpp
99 lines (82 loc) · 2.03 KB
/
targetmaker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "targetmaker.h"
#include "ui_targetmaker.h"
#include <QFileDialog>
TargetMaker::TargetMaker(QWidget *parent) :
QDialog(parent),
ui(new Ui::TargetMaker)
{
ui->setupUi(this);
accepted = false;
defaultNameInput = "";
defaultCoordInput = "";
defaultDescInput = "";
defaultFileInput = "";
}
TargetMaker::~TargetMaker()
{
delete ui;
}
bool TargetMaker::getAccepted() const
{
return this->accepted;
}
QString TargetMaker::getImageFilePath() const
{
return ui->fileInput->text();
}
QString TargetMaker::getName() const
{
return ui->nameInput->text();
}
QString TargetMaker::getDesc() const
{
return ui->descriptionInput->toPlainText();
}
QString TargetMaker::getCoord() const
{
return ui->coordinateInput->text();
}
void TargetMaker::setDefaultInputs()
{
ui->fileInput->setText(defaultFileInput);
ui->nameInput->setText(defaultNameInput);
ui->coordinateInput->setText(defaultCoordInput);
ui->descriptionInput->setText(defaultDescInput);
}
void TargetMaker::setDefaultNameInput(QString defaultNameInput)
{
this->defaultNameInput = defaultNameInput;
}
void TargetMaker::setDefaultCoordInput(QString defaultCoordInput)
{
this->defaultCoordInput = defaultCoordInput;
}
void TargetMaker::setDefaultDescInput(QString defaultDescInput)
{
this->defaultDescInput = defaultDescInput;
}
void TargetMaker::setDefaultFileInput(QString defaultFileInput)
{
this->defaultFileInput = defaultFileInput;
}
void TargetMaker::on_buttonBox_accepted()
{
accepted = true;
}
void TargetMaker::on_buttonBox_rejected()
{
accepted = false;
}
void TargetMaker::on_toolButton_clicked()
{
// Creates file selection dialog
QFileDialog fileDialog(NULL, tr("Select Preview Image"));
fileDialog.setNameFilter(tr("Images (*.png *.bmp *.jpg)"));
fileDialog.setModal(true);
QString fileName = "";
fileDialog.exec();
// Sets text
if (fileDialog.selectedFiles().length() > 0)
fileName = fileDialog.selectedFiles().at(0);
ui->fileInput->setText(fileName);
}