From 4b21008a53f2d89a0143976305368584d4ed1e44 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 19:38:08 +0200 Subject: CRLF -> LF conversion .git/index removal Forgot to do it earlier, hence trash commits in recent days --- facetracknoir/clientfiles/FlightGear/readme.txt | 16 +- facetracknoir/ftnoir_curves.ui | 2354 ++++++++++---------- facetracknoir/ftnoir_keyboardshortcuts.ui | 434 ++-- ftnoir_filter_accela/ftnoir_filter_accela.h | 158 +- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 286 +-- ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui | 268 +-- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 446 ++-- ftnoir_protocol_ftn/ftnoir_ftncontrols.ui | 532 ++--- ftnoir_protocol_mouse/ftnoir_mousecontrols.ui | 410 ++-- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 144 +- ftnoir_tracker_aruco/trans_calib.cpp | 88 +- ftnoir_tracker_aruco/trans_calib.h | 76 +- ftnoir_tracker_freepie-udp/freepie-udp-controls.ui | 138 +- ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 132 +- qxt-mini/plat/qxtglobalshortcut_mac.cpp | 456 ++-- qxt-mini/plat/qxtglobalshortcut_x11.cpp | 470 ++-- qxt-mini/qxtglobalshortcut.cpp | 448 ++-- qxt-mini/qxtglobalshortcut.h | 128 +- 18 files changed, 3492 insertions(+), 3492 deletions(-) diff --git a/facetracknoir/clientfiles/FlightGear/readme.txt b/facetracknoir/clientfiles/FlightGear/readme.txt index 0b3d9dfe..48cee837 100644 --- a/facetracknoir/clientfiles/FlightGear/readme.txt +++ b/facetracknoir/clientfiles/FlightGear/readme.txt @@ -1,8 +1,8 @@ -Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml - -$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker - -Adjust paths as necessary. - -cheers, --sh 20131008 +Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml + +$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker + +Adjust paths as necessary. + +cheers, +-sh 20131008 diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index f98bf884..7d6671aa 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -1,1177 +1,1177 @@ - - - UICCurveConfigurationDialog - - - - 0 - 0 - 970 - 655 - - - - - 0 - 0 - - - - Mapping properties - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - background-color: #ccc; - - - - - - - - - QTabWidget::North - - - 6 - - - - Yaw - - - - - 0 - 0 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 166 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - Pitch - - - - - 0 - 0 - 930 - 260 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 199 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Roll - - - - - 0 - 0 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 271 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - X - - - - - 0 - 0 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 228 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - Y - - - - - 0 - 0 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 229 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Z - - - - - 0 - 0 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 263 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - Options - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Center pose - - - Qt::AlignCenter - - - true - - - false - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - TX - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RY - - - - - - - TY - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TZ - - - - - - - RZ - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RX - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - - - - 65536 - 65536 - - - - - true - - - - Output remap - - - Qt::AlignCenter - - - true - - - false - - - - QLayout::SetMinAndMaxSize - - - 6 - - - - - X - - - - - - - Yaw - - - - - - - Pitch - - - - - - - Y - - - - - - - Z - - - - - - - Roll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - Source - - - - - - - Invert - - - - - - - Destination - - - - - - - - - - - 0 - 0 - - - - - - - Translation compensation - - - true - - - - - - - 0 - 0 - - - - - - - Enable - - - - - - - - - - Disable Z axis compensation - - - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - QFunctionConfigurator - QWidget -
qfunctionconfigurator.h
-
-
- - pos_rx - pos_ry - pos_rz - ry_altp - rz_altp - tx_altp - ty_altp - tz_altp - tcomp_enable - tabWidget - pos_tx - buttonBox - pos_ty - rx_altp - pos_tz - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
+ + + UICCurveConfigurationDialog + + + + 0 + 0 + 970 + 655 + + + + + 0 + 0 + + + + Mapping properties + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + background-color: #ccc; + + + + + + + + + QTabWidget::North + + + 6 + + + + Yaw + + + + + 0 + 0 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 166 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + Pitch + + + + + 0 + 0 + 930 + 260 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 199 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Roll + + + + + 0 + 0 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 271 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + X + + + + + 0 + 0 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 228 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + Y + + + + + 0 + 0 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 229 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Z + + + + + 0 + 0 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 263 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + Options + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Center pose + + + Qt::AlignCenter + + + true + + + false + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + TX + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RY + + + + + + + TY + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TZ + + + + + + + RZ + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RX + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + 65536 + 65536 + + + + + true + + + + Output remap + + + Qt::AlignCenter + + + true + + + false + + + + QLayout::SetMinAndMaxSize + + + 6 + + + + + X + + + + + + + Yaw + + + + + + + Pitch + + + + + + + Y + + + + + + + Z + + + + + + + Roll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + Source + + + + + + + Invert + + + + + + + Destination + + + + + + + + + + + 0 + 0 + + + + + + + Translation compensation + + + true + + + + + + + 0 + 0 + + + + + + + Enable + + + + + + + + + + Disable Z axis compensation + + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QFunctionConfigurator + QWidget +
qfunctionconfigurator.h
+
+
+ + pos_rx + pos_ry + pos_rz + ry_altp + rz_altp + tx_altp + ty_altp + tz_altp + tcomp_enable + tabWidget + pos_tx + buttonBox + pos_ty + rx_altp + pos_tz + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 5bdc3334..245b503a 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -1,217 +1,217 @@ - - - UICKeyboardShortcutDialog - - - - 0 - 0 - 371 - 125 - - - - - 0 - 0 - - - - Keyboard shortcuts - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Toggle - - - false - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Keyboard - - - Qt::AlignCenter - - - false - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 0 - 0 - - - - Center - - - false - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - Ding! - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICKeyboardShortcutDialog + + + + 0 + 0 + 371 + 125 + + + + + 0 + 0 + + + + Keyboard shortcuts + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Toggle + + + false + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Keyboard + + + Qt::AlignCenter + + + false + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + Ding! + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index c9a434e7..0a736042 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,79 +1,79 @@ -#pragma once -#include "ui_ftnoir_accela_filtercontrols.h" -#include "facetracknoir/plugin-api.hpp" -#include - -#define ACCELA_SMOOTHING_ROTATION 60.0 -#define ACCELA_SMOOTHING_TRANSLATION 40.0 -#define ACCELA_SECOND_ORDER_ALPHA 100.0 -#define ACCELA_THIRD_ORDER_ALPHA 180.0 - -#include -using namespace options; - -struct settings { - pbundle b; - value rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - rot_deadzone, - trans_deadzone, - expt; - settings() : - b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - rot_deadzone(b, "rotation-deadband", 0), - trans_deadzone(b, "translation-deadband", 0), - expt(b, "exponent", 2) - {} -}; - -class FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); - void reset() { - first_run = true; - } - void receiveSettings() { - s.b->reload(); - } - -private: - settings s; - bool first_run; - double last_output[3][6]; -}; - -class FilterControls: public QWidget, public IFilterDialog -{ - Q_OBJECT -public: - FilterControls(); - void registerFilter(IFilter* filter); - void unregisterFilter(); -private: - Ui::AccelaUICFilterControls ui; - void discard(); - void save(); - FTNoIR_Filter* accela_filter; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_FilterDll : public Metadata -{ -public: - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } - - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } -}; +#pragma once +#include "ui_ftnoir_accela_filtercontrols.h" +#include "facetracknoir/plugin-api.hpp" +#include + +#define ACCELA_SMOOTHING_ROTATION 60.0 +#define ACCELA_SMOOTHING_TRANSLATION 40.0 +#define ACCELA_SECOND_ORDER_ALPHA 100.0 +#define ACCELA_THIRD_ORDER_ALPHA 180.0 + +#include +using namespace options; + +struct settings { + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + rot_deadzone, + trans_deadzone, + expt; + settings() : + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + rot_deadzone(b, "rotation-deadband", 0), + trans_deadzone(b, "translation-deadband", 0), + expt(b, "exponent", 2) + {} +}; + +class FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); + void reset() { + first_run = true; + } + void receiveSettings() { + s.b->reload(); + } + +private: + settings s; + bool first_run; + double last_output[3][6]; +}; + +class FilterControls: public QWidget, public IFilterDialog +{ + Q_OBJECT +public: + FilterControls(); + void registerFilter(IFilter* filter); + void unregisterFilter(); +private: + Ui::AccelaUICFilterControls ui; + void discard(); + void save(); + FTNoIR_Filter* accela_filter; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_FilterDll : public Metadata +{ +public: + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } + + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } +}; diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index a4092c05..575549d6 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -1,143 +1,143 @@ - - - UICFGControls - - - Qt::NonModal - - - - 0 - 0 - 415 - 112 - - - - FlightGear protocol settings - - - - :/images/filter-16.png:/images/filter-16.png - - - Qt::LeftToRight - - - false - - - - - - IP-address remote PC - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFGControls + + + Qt::NonModal + + + + 0 + 0 + 415 + 112 + + + + FlightGear protocol settings + + + + :/images/filter-16.png:/images/filter-16.png + + + Qt::LeftToRight + + + false + + + + + + IP-address remote PC + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui index 6cb066bd..637e4dba 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui +++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui @@ -1,134 +1,134 @@ - - - UICFSUIPCControls - - - Qt::NonModal - - - - 0 - 0 - 512 - 100 - - - - FSUIPC settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 35 - 16777215 - - - - ... - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFSUIPCControls + + + Qt::NonModal + + + + 0 + 0 + 512 + 100 + + + + FSUIPC settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + The DLL should be located in the Modules/ directory of MS FS 2004 + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 35 + 16777215 + + + + ... + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index 941aaff0..554e681a 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -1,223 +1,223 @@ - - - UICFTControls - - - Qt::NonModal - - - true - - - - 0 - 0 - 489 - 402 - - - - - 0 - 0 - - - - - 0 - 0 - - - - freetrack protocol settings - - - - :/images/freetrack.png:/images/freetrack.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - TIRViews - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Qt::RightToLeft - - - Memory hacks - - - - - - - Only for very old and buggy old games such as CFS3. - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - - - - 0 - 0 - - - - TrackIR.exe - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Qt::RightToLeft - - - Using EZCA - - - - - - - FSX-specific EZCA protocol hacks - - - true - - - - - - - - - - - 0 - 0 - - - - Select interface - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - - - - Disable one of the protocols if game is confused by presence of both at the same time. - - - true - - - - - - - - - - - 0 - 0 - - - - Repair NPClient location - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Locate DLL - - - - - - - Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. - - - true - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFTControls + + + Qt::NonModal + + + true + + + + 0 + 0 + 489 + 402 + + + + + 0 + 0 + + + + + 0 + 0 + + + + freetrack protocol settings + + + + :/images/freetrack.png:/images/freetrack.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + TIRViews + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + Memory hacks + + + + + + + Only for very old and buggy old games such as CFS3. + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + TrackIR.exe + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + Using EZCA + + + + + + + FSX-specific EZCA protocol hacks + + + true + + + + + + + + + + + 0 + 0 + + + + Select interface + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + + + + Disable one of the protocols if game is confused by presence of both at the same time. + + + true + + + + + + + + + + + 0 + 0 + + + + Repair NPClient location + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Locate DLL + + + + + + + Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. + + + true + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui index 48679f3c..ca811e99 100644 --- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui +++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui @@ -1,266 +1,266 @@ - - - UICFTNControls - - - Qt::NonModal - - - - 0 - 0 - 411 - 169 - - - - UDP protocol settings - - - - :/images/facetracknoir.png:/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - btnOK - btnCancel - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFTNControls + + + Qt::NonModal + + + + 0 + 0 + 411 + 169 + + + + UDP protocol settings + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui index 2705fff7..258ed06a 100644 --- a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui +++ b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui @@ -1,205 +1,205 @@ - - - UICMOUSEControls - - - Qt::NonModal - - - - 0 - 0 - 257 - 114 - - - - Mouse protocol settings - - - - :/images/mouse.png:/images/mouse.png - - - Qt::LeftToRight - - - false - - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Map mouse Y to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 0 - 0 - - - - Map mouse X to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICMOUSEControls + + + Qt::NonModal + + + + 0 + 0 + 257 + 114 + + + + Mouse protocol settings + + + + :/images/mouse.png:/images/mouse.png + + + Qt::LeftToRight + + + false + + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Map mouse Y to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 0 + 0 + + + + Map mouse X to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 87dc8d86..5b2fd291 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -1,72 +1,72 @@ - - - UICSCControls - - - Qt::NonModal - - - - 0 - 0 - 290 - 79 - - - - SimConnect settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - FSX version - - - - - - - - SP1 - - - - - SP2 - - - - - Acceleration - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICSCControls + + + Qt::NonModal + + + + 0 + 0 + 290 + 79 + + + + SimConnect settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + FSX version + + + + + + + + SP1 + + + + + SP2 + + + + + Acceleration + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_aruco/trans_calib.cpp b/ftnoir_tracker_aruco/trans_calib.cpp index dd18399a..b1f956b4 100644 --- a/ftnoir_tracker_aruco/trans_calib.cpp +++ b/ftnoir_tracker_aruco/trans_calib.cpp @@ -1,44 +1,44 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "trans_calib.h" - -using namespace cv; - -//----------------------------------------------------------------------------- -TranslationCalibrator::TranslationCalibrator() -{ - reset(); -} - -void TranslationCalibrator::reset() -{ - P = Matx66f::zeros(); - y = Vec6f(0,0,0, 0,0,0); -} - -void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) -{ - Matx H_k_T = Matx::zeros(); - for (int i=0; i<3; ++i) { - for (int j=0; j<3; ++j) { - H_k_T(i,j) = R_CM_k(j,i); - } - } - for (int i=0; i<3; ++i) - { - H_k_T(3+i,i) = 1.0; - } - P += H_k_T * H_k_T.t(); - y += H_k_T * t_CM_k; -} - -Vec3f TranslationCalibrator::get_estimate() -{ - Vec6f x = P.inv() * y; - return Vec3f(x[0], x[1], x[2]); -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "trans_calib.h" + +using namespace cv; + +//----------------------------------------------------------------------------- +TranslationCalibrator::TranslationCalibrator() +{ + reset(); +} + +void TranslationCalibrator::reset() +{ + P = Matx66f::zeros(); + y = Vec6f(0,0,0, 0,0,0); +} + +void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) +{ + Matx H_k_T = Matx::zeros(); + for (int i=0; i<3; ++i) { + for (int j=0; j<3; ++j) { + H_k_T(i,j) = R_CM_k(j,i); + } + } + for (int i=0; i<3; ++i) + { + H_k_T(3+i,i) = 1.0; + } + P += H_k_T * H_k_T.t(); + y += H_k_T * t_CM_k; +} + +Vec3f TranslationCalibrator::get_estimate() +{ + Vec6f x = P.inv() * y; + return Vec3f(x[0], x[1], x[2]); +} diff --git a/ftnoir_tracker_aruco/trans_calib.h b/ftnoir_tracker_aruco/trans_calib.h index f2521690..609c9af1 100644 --- a/ftnoir_tracker_aruco/trans_calib.h +++ b/ftnoir_tracker_aruco/trans_calib.h @@ -1,39 +1,39 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef TRANSCALIB_H -#define TRANSCALIB_H - -#include - -//----------------------------------------------------------------------------- -// Calibrates the translation from head to model = t_MH -// by recursive least squares / -// kalman filter in information form with identity noise covariance -// measurement equation when head position = t_CH is fixed: -// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k - -class TranslationCalibrator -{ -public: - TranslationCalibrator(); - - // reset the calibration process - void reset(); - - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - - // get the current estimate for t_MH - cv::Vec3f get_estimate(); - -protected: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) -}; - +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef TRANSCALIB_H +#define TRANSCALIB_H + +#include + +//----------------------------------------------------------------------------- +// Calibrates the translation from head to model = t_MH +// by recursive least squares / +// kalman filter in information form with identity noise covariance +// measurement equation when head position = t_CH is fixed: +// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k + +class TranslationCalibrator +{ +public: + TranslationCalibrator(); + + // reset the calibration process + void reset(); + + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + + // get the current estimate for t_MH + cv::Vec3f get_estimate(); + +protected: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) +}; + #endif //TRANSCALIB_H \ No newline at end of file diff --git a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui index 9870372a..48290bf2 100644 --- a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui +++ b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui @@ -1,69 +1,69 @@ - - - UI_freepie_udp_dialog - - - Qt::NonModal - - - - 0 - 0 - 198 - 71 - - - - UDP tracker settings - - - - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - UDP port - - - - - - - 0 - - - 65535 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UI_freepie_udp_dialog + + + Qt::NonModal + + + + 0 + 0 + 198 + 71 + + + + UDP tracker settings + + + + ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + UDP port + + + + + + + 0 + + + 65535 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index f485e67f..4a5624cf 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -1,66 +1,66 @@ - - - UICFTNClientControls - - - Qt::NonModal - - - - 0 - 0 - 216 - 71 - - - - UDP tracker settings - - - - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - Port - - - - - - - 0 - - - 65535 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - spinPortNumber - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFTNClientControls + + + Qt::NonModal + + + + 0 + 0 + 216 + 71 + + + + UDP tracker settings + + + + ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + Port + + + + + + + 0 + + + 65535 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + spinPortNumber + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/qxt-mini/plat/qxtglobalshortcut_mac.cpp b/qxt-mini/plat/qxtglobalshortcut_mac.cpp index f43c773a..fbf86a94 100644 --- a/qxt-mini/plat/qxtglobalshortcut_mac.cpp +++ b/qxt-mini/plat/qxtglobalshortcut_mac.cpp @@ -1,4 +1,4 @@ -#include +#include /**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. ** See the Qxt AUTHORS file for a list of authors and copyright holders. @@ -29,235 +29,235 @@ ** *****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include - -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) -{ - Q_UNUSED(nextHandler); - Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); if(id != Identifier()) - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); - } - return noErr; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKey; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - switch (key) - { - case Qt::Key_Return: - return kVK_Return; - case Qt::Key_Enter: - return kVK_ANSI_KeypadEnter; - case Qt::Key_Tab: - return kVK_Tab; - case Qt::Key_Space: - return kVK_Space; - case Qt::Key_Backspace: - return kVK_Delete; - case Qt::Key_Control: - return kVK_Command; - case Qt::Key_Shift: - return kVK_Shift; - case Qt::Key_CapsLock: - return kVK_CapsLock; - case Qt::Key_Option: - return kVK_Option; - case Qt::Key_Meta: - return kVK_Control; - case Qt::Key_F17: - return kVK_F17; - case Qt::Key_VolumeUp: - return kVK_VolumeUp; - case Qt::Key_VolumeDown: - return kVK_VolumeDown; - case Qt::Key_F18: - return kVK_F18; - case Qt::Key_F19: - return kVK_F19; - case Qt::Key_F20: - return kVK_F20; - case Qt::Key_F5: - return kVK_F5; - case Qt::Key_F6: - return kVK_F6; - case Qt::Key_F7: - return kVK_F7; - case Qt::Key_F3: - return kVK_F3; - case Qt::Key_F8: - return kVK_F8; - case Qt::Key_F9: - return kVK_F9; - case Qt::Key_F11: - return kVK_F11; - case Qt::Key_F13: - return kVK_F13; - case Qt::Key_F16: - return kVK_F16; - case Qt::Key_F14: - return kVK_F14; - case Qt::Key_F10: - return kVK_F10; - case Qt::Key_F12: - return kVK_F12; - case Qt::Key_F15: - return kVK_F15; - case Qt::Key_Help: - return kVK_Help; - case Qt::Key_Home: - return kVK_Home; - case Qt::Key_PageUp: - return kVK_PageUp; - case Qt::Key_Delete: - return kVK_ForwardDelete; - case Qt::Key_F4: - return kVK_F4; - case Qt::Key_End: - return kVK_End; - case Qt::Key_F2: - return kVK_F2; - case Qt::Key_PageDown: - return kVK_PageDown; - case Qt::Key_F1: - return kVK_F1; - case Qt::Key_Left: - return kVK_LeftArrow; - case Qt::Key_Right: - return kVK_RightArrow; - case Qt::Key_Down: - return kVK_DownArrow; - case Qt::Key_Up: - return kVK_UpArrow; - default: - ; - } - - if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - CFDataRef currentLayoutData; - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - - if (currentKeyboard == NULL) - return 0; - - currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - CFRelease(currentKeyboard); - if (currentLayoutData == NULL) - return 0; - - UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - uint8_t *data = (uint8_t*)header; - // God, would a little documentation for this shit kill you... - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { qxt_mac_handler_installed = true; - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); -} + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, void *message, long *result) { diff --git a/qxt-mini/plat/qxtglobalshortcut_x11.cpp b/qxt-mini/plat/qxtglobalshortcut_x11.cpp index 0c203dd8..f18f86db 100644 --- a/qxt-mini/plat/qxtglobalshortcut_x11.cpp +++ b/qxt-mini/plat/qxtglobalshortcut_x11.cpp @@ -1,235 +1,235 @@ -#include "../qxtglobalshortcut_p.h" -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#include -#include -// include private header for great justice -sh 20131015 -#include -#include -#include "qplatformnativeinterface.h" - -namespace { - -const QVector maskModifiers = QVector() - << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); - -typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); - -class QxtX11ErrorHandler { -public: - static bool error; - - static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) - { - Q_UNUSED(display); - switch (event->error_code) - { - case BadAccess: - case BadValue: - case BadWindow: - if (event->request_code == 33 /* X_GrabKey */ || - event->request_code == 34 /* X_UngrabKey */) - { - error = true; - //TODO: - //char errstr[256]; - //XGetErrorText(dpy, err->error_code, errstr, 256); - } - } - return 0; - } - - QxtX11ErrorHandler() - { - error = false; - m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); - } - - ~QxtX11ErrorHandler() - { - XSetErrorHandler(m_previousErrorHandler); - } - -private: - X11ErrorHandler m_previousErrorHandler; -}; - -bool QxtX11ErrorHandler::error = false; - -class QxtX11Data { -public: - QxtX11Data() - { -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) - m_display = QX11Info::display(); -#else - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - void *display = native->nativeResourceForScreen(QByteArray("display"), - QGuiApplication::primaryScreen()); - m_display = reinterpret_cast(display); -#endif - } - - bool isValid() - { - return m_display != 0; - } - - Display *display() - { - Q_ASSERT(isValid()); - return m_display; - } - - Window rootWindow() - { - return DefaultRootWindow(display()); - } - - bool grabKey(quint32 keycode, quint32 modifiers, Window window) - { - QxtX11ErrorHandler errorHandler; - - for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { - XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, - GrabModeAsync, GrabModeAsync); - } - - if (errorHandler.error) { - ungrabKey(keycode, modifiers, window); - return false; - } - - return true; - } - - bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) - { - QxtX11ErrorHandler errorHandler; - - foreach (quint32 maskMods, maskModifiers) { - XUngrabKey(display(), keycode, modifiers | maskMods, window); - } - - return !errorHandler.error; - } - -private: - Display *m_display; -}; - -} // namespace - -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) -bool QxtGlobalShortcutPrivate::eventFilter(void *message) -{ - XEvent *event = static_cast(message); - if (event->type == KeyPress) - { - XKeyEvent *key = reinterpret_cast(event); - unsigned int keycode = key->keycode; - unsigned int keystate = key->state; -#else -bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, - void *message, long *result) -{ - Q_UNUSED(result); - - xcb_key_press_event_t *kev = 0; - if (eventType == "xcb_generic_event_t") { - xcb_generic_event_t *ev = static_cast(message); - if ((ev->response_type & 127) == XCB_KEY_PRESS) - kev = static_cast(message); - } - - if (kev != 0) { - unsigned int keycode = kev->detail; - unsigned int keystate = 0; - if(kev->state & XCB_MOD_MASK_1) - keystate |= Mod1Mask; - if(kev->state & XCB_MOD_MASK_CONTROL) - keystate |= ControlMask; - if(kev->state & XCB_MOD_MASK_4) - keystate |= Mod4Mask; - if(kev->state & XCB_MOD_MASK_SHIFT) - keystate |= ShiftMask; -#endif - activateShortcut(keycode, - // Mod1Mask == Alt, Mod4Mask == Meta - keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= ShiftMask; - if (modifiers & Qt::ControlModifier) - native |= ControlMask; - if (modifiers & Qt::AltModifier) - native |= Mod1Mask; - if (modifiers & Qt::MetaModifier) - native |= Mod4Mask; - - // TODO: resolve these? - //if (modifiers & Qt::MetaModifier) - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - QxtX11Data x11; - if (!x11.isValid()) - return 0; - - KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); - if (keysym == NoSymbol) - keysym = static_cast(key); - - return XKeysymToKeycode(x11.display(), keysym); -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtX11Data x11; - return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtX11Data x11; - return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); -} +#include "../qxtglobalshortcut_p.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include +#include +// include private header for great justice -sh 20131015 +#include +#include +#include "qplatformnativeinterface.h" + +namespace { + +const QVector maskModifiers = QVector() + << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); + +typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); + +class QxtX11ErrorHandler { +public: + static bool error; + + static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) + { + Q_UNUSED(display); + switch (event->error_code) + { + case BadAccess: + case BadValue: + case BadWindow: + if (event->request_code == 33 /* X_GrabKey */ || + event->request_code == 34 /* X_UngrabKey */) + { + error = true; + //TODO: + //char errstr[256]; + //XGetErrorText(dpy, err->error_code, errstr, 256); + } + } + return 0; + } + + QxtX11ErrorHandler() + { + error = false; + m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); + } + + ~QxtX11ErrorHandler() + { + XSetErrorHandler(m_previousErrorHandler); + } + +private: + X11ErrorHandler m_previousErrorHandler; +}; + +bool QxtX11ErrorHandler::error = false; + +class QxtX11Data { +public: + QxtX11Data() + { +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + m_display = QX11Info::display(); +#else + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + void *display = native->nativeResourceForScreen(QByteArray("display"), + QGuiApplication::primaryScreen()); + m_display = reinterpret_cast(display); +#endif + } + + bool isValid() + { + return m_display != 0; + } + + Display *display() + { + Q_ASSERT(isValid()); + return m_display; + } + + Window rootWindow() + { + return DefaultRootWindow(display()); + } + + bool grabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { + XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, + GrabModeAsync, GrabModeAsync); + } + + if (errorHandler.error) { + ungrabKey(keycode, modifiers, window); + return false; + } + + return true; + } + + bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + foreach (quint32 maskMods, maskModifiers) { + XUngrabKey(display(), keycode, modifiers | maskMods, window); + } + + return !errorHandler.error; + } + +private: + Display *m_display; +}; + +} // namespace + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool QxtGlobalShortcutPrivate::eventFilter(void *message) +{ + XEvent *event = static_cast(message); + if (event->type == KeyPress) + { + XKeyEvent *key = reinterpret_cast(event); + unsigned int keycode = key->keycode; + unsigned int keystate = key->state; +#else +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) +{ + Q_UNUSED(result); + + xcb_key_press_event_t *kev = 0; + if (eventType == "xcb_generic_event_t") { + xcb_generic_event_t *ev = static_cast(message); + if ((ev->response_type & 127) == XCB_KEY_PRESS) + kev = static_cast(message); + } + + if (kev != 0) { + unsigned int keycode = kev->detail; + unsigned int keystate = 0; + if(kev->state & XCB_MOD_MASK_1) + keystate |= Mod1Mask; + if(kev->state & XCB_MOD_MASK_CONTROL) + keystate |= ControlMask; + if(kev->state & XCB_MOD_MASK_4) + keystate |= Mod4Mask; + if(kev->state & XCB_MOD_MASK_SHIFT) + keystate |= ShiftMask; +#endif + activateShortcut(keycode, + // Mod1Mask == Alt, Mod4Mask == Meta + keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= ShiftMask; + if (modifiers & Qt::ControlModifier) + native |= ControlMask; + if (modifiers & Qt::AltModifier) + native |= Mod1Mask; + if (modifiers & Qt::MetaModifier) + native |= Mod4Mask; + + // TODO: resolve these? + //if (modifiers & Qt::MetaModifier) + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + QxtX11Data x11; + if (!x11.isValid()) + return 0; + + KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); + if (keysym == NoSymbol) + keysym = static_cast(key); + + return XKeysymToKeycode(x11.display(), keysym); +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); +} diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 8515a6b2..45576d37 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -1,224 +1,224 @@ -#include "qxtglobalshortcut.h" -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#include "qxtglobalshortcut_p.h" -#include -#include - -#ifndef Q_OS_MAC -int QxtGlobalShortcutPrivate::ref = 0; -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) -QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; -# endif -#endif // Q_OS_MAC -QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; - -QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) -{ -#ifndef Q_OS_MAC - if (ref == 0) { -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) - prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); -# else - QAbstractEventDispatcher::instance()->installNativeEventFilter(this); -#endif - } - ++ref; -#endif // Q_OS_MAC -} - -QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() -{ -#ifndef Q_OS_MAC - --ref; - if (ref == 0) { - QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); - if (ed != 0) { -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) - ed->setEventFilter(prevEventFilter); -# else - ed->removeNativeEventFilter(this); -# endif - } - } -#endif // Q_OS_MAC -} - -bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) -{ - if (shortcut.toString() == "") return false; - Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; - key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); - mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); - const quint32 nativeKey = nativeKeycode(key); - const quint32 nativeMods = nativeModifiers(mods); - const bool res = registerShortcut(nativeKey, nativeMods); - if (res) - shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); - else - qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); - return res; -} - -bool QxtGlobalShortcutPrivate::unsetShortcut() -{ - bool res = false; - const quint32 nativeKey = nativeKeycode(key); - const quint32 nativeMods = nativeModifiers(mods); - if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) - res = unregisterShortcut(nativeKey, nativeMods); - if (res) - shortcuts.remove(qMakePair(nativeKey, nativeMods)); - else - qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); - key = Qt::Key(0); - mods = Qt::KeyboardModifiers(0); - return res; -} - -void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); - if (shortcut && shortcut->isEnabled()) - emit shortcut->activated(); -} - -/*! - \class QxtGlobalShortcut - \inmodule QxtWidgets - \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". - - A global shortcut triggers even if the application is not active. This - makes it easy to implement applications that react to certain shortcuts - still if some other application is active or if the application is for - example minimized to the system tray. - - Example usage: - \code - QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); - connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); - shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); - \endcode - - \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. - */ - -/*! - \fn QxtGlobalShortcut::activated() - - This signal is emitted when the user types the shortcut's key sequence. - - \sa shortcut - */ - -/*! - Constructs a new QxtGlobalShortcut with \a parent. - */ -QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) - : QObject(parent) -{ - QXT_INIT_PRIVATE(QxtGlobalShortcut); -} - -/*! - Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. - */ -QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) - : QObject(parent) -{ - QXT_INIT_PRIVATE(QxtGlobalShortcut); - setShortcut(shortcut); -} - -/*! - Destructs the QxtGlobalShortcut. - */ -QxtGlobalShortcut::~QxtGlobalShortcut() -{ - if (qxt_d().key != 0) - qxt_d().unsetShortcut(); -} - -/*! - \property QxtGlobalShortcut::shortcut - \brief the shortcut key sequence - - \bold {Note:} Notice that corresponding key press and release events are not - delivered for registered global shortcuts even if they are disabled. - Also, comma separated key sequences are not supported. - Only the first part is used: - - \code - qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); - Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); - \endcode - */ -QKeySequence QxtGlobalShortcut::shortcut() const -{ - return QKeySequence(qxt_d().key | qxt_d().mods); -} - -bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) -{ - if (qxt_d().key != 0) - qxt_d().unsetShortcut(); - return qxt_d().setShortcut(shortcut); -} - -/*! - \property QxtGlobalShortcut::enabled - \brief whether the shortcut is enabled - - A disabled shortcut does not get activated. - - The default value is \c true. - - \sa setDisabled() - */ -bool QxtGlobalShortcut::isEnabled() const -{ - return qxt_d().enabled; -} - -void QxtGlobalShortcut::setEnabled(bool enabled) -{ - qxt_d().enabled = enabled; -} - -/*! - Sets the shortcut \a disabled. - - \sa enabled - */ -void QxtGlobalShortcut::setDisabled(bool disabled) -{ - qxt_d().enabled = !disabled; -} +#include "qxtglobalshortcut.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include "qxtglobalshortcut_p.h" +#include +#include + +#ifndef Q_OS_MAC +int QxtGlobalShortcutPrivate::ref = 0; +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) +QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; +# endif +#endif // Q_OS_MAC +QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; + +QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) +{ +#ifndef Q_OS_MAC + if (ref == 0) { +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); +# else + QAbstractEventDispatcher::instance()->installNativeEventFilter(this); +#endif + } + ++ref; +#endif // Q_OS_MAC +} + +QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() +{ +#ifndef Q_OS_MAC + --ref; + if (ref == 0) { + QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); + if (ed != 0) { +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + ed->setEventFilter(prevEventFilter); +# else + ed->removeNativeEventFilter(this); +# endif + } + } +#endif // Q_OS_MAC +} + +bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) +{ + if (shortcut.toString() == "") return false; + Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; + key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); + mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + const bool res = registerShortcut(nativeKey, nativeMods); + if (res) + shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); + else + qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); + return res; +} + +bool QxtGlobalShortcutPrivate::unsetShortcut() +{ + bool res = false; + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) + res = unregisterShortcut(nativeKey, nativeMods); + if (res) + shortcuts.remove(qMakePair(nativeKey, nativeMods)); + else + qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); + key = Qt::Key(0); + mods = Qt::KeyboardModifiers(0); + return res; +} + +void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); + if (shortcut && shortcut->isEnabled()) + emit shortcut->activated(); +} + +/*! + \class QxtGlobalShortcut + \inmodule QxtWidgets + \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". + + A global shortcut triggers even if the application is not active. This + makes it easy to implement applications that react to certain shortcuts + still if some other application is active or if the application is for + example minimized to the system tray. + + Example usage: + \code + QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); + connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); + shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); + \endcode + + \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. + */ + +/*! + \fn QxtGlobalShortcut::activated() + + This signal is emitted when the user types the shortcut's key sequence. + + \sa shortcut + */ + +/*! + Constructs a new QxtGlobalShortcut with \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); +} + +/*! + Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); + setShortcut(shortcut); +} + +/*! + Destructs the QxtGlobalShortcut. + */ +QxtGlobalShortcut::~QxtGlobalShortcut() +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); +} + +/*! + \property QxtGlobalShortcut::shortcut + \brief the shortcut key sequence + + \bold {Note:} Notice that corresponding key press and release events are not + delivered for registered global shortcuts even if they are disabled. + Also, comma separated key sequences are not supported. + Only the first part is used: + + \code + qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); + Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); + \endcode + */ +QKeySequence QxtGlobalShortcut::shortcut() const +{ + return QKeySequence(qxt_d().key | qxt_d().mods); +} + +bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); + return qxt_d().setShortcut(shortcut); +} + +/*! + \property QxtGlobalShortcut::enabled + \brief whether the shortcut is enabled + + A disabled shortcut does not get activated. + + The default value is \c true. + + \sa setDisabled() + */ +bool QxtGlobalShortcut::isEnabled() const +{ + return qxt_d().enabled; +} + +void QxtGlobalShortcut::setEnabled(bool enabled) +{ + qxt_d().enabled = enabled; +} + +/*! + Sets the shortcut \a disabled. + + \sa enabled + */ +void QxtGlobalShortcut::setDisabled(bool disabled) +{ + qxt_d().enabled = !disabled; +} diff --git a/qxt-mini/qxtglobalshortcut.h b/qxt-mini/qxtglobalshortcut.h index a81942d2..641c07c9 100644 --- a/qxt-mini/qxtglobalshortcut.h +++ b/qxt-mini/qxtglobalshortcut.h @@ -1,64 +1,64 @@ -#ifndef QXTGLOBALSHORTCUT_H -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#define QXTGLOBALSHORTCUT_H - -#include "qxtglobal.h" -#include -#include -class QxtGlobalShortcutPrivate; - -class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject -{ - Q_OBJECT - QXT_DECLARE_PRIVATE(QxtGlobalShortcut) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) - -public: - explicit QxtGlobalShortcut(QObject* parent = 0); - explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); - virtual ~QxtGlobalShortcut(); - - QKeySequence shortcut() const; - bool setShortcut(const QKeySequence& shortcut); - - bool isEnabled() const; - -public Q_SLOTS: - void setEnabled(bool enabled = true); - void setDisabled(bool disabled = true); - -Q_SIGNALS: - void activated(); -}; - -#endif // QXTGLOBALSHORTCUT_H +#ifndef QXTGLOBALSHORTCUT_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#define QXTGLOBALSHORTCUT_H + +#include "qxtglobal.h" +#include +#include +class QxtGlobalShortcutPrivate; + +class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject +{ + Q_OBJECT + QXT_DECLARE_PRIVATE(QxtGlobalShortcut) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) + +public: + explicit QxtGlobalShortcut(QObject* parent = 0); + explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); + virtual ~QxtGlobalShortcut(); + + QKeySequence shortcut() const; + bool setShortcut(const QKeySequence& shortcut); + + bool isEnabled() const; + +public Q_SLOTS: + void setEnabled(bool enabled = true); + void setDisabled(bool disabled = true); + +Q_SIGNALS: + void activated(); +}; + +#endif // QXTGLOBALSHORTCUT_H -- cgit v1.2.3