summaryrefslogtreecommitdiffhomepage
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
parent3583e3d3cd0b6ca2515ada16ca7dcc8cce83031f (diff)
gui, variant/default: move default UI
-rw-r--r--gui/init.cpp35
-rw-r--r--gui/keyboard.cpp2
-rw-r--r--gui/new_file_dialog.h51
-rw-r--r--variant/default/main-window.cpp (renamed from gui/main-window.cpp)0
-rw-r--r--variant/default/main-window.hpp (renamed from gui/main-window.hpp)2
-rw-r--r--variant/default/main-window.ui (renamed from gui/main-window.ui)0
-rw-r--r--variant/default/main.cpp2
-rw-r--r--variant/default/new_config.ui (renamed from gui/new_config.ui)0
-rw-r--r--variant/default/new_file_dialog.cpp39
-rw-r--r--variant/default/new_file_dialog.h25
10 files changed, 86 insertions, 70 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index 3ed4ff48..fde6f256 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -12,15 +12,14 @@
#endif
#include "migration/migration.hpp"
-#include "gui/main-window.hpp"
#include "options/options.hpp"
using namespace options;
#include "opentrack-library-path.h"
#include <memory>
+#include <cstdlib>
#include <cstring>
#include <cstdio>
-#include <cstdlib>
#include <QApplication>
#include <QStyleFactory>
@@ -94,19 +93,6 @@ void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QString &
std::fflush(stderr);
}
-void attach_parent_console()
-{
- if (AttachConsole(ATTACH_PARENT_PROCESS))
- {
- // XXX c++ iostreams aren't reopened
-
- _wfreopen(L"CON", L"w", stdout);
- _wfreopen(L"CON", L"w", stderr);
- _wfreopen(L"CON", L"r", stdin);
- }
- (void)qInstallMessageHandler(qdebug_to_console);
-}
-
void add_win32_path()
{
// see https://software.intel.com/en-us/articles/limitation-to-the-length-of-the-system-path-variable
@@ -157,6 +143,8 @@ void add_win32_path()
}
}
+void attach_parent_console();
+
#endif
int run_window(QApplication& app, std::unique_ptr<QWidget> main_window)
@@ -226,3 +214,20 @@ int otr_main(int argc, char** argv, std::function<QWidget*()> make_main_window)
return ret;
}
+
+#if defined _WIN32
+#include <windows.h>
+
+void attach_parent_console()
+{
+ if (AttachConsole(ATTACH_PARENT_PROCESS))
+ {
+ // XXX c++ iostreams aren't reopened
+
+ _wfreopen(L"CON", L"w", stdout);
+ _wfreopen(L"CON", L"w", stderr);
+ _wfreopen(L"CON", L"r", stdin);
+ }
+ (void)qInstallMessageHandler(qdebug_to_console);
+}
+#endif
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index e24d4644..4987d9c0 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -5,7 +5,7 @@
keyboard_listener::keyboard_listener(QWidget* parent) :
QDialog(parent)
#if defined _WIN32
- , token([&](const Key& k) {
+ , token([this](const Key& k) {
if(k.guid != "")
{
int mods = 0;
diff --git a/gui/new_file_dialog.h b/gui/new_file_dialog.h
deleted file mode 100644
index cd5ca528..00000000
--- a/gui/new_file_dialog.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#pragma once
-
-#include "ui_new_config.h"
-#include "options/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 != "" && !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;
- }
-};
diff --git a/gui/main-window.cpp b/variant/default/main-window.cpp
index 9d27afdc..9d27afdc 100644
--- a/gui/main-window.cpp
+++ b/variant/default/main-window.cpp
diff --git a/gui/main-window.hpp b/variant/default/main-window.hpp
index 899fbe0b..844542f1 100644
--- a/gui/main-window.hpp
+++ b/variant/default/main-window.hpp
@@ -8,8 +8,6 @@
#pragma once
-#include "export.hpp"
-
#include "api/plugin-support.hpp"
#include "gui/mapping-dialog.hpp"
#include "gui/settings.hpp"
diff --git a/gui/main-window.ui b/variant/default/main-window.ui
index ce8e161f..ce8e161f 100644
--- a/gui/main-window.ui
+++ b/variant/default/main-window.ui
diff --git a/variant/default/main.cpp b/variant/default/main.cpp
index e539c635..3ee93422 100644
--- a/variant/default/main.cpp
+++ b/variant/default/main.cpp
@@ -1,5 +1,5 @@
#include "gui/init.hpp"
-#include "gui/main-window.hpp"
+#include "main-window.hpp"
#if defined _WIN32
# include <windows.h>
diff --git a/gui/new_config.ui b/variant/default/new_config.ui
index 27dce0f8..27dce0f8 100644
--- a/gui/new_config.ui
+++ b/variant/default/new_config.ui
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;
+}
diff --git a/variant/default/new_file_dialog.h b/variant/default/new_file_dialog.h
new file mode 100644
index 00000000..5669e4a9
--- /dev/null
+++ b/variant/default/new_file_dialog.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "ui_new_config.h"
+#include "options/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);
+ bool is_ok(QString& name_);
+
+private:
+ Ui::UI_new_config ui;
+ bool ok = false;
+ QString name;
+
+private slots:
+ void cancel_clicked();
+ void ok_clicked();
+};