diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-03-28 13:40:33 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-03-28 13:44:59 +0100 |
commit | 47d4b25bd0583b1fd65ae885950efd34c9df256b (patch) | |
tree | f3a155717092c436e9211e1dc244edc9c9d62fa9 /opentrack/new_file_dialog.cpp | |
parent | 79d56147198dc873e30ae0ca8d554d37106db56f (diff) |
cmake: move around variant directories
Diffstat (limited to 'opentrack/new_file_dialog.cpp')
-rw-r--r-- | opentrack/new_file_dialog.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/opentrack/new_file_dialog.cpp b/opentrack/new_file_dialog.cpp new file mode 100644 index 00000000..70816c5d --- /dev/null +++ b/opentrack/new_file_dialog.cpp @@ -0,0 +1,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; +} |