diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | cmake/opentrack-boilerplate.cmake | 2 | ||||
-rw-r--r-- | cmake/opentrack-qt.cmake | 4 | ||||
-rw-r--r-- | gui/CMakeLists.txt | 7 | ||||
-rw-r--r-- | gui/export.hpp | 11 | ||||
-rw-r--r-- | gui/keyboard.cpp | 2 | ||||
-rw-r--r-- | gui/keyboard.h | 6 | ||||
-rw-r--r-- | gui/main-window.cpp | 112 | ||||
-rw-r--r-- | gui/main-window.hpp | 14 | ||||
-rw-r--r-- | gui/mapping-dialog.cpp | 16 | ||||
-rw-r--r-- | gui/mapping-dialog.hpp | 10 | ||||
-rw-r--r-- | gui/mapping-dialog.ui | 4 | ||||
-rw-r--r-- | gui/process_detector.cpp | 18 | ||||
-rw-r--r-- | gui/process_detector.h | 12 | ||||
-rw-r--r-- | gui/settings.cpp | 22 | ||||
-rw-r--r-- | gui/settings.hpp | 8 | ||||
-rw-r--r-- | main/CMakeLists.txt | 8 | ||||
-rw-r--r-- | main/lang/nl_NL.ts | 4 | ||||
-rw-r--r-- | main/lang/ru_RU.ts | 4 | ||||
-rw-r--r-- | main/lang/stub.ts | 4 | ||||
-rw-r--r-- | main/main.cpp (renamed from gui/main.cpp) | 6 |
21 files changed, 156 insertions, 119 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index aff3011a..f47bdd03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ otr_add_target_dirs(opentrack-subprojects "logic" "dinput" "gui" + "main" "x-plane-plugin" "csv" "pose-widget" diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index a8da8a23..a4d197be 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -38,7 +38,7 @@ function(otr_glob_sources var) 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 hh all) + foreach(i ui rc res cc cxx hh all) set(${var}-${i} "${${var}-${i}}" PARENT_SCOPE) endforeach() endfunction() diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake index 3939a981..665ed053 100644 --- a/cmake/opentrack-qt.cmake +++ b/cmake/opentrack-qt.cmake @@ -48,9 +48,9 @@ endfunction() otr_install_qt_libs() function(otr_qt n) - if(".${${n}-hh}" STREQUAL ".") + if(".${${n}-cc}${${n}-cxx}${${n}-hh}" STREQUAL ".") message(FATAL_ERROR "project ${n} not globbed") - endif() + endif() qt5_wrap_cpp(${n}-moc ${${n}-hh} OPTIONS --no-notes) qt5_wrap_ui(${n}-uih ${${n}-ui}) qt5_add_resources(${n}-rcc ${${n}-rc}) diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index d0cba4ac..954fa67a 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -1,9 +1,4 @@ -otr_module(user-interface EXECUTABLE BIN) - -set_target_properties(opentrack-user-interface PROPERTIES - SUFFIX "${opentrack-binary-suffix}" - OUTPUT_NAME "opentrack" - ) +otr_module(user-interface BIN) target_link_libraries(opentrack-user-interface opentrack-migration diff --git a/gui/export.hpp b/gui/export.hpp new file mode 100644 index 00000000..3ef3e5b8 --- /dev/null +++ b/gui/export.hpp @@ -0,0 +1,11 @@ +// generates export.hpp for each module from compat/linkage.hpp + +#pragma once + +#include "compat/linkage-macros.hpp" + +#ifdef BUILD_USER_INTERFACE +# define OTR_GUI_EXPORT OTR_GENERIC_EXPORT +#else +# define OTR_GUI_EXPORT OTR_GENERIC_IMPORT +#endif diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 79c8fb29..3d956970 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -2,7 +2,7 @@ #include <QDebug> -KeyboardListener::KeyboardListener(QWidget* parent) : +keyboard_listener::keyboard_listener(QWidget* parent) : QDialog(parent) #if defined _WIN32 , token([&](const Key& k) { diff --git a/gui/keyboard.h b/gui/keyboard.h index f4e5f7c0..9ca50df1 100644 --- a/gui/keyboard.h +++ b/gui/keyboard.h @@ -1,5 +1,7 @@ #pragma once +#include "export.hpp" + #ifdef _WIN32 # include "logic/win32-shortcuts.h" # include "dinput/keybinding-worker.hpp" @@ -10,7 +12,7 @@ #include <QDialog> #include <QKeyEvent> -class KeyboardListener : public QDialog +class OTR_GUI_EXPORT keyboard_listener : public QDialog { Q_OBJECT Ui_keyboard_listener ui; @@ -18,7 +20,7 @@ class KeyboardListener : public QDialog KeybindingWorker::Token token; #endif public: - KeyboardListener(QWidget* parent = nullptr); + keyboard_listener(QWidget* parent = nullptr); #ifndef _WIN32 void keyPressEvent(QKeyEvent* event) override; #endif diff --git a/gui/main-window.cpp b/gui/main-window.cpp index 34846131..1f84ea71 100644 --- a/gui/main-window.cpp +++ b/gui/main-window.cpp @@ -59,7 +59,7 @@ void MainWindow::annoy_if_root() } #endif -MainWindow::MainWindow() : +main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH), pose_update_timer(this), kbd_quit(QKeySequence("Ctrl+Q"), this), @@ -162,28 +162,28 @@ MainWindow::MainWindow() : this, [&](const QString&) { if (pFilterDialog) pFilterDialog = nullptr; }); - connect(&m.tracker_dll, base_value::value_changed<QString>(), this, &MainWindow::save_modules, Qt::QueuedConnection); - connect(&m.protocol_dll, base_value::value_changed<QString>(), this, &MainWindow::save_modules, Qt::QueuedConnection); - connect(&m.filter_dll, base_value::value_changed<QString>(), this, &MainWindow::save_modules, Qt::QueuedConnection); + 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); tie_setting(m.tracker_dll, ui.iconcomboTrackerSource); tie_setting(m.protocol_dll, ui.iconcomboProtocol); tie_setting(m.filter_dll, ui.iconcomboFilter); } - connect(this, &MainWindow::start_tracker, + connect(this, &main_window::start_tracker, this, [&]() { qDebug() << "start tracker"; start_tracker_(); }, Qt::QueuedConnection); - connect(this, &MainWindow::stop_tracker, + connect(this, &main_window::stop_tracker, this, [&]() { qDebug() << "stop tracker"; stop_tracker_(); }, Qt::QueuedConnection); - connect(this, &MainWindow::toggle_tracker, + connect(this, &main_window::toggle_tracker, this, [&]() { qDebug() << "toggle tracker"; if (work) stop_tracker_(); else start_tracker_(); }, Qt::QueuedConnection); - connect(this, &MainWindow::restart_tracker, + connect(this, &main_window::restart_tracker, this, [&]() { qDebug() << "restart tracker"; stop_tracker_(); start_tracker_(); }, Qt::QueuedConnection); @@ -204,7 +204,7 @@ MainWindow::MainWindow() : kbd_quit.setEnabled(true); } -void MainWindow::init_tray_menu() +void main_window::init_tray_menu() { tray_menu.clear(); @@ -231,39 +231,39 @@ void MainWindow::init_tray_menu() menu_action_tracker.setText(tr("Tracker settings")); menu_action_tracker.setIcon(QIcon(":/images/tools.png")); - QObject::connect(&menu_action_tracker, &QAction::triggered, this, &MainWindow::show_tracker_settings); + QObject::connect(&menu_action_tracker, &QAction::triggered, this, &main_window::show_tracker_settings); tray_menu.addAction(&menu_action_tracker); menu_action_filter.setText(tr("Filter settings")); menu_action_filter.setIcon(QIcon(":/images/filter-16.png")); - QObject::connect(&menu_action_filter, &QAction::triggered, this, &MainWindow::show_filter_settings); + QObject::connect(&menu_action_filter, &QAction::triggered, this, &main_window::show_filter_settings); tray_menu.addAction(&menu_action_filter); menu_action_proto.setText(tr("Protocol settings")); menu_action_proto.setIcon(QIcon(":/images/settings16.png")); - QObject::connect(&menu_action_proto, &QAction::triggered, this, &MainWindow::show_proto_settings); + QObject::connect(&menu_action_proto, &QAction::triggered, this, &main_window::show_proto_settings); tray_menu.addAction(&menu_action_proto); tray_menu.addSeparator(); menu_action_mappings.setIcon(QIcon(":/images/curves.png")); menu_action_mappings.setText(tr("Mappings")); - QObject::connect(&menu_action_mappings, &QAction::triggered, this, &MainWindow::show_mapping_window); + QObject::connect(&menu_action_mappings, &QAction::triggered, this, &main_window::show_mapping_window); tray_menu.addAction(&menu_action_mappings); menu_action_options.setIcon(QIcon(":/images/tools.png")); menu_action_options.setText(tr("Options")); - QObject::connect(&menu_action_options, &QAction::triggered, this, &MainWindow::show_options_dialog); + QObject::connect(&menu_action_options, &QAction::triggered, this, &main_window::show_options_dialog); tray_menu.addAction(&menu_action_options); tray_menu.addSeparator(); menu_action_exit.setText(tr("Exit")); - QObject::connect(&menu_action_exit, &QAction::triggered, this, &MainWindow::exit); + QObject::connect(&menu_action_exit, &QAction::triggered, this, &main_window::exit); tray_menu.addAction(&menu_action_exit); } -void MainWindow::register_shortcuts() +void main_window::register_shortcuts() { using t_key = Shortcuts::t_key; using t_keys = Shortcuts::t_keys; @@ -289,7 +289,7 @@ void MainWindow::register_shortcuts() work->reload_shortcuts(); } -void MainWindow::die_on_config_not_writable() +void main_window::die_on_config_not_writable() { stop_tracker_(); @@ -312,7 +312,7 @@ void MainWindow::die_on_config_not_writable() close(); } -bool MainWindow::maybe_die_on_config_not_writable(const QString& current, QStringList* ini_list_) +bool main_window::maybe_die_on_config_not_writable(const QString& current, QStringList* ini_list_) { const bool writable = group::with_settings_object([&](QSettings& s) { @@ -337,14 +337,14 @@ bool MainWindow::maybe_die_on_config_not_writable(const QString& current, QStrin return false; } -bool MainWindow::get_new_config_name_from_dialog(QString& ret) +bool main_window::get_new_config_name_from_dialog(QString& ret) { new_file_dialog dlg; dlg.exec(); return dlg.is_ok(ret); } -MainWindow::~MainWindow() +main_window::~main_window() { if (tray) tray->hide(); @@ -361,18 +361,18 @@ MainWindow::~MainWindow() } } -void MainWindow::set_working_directory() +void main_window::set_working_directory() { QDir::setCurrent(OPENTRACK_BASE_PATH); } -void MainWindow::save_modules() +void main_window::save_modules() { qDebug() << "save modules"; m.b->save(); } -void MainWindow::make_empty_config() +void main_window::make_empty_config() { QString name; if (get_new_config_name_from_dialog(name)) @@ -393,7 +393,7 @@ void MainWindow::make_empty_config() } } -void MainWindow::make_copied_config() +void main_window::make_copied_config() { const QString cur = group::ini_pathname(); QString name; @@ -418,12 +418,12 @@ void MainWindow::make_copied_config() } -void MainWindow::open_config_directory() +void main_window::open_config_directory() { QDesktopServices::openUrl("file:///" + QDir::toNativeSeparators(group::ini_directory())); } -bool MainWindow::refresh_config_list() +bool main_window::refresh_config_list() { if (work) return true; @@ -472,7 +472,7 @@ bool MainWindow::refresh_config_list() return true; } -void MainWindow::update_button_state(bool running, bool inertialp) +void main_window::update_button_state(bool running, bool inertialp) { bool not_running = !running; ui.iconcomboProfile->setEnabled(not_running); @@ -492,7 +492,7 @@ void MainWindow::update_button_state(bool running, bool inertialp) } } -void MainWindow::start_tracker_() +void main_window::start_tracker_() { if (work) return; @@ -529,7 +529,7 @@ void MainWindow::start_tracker_() ui.btnStopTracker->setFocus(); } -void MainWindow::stop_tracker_() +void main_window::stop_tracker_() { if (!work) return; @@ -560,7 +560,7 @@ void MainWindow::stop_tracker_() ui.btnStartTracker->setFocus(); } -void MainWindow::display_pose(const double *mapped, const double *raw) +void main_window::display_pose(const double *mapped, const double *raw) { ui.pose_display->rotate_async(mapped[Yaw], mapped[Pitch], -mapped[Roll], mapped[TX], mapped[TY], mapped[TZ]); @@ -587,7 +587,7 @@ void MainWindow::display_pose(const double *mapped, const double *raw) set_title(game_title); } -void MainWindow::set_title(const QString& game_title_) +void main_window::set_title(const QString& game_title_) { QString game_title; if (game_title_ != "") @@ -598,7 +598,7 @@ void MainWindow::set_title(const QString& game_title_) setWindowTitle(version + tr(" :: ") + current + game_title); } -void MainWindow::show_pose() +void main_window::show_pose() { set_is_visible(*this); @@ -616,7 +616,7 @@ void MainWindow::show_pose() } template<typename t, typename F> -bool MainWindow::mk_window_common(std::unique_ptr<t>& d, F&& ctor) +bool main_window::mk_window_common(std::unique_ptr<t>& d, F&& ctor) { if (d) { @@ -644,13 +644,13 @@ bool MainWindow::mk_window_common(std::unique_ptr<t>& d, F&& ctor) } template<typename t, typename... Args> -inline bool MainWindow::mk_window(std::unique_ptr<t>& place, Args&&... params) +inline bool main_window::mk_window(std::unique_ptr<t>& place, Args&&... params) { return mk_window_common(place, [&]() { return new t(std::forward<Args>(params)...); }); } template<typename t> -bool MainWindow::mk_dialog(std::shared_ptr<dylib> lib, std::unique_ptr<t>& d) +bool main_window::mk_dialog(std::shared_ptr<dylib> lib, std::unique_ptr<t>& d) { const bool just_created = mk_window_common(d, [&]() -> t* { if (lib && lib->Dialog) @@ -661,7 +661,7 @@ bool MainWindow::mk_dialog(std::shared_ptr<dylib> lib, std::unique_ptr<t>& d) return just_created; } -void MainWindow::show_tracker_settings() +void main_window::show_tracker_settings() { if (mk_dialog(current_tracker(), pTrackerDialog) && work && work->libs.pTracker) pTrackerDialog->register_tracker(work->libs.pTracker.get()); @@ -670,7 +670,7 @@ void MainWindow::show_tracker_settings() QObject::connect(pTrackerDialog.get(), &ITrackerDialog::closing, this, [this]() { pTrackerDialog = nullptr; }); } -void MainWindow::show_proto_settings() +void main_window::show_proto_settings() { if (mk_dialog(current_protocol(), pProtocolDialog) && work && work->libs.pProtocol) pProtocolDialog->register_protocol(work->libs.pProtocol.get()); @@ -679,7 +679,7 @@ void MainWindow::show_proto_settings() QObject::connect(pProtocolDialog.get(), &IProtocolDialog::closing, this, [this]() { pProtocolDialog = nullptr; }); } -void MainWindow::show_filter_settings() +void main_window::show_filter_settings() { if (mk_dialog(current_filter(), pFilterDialog) && work && work->libs.pFilter) pFilterDialog->register_filter(work->libs.pFilter.get()); @@ -688,25 +688,25 @@ void MainWindow::show_filter_settings() QObject::connect(pFilterDialog.get(), &IFilterDialog::closing, this, [this]() { pFilterDialog = nullptr; }); } -void MainWindow::show_options_dialog() +void main_window::show_options_dialog() { if (mk_window(options_widget, [&](bool flag) { set_keys_enabled(!flag); })) { - connect(options_widget.get(), &OptionsDialog::closing, this, &MainWindow::register_shortcuts); + connect(options_widget.get(), &options_dialog::closing, this, &main_window::register_shortcuts); } } -void MainWindow::show_mapping_window() +void main_window::show_mapping_window() { mk_window(mapping_widget, pose); } -void MainWindow::exit() +void main_window::exit() { QCoreApplication::exit(0); } -bool MainWindow::set_profile(const QString& new_name_) +bool main_window::set_profile(const QString& new_name_) { if (!refresh_config_list()) return false; @@ -732,7 +732,7 @@ bool MainWindow::set_profile(const QString& new_name_) return true; } -void MainWindow::ensure_tray() +void main_window::ensure_tray() { if (!QSystemTrayIcon::isSystemTrayAvailable()) return; @@ -749,7 +749,7 @@ void MainWindow::ensure_tray() connect(tray.get(), &QSystemTrayIcon::activated, this, - &MainWindow::toggle_restore_from_tray); + &main_window::toggle_restore_from_tray); } } else @@ -771,7 +771,7 @@ void MainWindow::ensure_tray() } } -void MainWindow::toggle_restore_from_tray(QSystemTrayIcon::ActivationReason e) +void main_window::toggle_restore_from_tray(QSystemTrayIcon::ActivationReason e) { if (progn( switch (e) @@ -818,7 +818,7 @@ void MainWindow::toggle_restore_from_tray(QSystemTrayIcon::ActivationReason e) } } -bool MainWindow::maybe_hide_to_tray(QEvent* e) +bool main_window::maybe_hide_to_tray(QEvent* e) { if (e->type() == QEvent::WindowStateChange && (windowState() & Qt::WindowMinimized) && @@ -834,7 +834,7 @@ bool MainWindow::maybe_hide_to_tray(QEvent* e) return false; } -void MainWindow::maybe_start_profile_from_executable() +void main_window::maybe_start_profile_from_executable() { if (!work) { @@ -852,7 +852,7 @@ void MainWindow::maybe_start_profile_from_executable() } } -void MainWindow::set_keys_enabled(bool flag) +void main_window::set_keys_enabled(bool flag) { if (!flag) { @@ -866,7 +866,7 @@ void MainWindow::set_keys_enabled(bool flag) } } -bool MainWindow::is_config_listed(const QString& name) +bool main_window::is_config_listed(const QString& name) { const int sz = ui.iconcomboProfile->count(); for (int i = 0; i < sz; i++) @@ -875,7 +875,7 @@ bool MainWindow::is_config_listed(const QString& name) return false; } -void MainWindow::changeEvent(QEvent* e) +void main_window::changeEvent(QEvent* e) { if (maybe_hide_to_tray(e)) e->accept(); @@ -885,12 +885,12 @@ void MainWindow::changeEvent(QEvent* e) } } -void MainWindow::closeEvent(QCloseEvent*) +void main_window::closeEvent(QCloseEvent*) { exit(); } -bool MainWindow::event(QEvent* event) +bool main_window::event(QEvent* event) { using t = QEvent::Type; @@ -912,17 +912,17 @@ bool MainWindow::event(QEvent* event) return QMainWindow::event(event); } -bool MainWindow::is_tray_enabled() +bool main_window::is_tray_enabled() { return s.tray_enabled && QSystemTrayIcon::isSystemTrayAvailable(); } -bool MainWindow::start_in_tray() +bool main_window::start_in_tray() { return s.tray_enabled && s.tray_start && QSystemTrayIcon::isSystemTrayAvailable(); } -void MainWindow::set_profile_in_registry(const QString &profile) +void main_window::set_profile_in_registry(const QString &profile) { group::with_global_settings_object([&](QSettings& s) { s.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); diff --git a/gui/main-window.hpp b/gui/main-window.hpp index 8b0144b8..253c1194 100644 --- a/gui/main-window.hpp +++ b/gui/main-window.hpp @@ -8,6 +8,8 @@ #pragma once +#include "export.hpp" + #include "api/plugin-support.hpp" #include "mapping-dialog.hpp" #include "settings.hpp" @@ -37,11 +39,11 @@ #include <tuple> #include <memory> -#include "ui_main-window.h" +#include "gui/ui_main-window.h" using namespace options; -class MainWindow : public QMainWindow, private State +class OTR_GUI_EXPORT main_window : public QMainWindow, private State { Q_OBJECT @@ -54,8 +56,8 @@ class MainWindow : public QMainWindow, private State QTimer pose_update_timer; QTimer det_timer; QTimer config_list_timer; - std::unique_ptr<OptionsDialog> options_widget; - std::unique_ptr<MapWidget> mapping_widget; + std::unique_ptr<options_dialog> options_widget; + std::unique_ptr<mapping_dialog> mapping_widget; QShortcut kbd_quit; std::unique_ptr<IFilterDialog> pFilterDialog; std::unique_ptr<IProtocolDialog> pProtocolDialog; @@ -143,8 +145,8 @@ signals: void toggle_tracker(); void restart_tracker(); public: - MainWindow(); - ~MainWindow(); + main_window(); + ~main_window(); static void set_working_directory(); bool maybe_die_on_config_not_writable(const QString& current, QStringList* ini_list); void die_on_config_not_writable(); diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp index fbe274e0..5f884607 100644 --- a/gui/mapping-dialog.cpp +++ b/gui/mapping-dialog.cpp @@ -10,7 +10,7 @@ #include "logic/main-settings.hpp" #include "spline/spline-widget.hpp" -MapWidget::MapWidget(Mappings& m) : m(m), widgets{} +mapping_dialog::mapping_dialog(Mappings& m) : m(m), widgets{} { ui.setupUi(this); @@ -66,7 +66,7 @@ MapWidget::MapWidget(Mappings& m) : m(m), widgets{} tie_setting(s.a_pitch.clamp_y_, ui.max_pitch_output); } -void MapWidget::load() +void mapping_dialog::load() { struct { spline_widget* qfc; @@ -145,12 +145,12 @@ void MapWidget::load() } } -void MapWidget::closeEvent(QCloseEvent*) +void mapping_dialog::closeEvent(QCloseEvent*) { invalidate_dialog(); } -void MapWidget::refresh_tab() +void mapping_dialog::refresh_tab() { if (!isVisible()) return; @@ -166,7 +166,7 @@ void MapWidget::refresh_tab() qDebug() << "map-widget: bad index" << idx; } -void MapWidget::save_dialog() +void mapping_dialog::save_dialog() { s.b_map->save(); @@ -181,7 +181,7 @@ void MapWidget::save_dialog() } } -void MapWidget::invalidate_dialog() +void mapping_dialog::invalidate_dialog() { s.b_map->reload(); @@ -193,13 +193,13 @@ void MapWidget::invalidate_dialog() }); } -void MapWidget::doOK() +void mapping_dialog::doOK() { save_dialog(); close(); } -void MapWidget::doCancel() +void mapping_dialog::doCancel() { invalidate_dialog(); close(); diff --git a/gui/mapping-dialog.hpp b/gui/mapping-dialog.hpp index ba5d1867..5ab8a066 100644 --- a/gui/mapping-dialog.hpp +++ b/gui/mapping-dialog.hpp @@ -1,7 +1,9 @@ #pragma once +#include "export.hpp" + #include "logic/mappings.hpp" -#include "ui_mapping-dialog.h" +#include "gui/ui_mapping-dialog.h" #include <QWidget> #include <QDialog> @@ -9,14 +11,14 @@ #include <QCloseEvent> #include <QCheckBox> -class MapWidget final : public QDialog +class OTR_GUI_EXPORT mapping_dialog final : public QDialog { Q_OBJECT public: - MapWidget(Mappings& m); + mapping_dialog(Mappings& m); void refresh_tab(); private: - Ui::mapping_window ui; + Ui::mapping_dialog ui; Mappings& m; main_settings s; diff --git a/gui/mapping-dialog.ui b/gui/mapping-dialog.ui index 7db6f425..58b8ad1f 100644 --- a/gui/mapping-dialog.ui +++ b/gui/mapping-dialog.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>mapping_window</class> - <widget class="QWidget" name="mapping_window"> + <class>mapping_dialog</class> + <widget class="QWidget" name="mapping_dialog"> <property name="geometry"> <rect> <x>0</x> diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp index 806f0b47..e9f58aad 100644 --- a/gui/process_detector.cpp +++ b/gui/process_detector.cpp @@ -20,35 +20,35 @@ static constexpr inline auto RECORD_SEPARATOR = QChar(char(0x1e)); // RS ^] static constexpr inline auto UNIT_SEPARATOR = QChar(char(0x1f)); // US ^_ -void settings::set_game_list(const QString &game_list) +void proc_detector_settings::set_game_list(const QString &game_list) { group::with_global_settings_object([&](QSettings& settings) { settings.setValue("executable-list", game_list); }); } -QString settings::get_game_list() +QString proc_detector_settings::get_game_list() { return group::with_global_settings_object([&](QSettings& settings) { return settings.value("executable-list").toString(); }); } -bool settings::is_enabled() +bool proc_detector_settings::is_enabled() { return group::with_global_settings_object([&](QSettings& settings) { return settings.value("executable-detector-enabled", false).toBool(); }); } -void settings::set_is_enabled(bool enabled) +void proc_detector_settings::set_is_enabled(bool enabled) { group::with_global_settings_object([&](QSettings& settings) { settings.setValue("executable-detector-enabled", enabled); }); } -QHash<QString, QString> settings::split_process_names() +QHash<QString, QString> proc_detector_settings::split_process_names() { QHash<QString, QString> ret; QString str = get_game_list(); @@ -79,7 +79,7 @@ void BrowseButton::browse() tr("Set executable name"), dir_path, tr("Executable (*.exe);;All Files (*)")); - MainWindow::set_working_directory(); + main_window::set_working_directory(); filename = QFileInfo(filename).fileName(); if (!filename.isNull()) twi->setText(filename); @@ -132,7 +132,7 @@ process_detector::process_detector(QWidget* parent) : QWidget(parent) QResizeEvent e(ui.tableWidget->size(), ui.tableWidget->size()); ui.tableWidget->resizeEvent(&e); - settings s; + proc_detector_settings s; ui.enabled->setChecked(s.is_enabled()); } @@ -173,7 +173,7 @@ bool process_detector_worker::should_stop() if (last_exe_name == "") return false; - settings s; + proc_detector_settings s; if (!s.is_enabled()) { @@ -193,7 +193,7 @@ bool process_detector_worker::should_stop() bool process_detector_worker::config_to_start(QString& str) { - settings s; + proc_detector_settings s; if (!s.is_enabled()) { last_exe_name = ""; diff --git a/gui/process_detector.h b/gui/process_detector.h index 475ebde0..16d50e42 100644 --- a/gui/process_detector.h +++ b/gui/process_detector.h @@ -8,6 +8,8 @@ #pragma once +#include "export.hpp" + #include <QObject> #include <QWidget> #include <QTableWidget> @@ -17,7 +19,7 @@ #include "process-detector-fancy-table.hpp" #include "options/options.hpp" -struct settings +struct OTR_GUI_EXPORT proc_detector_settings { QHash<QString, QString> split_process_names(); QString get_game_list(); @@ -26,12 +28,12 @@ struct settings void set_is_enabled(bool enabled); }; -class process_detector final : public QWidget +class OTR_GUI_EXPORT process_detector final : public QWidget { Q_OBJECT Ui_process_detector ui; - settings s; + proc_detector_settings s; int add_row(QString exe_name = "...", QString profile = ""); void add_items(); @@ -56,10 +58,10 @@ public slots: void browse(); }; -class process_detector_worker : QObject +class OTR_GUI_EXPORT process_detector_worker : QObject { Q_OBJECT - settings s; + proc_detector_settings s; QString last_exe_name; public: bool config_to_start(QString& s); diff --git a/gui/settings.cpp b/gui/settings.cpp index 3b14dec7..b6d4255e 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -14,7 +14,7 @@ #include <QDialog> #include <QFileDialog> -QString OptionsDialog::kopts_to_string(const key_opts& kopts) +QString options_dialog::kopts_to_string(const key_opts& kopts) { if (static_cast<QString>(kopts.guid) != "") { @@ -31,7 +31,7 @@ QString OptionsDialog::kopts_to_string(const key_opts& kopts) return kopts.keycode; } -void OptionsDialog::set_disable_translation_state(bool value) +void options_dialog::set_disable_translation_state(bool value) { group::with_global_settings_object([&](QSettings& s) { @@ -39,7 +39,7 @@ void OptionsDialog::set_disable_translation_state(bool value) }); } -OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) : +options_dialog::options_dialog(std::function<void(bool)> pause_keybindings) : pause_keybindings(pause_keybindings) { ui.setupUi(this); @@ -145,22 +145,22 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) : } } -void OptionsDialog::closeEvent(QCloseEvent *) +void options_dialog::closeEvent(QCloseEvent *) { done(result()); } -void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) +void options_dialog::bind_key(key_opts& kopts, QLabel* label) { kopts.button = -1; kopts.guid = ""; kopts.keycode = ""; - auto k = new KeyboardListener; + auto k = new keyboard_listener; k->setWindowModality(Qt::ApplicationModal); k->deleteLater(); connect(k, - &KeyboardListener::key_pressed, + &keyboard_listener::key_pressed, this, [&](const QKeySequence& s) { @@ -169,7 +169,7 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) kopts.button = -1; k->close(); }); - connect(k, &KeyboardListener::joystick_button_pressed, + connect(k, &keyboard_listener::joystick_button_pressed, this, [&](const QString& guid, int idx, bool held) { @@ -202,7 +202,7 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) label->setText(kopts_to_string(kopts)); } -void OptionsDialog::doOK() +void options_dialog::doOK() { if (isHidden()) // close() can return true twice in a row it seems return; @@ -216,7 +216,7 @@ void OptionsDialog::doOK() emit closing(); } -void OptionsDialog::doCancel() +void options_dialog::doCancel() { if (isHidden()) // close() can return true twice in a row it seems return; @@ -229,7 +229,7 @@ void OptionsDialog::doCancel() emit closing(); } -void OptionsDialog::done(int res) +void options_dialog::done(int res) { if (isVisible()) { diff --git a/gui/settings.hpp b/gui/settings.hpp index 67c0ee54..63e109a4 100644 --- a/gui/settings.hpp +++ b/gui/settings.hpp @@ -1,19 +1,21 @@ #pragma once -#include "ui_settings-dialog.h" +#include "export.hpp" + +#include "gui/ui_settings-dialog.h" #include "logic/shortcuts.h" #include <QObject> #include <QDialog> #include <QWidget> #include <functional> -class OptionsDialog : public QDialog +class OTR_GUI_EXPORT options_dialog : public QDialog { Q_OBJECT signals: void closing(); public: - OptionsDialog(std::function<void(bool)> pause_keybindings); + options_dialog(std::function<void(bool)> pause_keybindings); private: main_settings main; std::function<void(bool)> pause_keybindings; diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 00000000..627501ea --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,8 @@ +otr_module(executable EXECUTABLE BIN) + +set_target_properties(opentrack-user-interface PROPERTIES + SUFFIX "${opentrack-binary-suffix}" + OUTPUT_NAME "opentrack" +) + +target_link_libraries(opentrack-executable opentrack-user-interface) diff --git a/main/lang/nl_NL.ts b/main/lang/nl_NL.ts new file mode 100644 index 00000000..9e739505 --- /dev/null +++ b/main/lang/nl_NL.ts @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="nl_NL"> +</TS> diff --git a/main/lang/ru_RU.ts b/main/lang/ru_RU.ts new file mode 100644 index 00000000..f62cf2e1 --- /dev/null +++ b/main/lang/ru_RU.ts @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="ru_RU"> +</TS> diff --git a/main/lang/stub.ts b/main/lang/stub.ts new file mode 100644 index 00000000..6401616d --- /dev/null +++ b/main/lang/stub.ts @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1"> +</TS> diff --git a/gui/main.cpp b/main/main.cpp index d07e0d27..03c12a8b 100644 --- a/gui/main.cpp +++ b/main/main.cpp @@ -10,7 +10,7 @@ #endif #include "migration/migration.hpp" -#include "main-window.hpp" +#include "gui/main-window.hpp" #include "options/options.hpp" using namespace options; #include "opentrack-library-path.h" @@ -183,7 +183,7 @@ main(int argc, char** argv) add_win32_path(); #endif - MainWindow::set_working_directory(); + main_window::set_working_directory(); #if !defined(__linux) && !defined _WIN32 // workaround QTBUG-38598 @@ -205,7 +205,7 @@ main(int argc, char** argv) do { - std::shared_ptr<MainWindow> w = std::make_shared<MainWindow>(); + std::shared_ptr<main_window> w = std::make_shared<main_window>(); if (!w->isEnabled()) break; |