summaryrefslogtreecommitdiffhomepage
path: root/variant/default/new_file_dialog.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-16 04:33:14 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-16 06:45:52 +0100
commit2b1c5593b0bc1ebfcd2e808f128e4b0312f59d93 (patch)
treee7e8f5d8d3af88a6df37cbd482edcbd3ff8def26 /variant/default/new_file_dialog.cpp
parent3583e3d3cd0b6ca2515ada16ca7dcc8cce83031f (diff)
gui, variant/default: move default UI
Diffstat (limited to 'variant/default/new_file_dialog.cpp')
-rw-r--r--variant/default/new_file_dialog.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/variant/default/new_file_dialog.cpp b/variant/default/new_file_dialog.cpp
new file mode 100644
index 00000000..831fe63e
--- /dev/null
+++ b/variant/default/new_file_dialog.cpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#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::group::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;
+}