-
Notifications
You must be signed in to change notification settings - Fork 57
/
import_project_dialog.cpp
98 lines (87 loc) · 2.57 KB
/
import_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
90
91
92
93
94
95
96
97
98
/*
* 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 "import_project_dialog.h"
#include "ui_import_project_dialog.h"
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
#include <QPushButton>
ImportProjectDialog::ImportProjectDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ImportProjectDialog)
{
ui->setupUi(this);
setModal(true);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
ImportProjectDialog::~ImportProjectDialog()
{
delete ui;
}
QString ImportProjectDialog::getProjectFolder() const
{
return ui->lineGameFolder->text();
}
QString ImportProjectDialog::getSourceFolder() const
{
return ui->lineSourcePath->text();
}
void ImportProjectDialog::setDefDir(QString n_defDir)
{
if (!n_defDir.endsWith('/'))
n_defDir.append("/");
ui->lineProjectPath->setText(n_defDir);
m_defDir = n_defDir;
}
QString ImportProjectDialog::getDefDir()
{
return ui->lineProjectPath->text();
}
bool ImportProjectDialog::getConvertXYZ() const {
return ui->checkConvertXYZ->isChecked();
}
void ImportProjectDialog::on_lineGameFolder_textChanged(const QString &arg1)
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!arg1.isEmpty());
}
void ImportProjectDialog::on_toolProjectPath_clicked()
{
QString path = QFileDialog::getExistingDirectory(this,
tr("Select destination folder"),
m_defDir);
if (path.isEmpty())
return;
ui->lineProjectPath->setText(path+"/");
m_defDir = ui->lineProjectPath->text();
}
void ImportProjectDialog::on_toolSourcePath_clicked()
{
QString path = QFileDialog::getExistingDirectory(this,
tr("Select origin folder"),
m_defDir);
if (path.isEmpty())
return;
if (!QFileInfo(path+"/RPG_RT.ldb").exists())
{
QMessageBox::critical(this,
tr("Error"),
tr("This folder does not contain a valid RPG Maker project"));
return;
}
ui->lineSourcePath->setText(path+"/");
ui->lineGameFolder->setText(QDir(path).dirName());
}