summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-13 07:42:29 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-13 07:42:29 +0100
commit53e8b2d41988be69deb800e1ef3cbcfc699a3076 (patch)
treedc5a3a9098bf4172a52f0410a04274b997505ff0
parentb0657c7ca495ac9d1d3938b3fdfddd9a8ed2d5f2 (diff)
cmake, main: work toward introducing alternative UI
We're going to base opentrack derivatives on the same branch. Previously merges were a living hell. Modularizing the UI code and having continuously-built executables will do a lot. First opentrack variant in progress is a TrackHat device for mouse and scrolling control for people with spine and hand/arm disabilities.
-rw-r--r--CMakeLists.txt38
-rw-r--r--cmake/msvc.cmake4
-rw-r--r--cmake/opentrack-boilerplate.cmake39
-rw-r--r--cmake/opentrack-qt.cmake2
-rw-r--r--cmake/opentrack-variant.cmake50
-rw-r--r--gui/init.cpp (renamed from main/main.cpp)129
-rw-r--r--gui/init.hpp14
-rw-r--r--gui/main-window.cpp142
-rw-r--r--gui/main-window.hpp22
-rw-r--r--options/defs.hpp1
-rw-r--r--variant/default/CMakeLists.txt (renamed from main/CMakeLists.txt)0
-rw-r--r--variant/default/facetracknoir.ico (renamed from main/facetracknoir.ico)bin67134 -> 67134 bytes
-rw-r--r--variant/default/facetracknoir.rc (renamed from main/facetracknoir.rc)0
-rw-r--r--variant/default/lang/nl_NL.ts (renamed from main/lang/nl_NL.ts)0
-rw-r--r--variant/default/lang/ru_RU.ts (renamed from main/lang/ru_RU.ts)0
-rw-r--r--variant/default/lang/stub.ts (renamed from main/lang/stub.ts)0
-rw-r--r--variant/default/main.cpp20
-rw-r--r--variant/trackmouse/CMakeLists.txt1
18 files changed, 266 insertions, 196 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f47bdd03..aa1a63dd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,7 @@ include(opentrack-boilerplate)
include(opentrack-qt)
include(opentrack-version)
include(opentrack-install)
+include(opentrack-variant)
if(WIN32)
enable_language(RC)
@@ -57,31 +58,20 @@ add_custom_target(mrproper COMMAND
"${CMAKE_SOURCE_DIR}/cmake/opentrack-clean-build-directory.cmake"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
-otr_add_target_dirs(opentrack-subprojects
- "tracker-*"
- "proto-*"
- "filter-*"
- "ext-*"
- "options"
- "api"
- "compat"
- "logic"
- "dinput"
- "gui"
- "main"
- "x-plane-plugin"
- "csv"
- "pose-widget"
- "spline"
- "qxt-mini"
- "macosx"
- "cv"
- "migration")
+function(otr_add_subdirs)
+ otr_dist_select_variant()
+ get_property(_globs GLOBAL PROPERTY opentrack-subprojects)
+ otr_add_target_dirs(_globbed ${_globs})
-foreach(k ${opentrack-subprojects})
- get_filename_component(k "${k}" DIRECTORY)
- add_subdirectory("${k}")
-endforeach()
+ get_property(_variant GLOBAL PROPERTY opentrack-variant)
+ add_subdirectory("variant/${_variant}")
+ foreach(k ${_globbed})
+ get_filename_component(k "${k}" DIRECTORY)
+ add_subdirectory("${k}")
+ endforeach()
+endfunction()
+
+otr_add_subdirs()
otr_merge_translations()
install_sources()
diff --git a/cmake/msvc.cmake b/cmake/msvc.cmake
index 45791d4e..8d125ffa 100644
--- a/cmake/msvc.cmake
+++ b/cmake/msvc.cmake
@@ -65,8 +65,8 @@ set(_CXXFLAGS_DEBUG "${_CFLAGS_DEBUG}")
set(_LDFLAGS "-machine:X86 -DEBUG")
-set(_ltcg "-LTCG")
-#set(_ltcg "-LTCG:INCREMENTAL")
+#set(_ltcg "-LTCG")
+set(_ltcg "-LTCG:INCREMENTAL")
set(_LDFLAGS_RELEASE "-OPT:REF,ICF -cgthreads:1 ${_ltcg}")
set(_LDFLAGS_DEBUG "")
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index a4d197be..019efb05 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -27,19 +27,22 @@ if(NOT (orig-hier-path STREQUAL new-hier-path))
endif()
function(otr_glob_sources var)
- set(dir "${CMAKE_CURRENT_SOURCE_DIR}")
- file(GLOB ${var}-cxx ${dir}/*.cpp)
- file(GLOB ${var}-cc ${dir}/*.c)
- file(GLOB ${var}-hh ${dir}/*.h ${dir}/*.hpp)
- file(GLOB ${var}-res ${dir}/*.rc)
- foreach(f ${var}-res)
- set_source_files_properties(${f} PROPERTIES LANGUAGE RC)
- endforeach()
- file(GLOB ${var}-ui ${dir}/*.ui)
- file(GLOB ${var}-rc ${dir}/*.qrc)
- set(${var}-all ${${var}-cc} ${${var}-cxx} ${${var}-hh} ${${var}-rc} ${${var}-res})
- foreach(i ui rc res cc cxx hh all)
- set(${var}-${i} "${${var}-${i}}" PARENT_SCOPE)
+ set(basedir "${CMAKE_CURRENT_SOURCE_DIR}")
+ foreach(dir . ${ARGN})
+ set(dir "${basedir}/${dir}")
+ file(GLOB ${var}-cxx ${dir}/*.cpp)
+ file(GLOB ${var}-cc ${dir}/*.c)
+ file(GLOB ${var}-hh ${dir}/*.h ${dir}/*.hpp)
+ file(GLOB ${var}-res ${dir}/*.rc)
+ foreach(f ${var}-res)
+ set_source_files_properties(${f} PROPERTIES LANGUAGE RC)
+ endforeach()
+ file(GLOB ${var}-ui ${dir}/*.ui)
+ file(GLOB ${var}-rc ${dir}/*.qrc)
+ set(${var}-all ${${var}-cc} ${${var}-cxx} ${${var}-hh} ${${var}-rc} ${${var}-res})
+ foreach(i ui rc res cc cxx hh all)
+ set(${var}-${i} "${${var}-${i}}" PARENT_SCOPE)
+ endforeach()
endforeach()
endfunction()
@@ -124,7 +127,7 @@ function(otr_module n_)
cmake_parse_arguments(arg
"STATIC;NO-COMPAT;BIN;EXECUTABLE;NO-QT;WIN32-CONSOLE;NO-INSTALL;RELINK"
"LINK;COMPILE"
- "SOURCES"
+ "SOURCES;SUBDIRS"
${ARGN}
)
@@ -134,7 +137,7 @@ function(otr_module n_)
set(n "opentrack-${n_}")
- otr_glob_sources(${n})
+ otr_glob_sources(${n} ${arg_SUBDIRS})
list(APPEND ${n}-all ${arg_SOURCES})
if(NOT arg_NO-QT)
@@ -183,6 +186,12 @@ function(otr_module n_)
string(TOUPPER "${build-n}" build-n)
set_property(TARGET ${n} PROPERTY DEFINE_SYMBOL "BUILD_${build-n}")
+ get_property(ident GLOBAL PROPERTY opentrack-ident)
+ if (".${ident}" STREQUAL ".")
+ message(FATAL_ERROR "must set global property `opentrack-ident' in `opentrack-variant.cmake'")
+ endif()
+ set_property(TARGET ${n} APPEND PROPERTY COMPILE_DEFINITIONS "OPENTRACK_ORG=\"${ident}\"")
+
if(arg_STATIC)
set(arg_NO-INSTALL TRUE)
endif()
diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake
index 665ed053..911eec5b 100644
--- a/cmake/opentrack-qt.cmake
+++ b/cmake/opentrack-qt.cmake
@@ -2,7 +2,7 @@ find_package(Qt5 REQUIRED COMPONENTS Core Network Widgets LinguistTools Gui QUIE
if(WIN32)
find_package(Qt5Gui REQUIRED COMPONENTS QWindowsIntegrationPlugin)
endif()
-find_package(Qt5 COMPONENTS SerialPort Gamepad QUIET)
+find_package(Qt5 COMPONENTS SerialPort QUIET)
include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS})
diff --git a/cmake/opentrack-variant.cmake b/cmake/opentrack-variant.cmake
new file mode 100644
index 00000000..7418f882
--- /dev/null
+++ b/cmake/opentrack-variant.cmake
@@ -0,0 +1,50 @@
+# set these as cache variables manually
+
+set(opentrack_variant "default" CACHE STRING "")
+set_property(CACHE opentrack_variant PROPERTY STRINGS "default;trackmouse")
+
+function(otr_dist_select_variant)
+ if(opentrack_variant STREQUAL "trackmouse")
+ set_property(GLOBAL PROPERTY opentrack-variant "trackmouse")
+ set_property(GLOBAL PROPERTY opentrack-ident "trackmouse-prototype")
+ set(subprojects
+ "tracker-pt"
+ "proto-mouse"
+ "filter-accela"
+ "options"
+ "api"
+ "compat"
+ "logic"
+ "dinput"
+ "gui"
+ "spline"
+ "cv"
+ "migration")
+ set_property(GLOBAL PROPERTY opentrack-subprojects "${subprojects}")
+ else()
+ set_property(GLOBAL PROPERTY opentrack-variant "default")
+ set_property(GLOBAL PROPERTY opentrack-ident "opentrack-2.3")
+ set(subprojects
+ "tracker-*"
+ "proto-*"
+ "filter-*"
+ "ext-*"
+ "options"
+ "api"
+ "compat"
+ "logic"
+ "dinput"
+ "gui"
+ "main"
+ "x-plane-plugin"
+ "csv"
+ "pose-widget"
+ "spline"
+ "qxt-mini"
+ "macosx"
+ "cv"
+ "migration")
+ set_property(GLOBAL PROPERTY opentrack-subprojects "${subprojects}")
+ endif()
+endfunction()
+
diff --git a/main/main.cpp b/gui/init.cpp
index 03c12a8b..7ccc67fe 100644
--- a/main/main.cpp
+++ b/gui/init.cpp
@@ -1,12 +1,7 @@
-#ifdef _WIN32
-# include <cstdio>
-# include <stdlib.h>
-# include <vector>
-# include <QCoreApplication>
-# include <QFile>
-# include <QString>
-# include <QSysInfo>
-# include <QtGlobal>
+#include "init.hpp"
+
+#if defined(Q_CREATOR_RUN)
+# pragma clang diagnostic ignored "-Wmain"
#endif
#include "migration/migration.hpp"
@@ -14,39 +9,39 @@
#include "options/options.hpp"
using namespace options;
#include "opentrack-library-path.h"
+
+#include <memory>
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+
#include <QApplication>
-#include <QCommandLineParser>
#include <QStyleFactory>
-#include <QStringList>
#include <QLocale>
#include <QTranslator>
+#include <QApplication>
+#include <QDir>
+#include <QFile>
+#include <QFileDialog>
+#include <QString>
+#include <QSysInfo>
+
#include <QDebug>
-#include <memory>
-#include <cstring>
#if /* denormal control */ \
/* GNU */ defined __x86_64__ || defined __SSE2__ || \
/* MSVC */ defined _M_AMD64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
# include <xmmintrin.h>
# include <pmmintrin.h>
-# include <float.h>
+# include <cfloat>
#define OTR_HAS_DENORM_CONTROL
void set_fp_mask()
{
- unsigned old_mask = _mm_getcsr();
- (void) old_mask;
-
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
_MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST);
_MM_SET_EXCEPTION_MASK(_MM_MASK_MASK);
-
-#if 0
- unsigned new_mask = _mm_getcsr();
-
- qDebug() << "old" << (void*) old_mask << "new" << (void*) new_mask;
-#endif
}
#endif
@@ -57,11 +52,11 @@ void set_qt_style()
return;
#endif
-#if defined(_WIN32) || defined(__APPLE__)
+#if defined _WIN32 || defined __APPLE__
// our layouts on OSX make some control wrongly sized -sh 20160908
{
- const QStringList preferred { "fusion", "windowsvista", "macintosh" };
- for (const auto& style_name : preferred)
+ const char* preferred[] { "fusion", "windowsvista", "macintosh" };
+ for (const char* style_name : preferred)
{
QStyle* s = QStyleFactory::create(style_name);
if (s)
@@ -84,7 +79,7 @@ void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QString &
std::fflush(stderr);
if (ctx.function)
- std::fprintf(stderr, "[%s]: %ls\n", ctx.function, str);
+ std::fprintf(stderr, "[%s:%d%s]: %ls\n", ctx.file, ctx.line, ctx.function, str);
else if (ctx.file)
std::fprintf(stderr, "[%s:%d]: %ls\n", ctx.file, ctx.line, str);
else
@@ -101,8 +96,8 @@ void attach_parent_console()
_wfreopen(L"CON", L"w", stdout);
_wfreopen(L"CON", L"w", stderr);
_wfreopen(L"CON", L"r", stdin);
- qInstallMessageHandler(qdebug_to_console);
}
+ (void)qInstallMessageHandler(qdebug_to_console);
}
void add_win32_path()
@@ -118,8 +113,7 @@ void add_win32_path()
mod_path.replace("/", "\\");
const QByteArray mod_path_ = QFile::encodeName(mod_path);
- std::vector<const char*> contents
- {
+ const char* contents[] {
"PATH=",
lib_path_.constData(),
";",
@@ -158,11 +152,23 @@ void add_win32_path()
#endif
-int
-#ifdef _MSC_VER
-WINAPI
-#endif
-main(int argc, char** argv)
+int run_window(QApplication& app, std::unique_ptr<QWidget> main_window)
+{
+ if (!main_window->isEnabled())
+ {
+ qDebug() << "exit before window created";
+ return 2;
+ }
+
+ app.setQuitOnLastWindowClosed(false);
+
+ int ret = app.exec();
+ qDebug() << "exit" << ret;
+
+ return ret;
+}
+
+int otr_main(int argc, char** argv, std::function<QWidget*()> make_main_window)
{
#ifdef _WIN32
attach_parent_console();
@@ -172,10 +178,8 @@ main(int argc, char** argv)
set_fp_mask();
#endif
-#if QT_VERSION >= 0x050600 // flag introduced in QT 5.6. It is non-essential so might as well allow compilation on older systems.
- QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-#endif
- QApplication::setAttribute(Qt::AA_X11InitThreads, true);
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QCoreApplication::setAttribute(Qt::AA_X11InitThreads, true);
QApplication app(argc, argv);
@@ -183,12 +187,14 @@ main(int argc, char** argv)
add_win32_path();
#endif
- main_window::set_working_directory();
+ QDir::setCurrent(OPENTRACK_BASE_PATH);
+#if 0
#if !defined(__linux) && !defined _WIN32
// workaround QTBUG-38598
QCoreApplication::addLibraryPath(".");
#endif
+#endif
set_qt_style();
QTranslator t;
@@ -203,31 +209,7 @@ main(int argc, char** argv)
(void) QCoreApplication::installTranslator(&t);
}
- do
- {
- std::shared_ptr<main_window> w = std::make_shared<main_window>();
-
- if (!w->isEnabled())
- break;
-
- if (!w->start_in_tray())
- {
- w->setVisible(true);
- w->show();
- w->adjustSize();
- w->setFixedSize(w->size());
- }
- else
- w->setVisible(false);
-
- app.setQuitOnLastWindowClosed(false);
- app.exec();
-
- app.exit(0);
-
- qDebug() << "exit: window";
- }
- while (false);
+ int ret = run_window(app, std::unique_ptr<QWidget>(make_main_window()));
// msvc crashes in Qt plugin system's dtor
// Note: QLibrary::PreventUnloadHint seems to workaround it
@@ -236,20 +218,5 @@ main(int argc, char** argv)
TerminateProcess(GetCurrentProcess(), 0);
#endif
- qDebug() << "exit: main()";
-
- return 0;
+ return ret;
}
-
-#if defined(Q_CREATOR_RUN)
-# pragma clang diagnostic ignored "-Wmain"
-#endif
-
-#ifdef _MSC_VER
-int WINAPI
-WinMain (struct HINSTANCE__*, struct HINSTANCE__*, char*, int)
-{
- return main (__argc, __argv);
-}
-
-#endif
diff --git a/gui/init.hpp b/gui/init.hpp
new file mode 100644
index 00000000..d437b084
--- /dev/null
+++ b/gui/init.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "export.hpp"
+
+#include <functional>
+#include <QWidget>
+
+int OTR_GUI_EXPORT otr_main(int argc, char** argv, std::function<QWidget*()> make_main_window);
+
+template<typename F>
+auto run_application(int argc, char** argv, F&& fun)
+{
+ return otr_main(argc, argv, fun);
+}
diff --git a/gui/main-window.cpp b/gui/main-window.cpp
index 1f84ea71..bc20cf59 100644
--- a/gui/main-window.cpp
+++ b/gui/main-window.cpp
@@ -15,73 +15,71 @@
#include "compat/check-visible.hpp"
#include "compat/sleep.hpp"
-#include <QFile>
-#include <QFileDialog>
+#include <QMessageBox>
#include <QDesktopServices>
-#include <QCoreApplication>
-#include <QApplication>
-#include <QIcon>
-#include <QString>
-#include <QChar>
-#include <QSignalBlocker>
-
-#ifdef _WIN32
-# include <windows.h>
-#endif
+#include <QDir>
extern "C" const char* const opentrack_version;
+#if !defined EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+
+#if !defined EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+//
+
+/* FreeBSD sysexits(3)
+ *
+ * The input data was incorrect in some way. This
+ * should only be used for user's data and not system
+ * files.
+ */
+
+#if !defined EX_DATAERR
+# define EX_DATAERR 65
+#endif
+
#if !defined _WIN32 && !defined __APPLE__
# include <unistd.h>
void MainWindow::annoy_if_root()
{
if (geteuid() == 0)
{
- for (unsigned k = 0; k < 2; k++)
- {
- portable::sleep(1 * 1000);
- QMessageBox::critical(this,
- tr("Running as root is bad"),
- tr("Do not run as root. Set correct device node permissions."),
- QMessageBox::Ok);
- portable::sleep(1 * 1000);
- QMessageBox::critical(this,
- tr("Running as root is bad, seriously"),
- tr("Do not run as root. I'll keep whining at every startup."),
- QMessageBox::Ok);
- portable::sleep(3 * 1000);
- QMessageBox::critical(this,
- tr("Running as root is really seriously bad"),
- tr("Do not run as root. Be annoyed, comprehensively."),
- QMessageBox::Ok);
- }
+ portable::sleep(4000);
+ QMessageBox::critical(this,
+ tr("Running as root is bad"),
+ tr("Do not run as root. Set correct device node permissions."),
+ QMessageBox::Ok);
+ portable::sleep(4000);
+ QMessageBox::critical(this,
+ tr("Running as root is bad, seriously"),
+ tr("Do not run as root. I'll keep whining at every startup."),
+ QMessageBox::Ok);
+ portable::sleep(4000);
+ QMessageBox::critical(this,
+ tr("Running as root is really seriously bad"),
+ tr("Do not run as root. Be annoyed, comprehensively."),
+ QMessageBox::Ok);
}
}
#endif
main_window::main_window() :
- State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH),
- pose_update_timer(this),
- kbd_quit(QKeySequence("Ctrl+Q"), this),
- menu_action_header(&tray_menu),
- menu_action_show(&tray_menu),
- menu_action_exit(&tray_menu),
- menu_action_tracker(&tray_menu),
- menu_action_filter(&tray_menu),
- menu_action_proto(&tray_menu),
- menu_action_options(&tray_menu),
- menu_action_mappings(&tray_menu)
+ State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH)
{
ui.setupUi(this);
+ setAttribute(Qt::WA_QuitOnClose, true);
+
#if !defined _WIN32 && !defined __APPLE__
annoy_if_root();
#endif
- {
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags());
- }
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags());
update_button_state(false, false);
@@ -92,7 +90,10 @@ main_window::main_window() :
}
if (!refresh_config_list())
+ {
+ exit(EX_DATAERR);
return;
+ }
connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(show_mapping_window()));
connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog()));
@@ -133,14 +134,15 @@ main_window::main_window() :
ui.profile_button->setMenu(&profile_menu);
}
- if (!progn(
+ {
const QString cur = group::ini_filename();
- if (is_config_listed(cur))
- return set_profile(cur);
- else
- return set_profile(OPENTRACK_DEFAULT_CONFIG);
- ))
- return;
+ bool ok = is_config_listed(cur) ? set_profile(cur) : set_profile(OPENTRACK_DEFAULT_CONFIG);
+ if (!ok)
+ {
+ exit(EX_DATAERR);
+ return;
+ }
+ }
// only tie and connect main screen options after migrations are done
// below is fine, set_profile() is called already
@@ -162,9 +164,9 @@ main_window::main_window() :
this,
[&](const QString&) { if (pFilterDialog) pFilterDialog = nullptr; });
- connect(&m.tracker_dll, base_value::value_changed<QString>(), this, &main_window::save_modules, Qt::QueuedConnection);
- connect(&m.protocol_dll, base_value::value_changed<QString>(), this, &main_window::save_modules, Qt::QueuedConnection);
- connect(&m.filter_dll, base_value::value_changed<QString>(), this, &main_window::save_modules, Qt::QueuedConnection);
+ connect(&m.tracker_dll, base_value::value_changed<QString>(), this, &main_window::save_modules, Qt::DirectConnection);
+ connect(&m.protocol_dll, base_value::value_changed<QString>(), this, &main_window::save_modules, Qt::DirectConnection);
+ connect(&m.filter_dll, base_value::value_changed<QString>(), this, &main_window::save_modules, Qt::DirectConnection);
tie_setting(m.tracker_dll, ui.iconcomboTrackerSource);
tie_setting(m.protocol_dll, ui.iconcomboProtocol);
@@ -202,6 +204,17 @@ main_window::main_window() :
det_timer.start(1000);
config_list_timer.start(1000 * 5);
kbd_quit.setEnabled(true);
+
+ adjustSize();
+ setFixedSize(size());
+
+ if (!start_in_tray())
+ {
+ setVisible(true);
+ show();
+ }
+ else
+ setVisible(false);
}
void main_window::init_tray_menu()
@@ -301,15 +314,15 @@ void main_window::die_on_config_not_writable()
QMessageBox::Close, QMessageBox::NoButton);
// signals main() to short-circuit
- if (!isVisible())
- setEnabled(false);
+ //if (!isVisible())
+ // setEnabled(false);
- setVisible(false);
+ //setVisible(false);
// tray related
- qApp->setQuitOnLastWindowClosed(true);
+ //qApp->setQuitOnLastWindowClosed(true);
- close();
+ exit(EX_DATAERR);
}
bool main_window::maybe_die_on_config_not_writable(const QString& current, QStringList* ini_list_)
@@ -701,9 +714,11 @@ void main_window::show_mapping_window()
mk_window(mapping_widget, pose);
}
-void main_window::exit()
+void main_window::exit(int status)
{
- QCoreApplication::exit(0);
+ setEnabled(false);
+ close();
+ QCoreApplication::exit(status);
}
bool main_window::set_profile(const QString& new_name_)
@@ -885,8 +900,9 @@ void main_window::changeEvent(QEvent* e)
}
}
-void main_window::closeEvent(QCloseEvent*)
+void main_window::closeEvent(QCloseEvent* ev)
{
+ ev->accept();
exit();
}
diff --git a/gui/main-window.hpp b/gui/main-window.hpp
index 253c1194..402202d6 100644
--- a/gui/main-window.hpp
+++ b/gui/main-window.hpp
@@ -21,8 +21,7 @@
#include "logic/state.hpp"
#include "options/options.hpp"
-#include <QObject>
-#include <QWidget>
+#include <QApplication>
#include <QMainWindow>
#include <QKeySequence>
#include <QShortcut>
@@ -53,12 +52,12 @@ class OTR_GUI_EXPORT main_window : public QMainWindow, private State
module_settings m;
std::unique_ptr<QSystemTrayIcon> tray;
QMenu tray_menu;
- QTimer pose_update_timer;
+ QTimer pose_update_timer { this };
QTimer det_timer;
QTimer config_list_timer;
std::unique_ptr<options_dialog> options_widget;
std::unique_ptr<mapping_dialog> mapping_widget;
- QShortcut kbd_quit;
+ QShortcut kbd_quit { QKeySequence("Ctrl+Q"), this };
std::unique_ptr<IFilterDialog> pFilterDialog;
std::unique_ptr<IProtocolDialog> pProtocolDialog;
std::unique_ptr<ITrackerDialog> pTrackerDialog;
@@ -66,9 +65,14 @@ class OTR_GUI_EXPORT main_window : public QMainWindow, private State
process_detector_worker det;
QMenu profile_menu;
- QAction menu_action_header, menu_action_show, menu_action_exit,
- menu_action_tracker, menu_action_filter, menu_action_proto,
- menu_action_options, menu_action_mappings;
+ QAction menu_action_header { &tray_menu },
+ menu_action_show { &tray_menu },
+ menu_action_exit { &tray_menu },
+ menu_action_tracker { &tray_menu },
+ menu_action_filter { &tray_menu },
+ menu_action_proto { &tray_menu },
+ menu_action_options { &tray_menu },
+ menu_action_mappings { &tray_menu };
std::shared_ptr<dylib> current_tracker()
{
@@ -96,7 +100,7 @@ class OTR_GUI_EXPORT main_window : public QMainWindow, private State
void init_tray_menu();
void changeEvent(QEvent* e) override;
- void closeEvent(QCloseEvent*) override;
+ void closeEvent(QCloseEvent* ev) override;
bool event(QEvent *event) override;
bool maybe_hide_to_tray(QEvent* e);
#if !defined _WIN32 && !defined __APPLE__
@@ -117,7 +121,7 @@ class OTR_GUI_EXPORT main_window : public QMainWindow, private State
private slots:
void save_modules();
- void exit();
+ void exit(int status = 0);
bool set_profile(const QString& new_name);
void show_tracker_settings();
diff --git a/options/defs.hpp b/options/defs.hpp
index 6f368848..f093a22a 100644
--- a/options/defs.hpp
+++ b/options/defs.hpp
@@ -5,4 +5,3 @@
#define OPENTRACK_CONFIG_FILENAME_KEY "settings-filename"
#define OPENTRACK_DEFAULT_CONFIG "default.ini"
#define OPENTRACK_DEFAULT_CONFIG_Q QStringLiteral("default.ini")
-#define OPENTRACK_ORG "opentrack-2.3"
diff --git a/main/CMakeLists.txt b/variant/default/CMakeLists.txt
index a9e3c754..a9e3c754 100644
--- a/main/CMakeLists.txt
+++ b/variant/default/CMakeLists.txt
diff --git a/main/facetracknoir.ico b/variant/default/facetracknoir.ico
index 5cac8da1..5cac8da1 100644
--- a/main/facetracknoir.ico
+++ b/variant/default/facetracknoir.ico
Binary files differ
diff --git a/main/facetracknoir.rc b/variant/default/facetracknoir.rc
index 020ffe97..020ffe97 100644
--- a/main/facetracknoir.rc
+++ b/variant/default/facetracknoir.rc
diff --git a/main/lang/nl_NL.ts b/variant/default/lang/nl_NL.ts
index 9e739505..9e739505 100644
--- a/main/lang/nl_NL.ts
+++ b/variant/default/lang/nl_NL.ts
diff --git a/main/lang/ru_RU.ts b/variant/default/lang/ru_RU.ts
index f62cf2e1..f62cf2e1 100644
--- a/main/lang/ru_RU.ts
+++ b/variant/default/lang/ru_RU.ts
diff --git a/main/lang/stub.ts b/variant/default/lang/stub.ts
index 6401616d..6401616d 100644
--- a/main/lang/stub.ts
+++ b/variant/default/lang/stub.ts
diff --git a/variant/default/main.cpp b/variant/default/main.cpp
new file mode 100644
index 00000000..80f7e495
--- /dev/null
+++ b/variant/default/main.cpp
@@ -0,0 +1,20 @@
+#include "gui/init.hpp"
+#include "gui/main-window.hpp"
+
+#if defined _WIN32
+# include <windows.h>
+#endif
+
+int main(int argc, char** argv)
+{
+ return run_application(argc, argv, []() { return new main_window; });
+}
+
+#if defined _MSC_VER
+int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int /* nCmdShow */)
+{
+ return main(__argc, __argv);
+}
+#endif
+
+
diff --git a/variant/trackmouse/CMakeLists.txt b/variant/trackmouse/CMakeLists.txt
new file mode 100644
index 00000000..bda9c39b
--- /dev/null
+++ b/variant/trackmouse/CMakeLists.txt
@@ -0,0 +1 @@
+message("FATAL_ERROR" "")