-
Notifications
You must be signed in to change notification settings - Fork 57
/
new_project_dialog.cpp
89 lines (78 loc) · 2.22 KB
/
new_project_dialog.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
/*
* This file is part of EasyRPG Editor.
*
* EasyRPG Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Editor. If not, see <http://www.gnu.org/licenses/>.
*/
#include "new_project_dialog.h"
#include "ui_new_project_dialog.h"
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include <QPushButton>
NewProjectDialog::NewProjectDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NewProjectDialog)
{
ui->setupUi(this);
setModal(true);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
NewProjectDialog::~NewProjectDialog()
{
delete ui;
}
QString NewProjectDialog::getProjectFolder() const
{
return ui->lineGameFolder->text();
}
QString NewProjectDialog::getGameTitle() const
{
if (ui->lineGameTitle->text().isEmpty())
return (tr("Untitled"));
return ui->lineGameTitle->text();
}
int NewProjectDialog::getTileSize() const
{
bool *ok = new bool;
int val = ui->comboTileSize->currentText().toInt(ok);
if (!*ok)
val = 16;
return val;
}
void NewProjectDialog::setDefDir(QString n_defDir)
{
if (!n_defDir.endsWith('/'))
n_defDir.append("/");
ui->lineProjectPath->setText(n_defDir);
m_defDir = n_defDir;
}
QString NewProjectDialog::getDefDir()
{
return ui->lineProjectPath->text();
}
void NewProjectDialog::on_toolProjectPath_clicked()
{
QString path = QFileDialog::getExistingDirectory(this,
tr("Select destination folder"),
m_defDir);
if (path == QString())
return;
ui->lineProjectPath->setText(path+"/");
m_defDir = ui->lineProjectPath->text();
}
//TODO: generate RTP template code.
void NewProjectDialog::on_lineGameFolder_textChanged(const QString &arg1)
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!arg1.isEmpty());
}