summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/new_file_dialog.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-22 19:02:25 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-08-22 19:02:25 +0200
commit4ab33fdfbb23fdfed5327d402989fd53d79f5380 (patch)
treeeef1c2f20d1d9bfe7d44b3a7f4e1bcb2f568d4ec /facetracknoir/new_file_dialog.h
parent05203f39e6314c09f65d69c028b9f9d864de3f7b (diff)
main, ui: store config files in a predefined directory
Settings files are now stored in Documents/opentrack-version. The transition path is to copy all .ini files into that directory, accessible through the "Profile" menu dropdown. Issue: #179
Diffstat (limited to 'facetracknoir/new_file_dialog.h')
-rw-r--r--facetracknoir/new_file_dialog.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h
new file mode 100644
index 00000000..dc821592
--- /dev/null
+++ b/facetracknoir/new_file_dialog.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#include "ui_new_config.h"
+#include "opentrack/options.hpp"
+#include <QFile>
+#include <QRegExp>
+#include <QString>
+#include <QMessageBox>
+
+class new_file_dialog : public QDialog
+{
+ Q_OBJECT
+public:
+ new_file_dialog(QWidget* parent = 0) : QDialog(parent), ok(false)
+ {
+ ui.setupUi(this);
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(ok_clicked()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancel_clicked()));
+ setFixedSize(size());
+ }
+ bool is_ok(QString& name_)
+ {
+ name_ = name;
+ return ok;
+ }
+private:
+ Ui::UI_new_config ui;
+ bool ok;
+ QString name;
+private slots:
+ void cancel_clicked() { close(); }
+ void ok_clicked()
+ {
+ QString text = ui.lineEdit->text();
+ text = text.replace('/', "");
+ text = text.replace('\\', "");
+ if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists())
+ {
+ QMessageBox::warning(this,
+ "File exists", "This file already exists. Pick another name.",
+ QMessageBox::Ok, QMessageBox::NoButton);
+ return;
+ }
+ ok = true;
+ close();
+ name = text;
+ }
+};