blob: 70816c5d78ec98b794fd8b93bd6fb89385cf4e86 (
plain)
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
|
#include "new_file_dialog.h"
new_file_dialog::new_file_dialog(QWidget* parent) : QDialog(parent)
{
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(ok_clicked()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancel_clicked()));
setFixedSize(size());
}
bool new_file_dialog::is_ok(QString& name_)
{
name_ = name;
return ok;
}
void new_file_dialog::cancel_clicked() { close(); }
void new_file_dialog::ok_clicked()
{
QString text = ui.lineEdit->text();
text = text.replace('/', "");
text = text.replace('\\', "");
if (text != "" && !text.endsWith(".ini"))
text += ".ini";
if (text == "" || text == ".ini" || QFile(options::globals::ini_directory() + "/" + text).exists())
{
QMessageBox::warning(this,
tr("File exists"),
tr("This file already exists. Pick another name."),
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
ok = true;
close();
name = text;
}
|