45 Commits
Author SHA1 Message Date
Skycoder42 547cf7a7cc updated qpm version
fixes #19
2018-03-10 23:22:50 +01:00
Felix Barz f00ae2a071 Merge pull request #18 from semanser/semanser-patch-1
Fix issue with non-English keyboard on Windows (Fixes #17)
2018-03-10 16:11:11 +01:00
Andriy Semenets 9a90aff273 Fix issue with non-English keyboard on Windows
Full issue described in #17.
2018-03-10 16:42:45 +02:00
Felix Barz 080ddd479a Update README.md 2018-02-22 20:53:04 +01:00
Felix Barz 2d21833742 Update README add help text 2018-02-08 15:28:56 +01:00
Skycoder42 fc259100b2 added addGlobalMapping method
Enables overrides for specific key sequences, fixes #11
2017-12-21 18:12:48 +01:00
Felix Barz 670705e4e0 Merge pull request #13 from aknobloch/master
X11 Media Key Support
2017-12-21 11:16:45 +01:00
aknobloch f549a7763f X11 Media Key Support 2017-12-20 20:15:02 -05:00
Skycoder42 d46af31902 Add define to stay compatible to pre Qt5.8 2017-11-08 14:07:59 +01:00
Felix Barz f4665e20ad Merge pull request #10 from Kolcha/master
removed warning for wide range of GCC versions (5,6,7), fixes #9
2017-11-08 12:28:41 +01:00
Kolcha 9a04e8f539 added Q_FALLTHROUGH macro 2017-11-08 14:16:07 +03:00
Kolcha 974af9253c removed warning for wide range of GCC versions (5,6,7) 2017-11-08 12:55:42 +03:00
Skycoder42 9a812a3eb4 Merge branch 'pr8' 2017-10-23 15:36:32 +02:00
Skycoder42 0943bb0494 lib fixup 2017-10-23 15:36:25 +02:00
Martin T. H. Sandsmark b910580fce add target to build as normal library 2017-10-22 14:00:59 +02:00
Skycoder42 c9cfd8fb6f fixed library parts 2017-09-30 22:22:21 +02:00
Skycoder42 7d214ac41e qpmx 2017-09-30 19:22:06 +02:00
Skycoder42 83910c8eca fixed invalid key detection 2017-09-30 19:21:26 +02:00
Skycoder42 91f3542b5d qm update 2017-06-25 14:41:23 +02:00
Skycoder42 1833a053f6 fixed xerrorhandler
fixes #4
2017-06-25 14:40:03 +02:00
Felix Barz f288e85ef1 Create README.md 2017-06-15 11:41:09 +02:00
Skycoder42 2578b69dc5 remove recursive call
detected by #4
2017-06-02 21:24:14 +02:00
Skycoder42 a0678c4cfc qpm update 2017-05-14 22:28:10 +02:00
Skycoder42 cdb4d37453 replaced XSync by XFlush 2017-05-14 22:27:26 +02:00
Skycoder42 9eace8fbbd do not discard events on XSync 2017-05-14 13:39:54 +02:00
Skycoder42 6baf644b40 fixed misread parameter
#3
2017-05-14 13:35:13 +02:00
Skycoder42 3fa176a380 Added XSync call for hotkey without window
For #3
2017-05-14 13:32:06 +02:00
Skycoder42 7c4ef6a03a qpm update 2017-05-01 12:17:18 +02:00
Skycoder42 15e34a7dbf fixed initial tab 2017-05-01 12:15:01 +02:00
Felix Barz b8f32c3381 Merge pull request #2 from ArsenArsen/patch-1
Fix a compile error on MXE
2017-05-01 12:13:48 +02:00
ArsenArsen 10d1e44b21 Fix a compile error on MXE 2017-05-01 11:48:53 +02:00
Skycoder42 040cf5ec0c added qpm 2017-04-18 16:38:02 +02:00
Skycoder42 4446fe0a42 readme update 2017-04-18 16:36:11 +02:00
Skycoder42 53bd8cdd14 code cleanup 2017-04-18 16:31:05 +02:00
Skycoder42 e1f90f15bc namespace fix 2016-12-04 17:53:30 +01:00
Felix Barz 7bcca77c16 Update README.md 2016-12-04 17:42:27 +01:00
Felix Barz 71534b3167 Update README.md 2016-12-04 17:42:12 +01:00
Skycoder42 898e3b9b6d updated doc 2016-12-04 17:28:37 +01:00
Skycoder42 038884883e ... and x11 2016-12-04 17:02:26 +01:00
Skycoder42 c8c857af79 updated osx ui 2016-12-04 16:12:21 +01:00
Skycoder42 686abe219a added native shortcut support (win) 2016-12-04 16:49:53 +01:00
Skycoder42 5cc4b7bf2d moved pri file 2016-12-04 16:20:51 +01:00
Skycoder42 1a5798587c ... on mac 2016-12-04 15:54:29 +01:00
Skycoder42 5d770d60a0 modified native hotkey to allow 0 as valid key 2016-12-04 16:03:12 +01:00
Skycoder42 49da8b1c5c updated 0 to nullptr 2016-11-01 16:28:53 +01:00
21 changed files with 959 additions and 353 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = HotkeyTest TARGET = HotkeyTest
TEMPLATE = app TEMPLATE = app
include(../QHotkey/qhotkey.pri) include(../qhotkey.pri)
SOURCES += main.cpp\ SOURCES += main.cpp\
hottestwidget.cpp hottestwidget.cpp
+29 -1
View File
@@ -1,6 +1,8 @@
#include "hottestwidget.h" #include "hottestwidget.h"
#include "ui_hottestwidget.h" #include "ui_hottestwidget.h"
//#define TEST_MAPPING
HotTestWidget::HotTestWidget(QWidget *parent) : HotTestWidget::HotTestWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::HotTestWidget), ui(new Ui::HotTestWidget),
@@ -11,12 +13,18 @@ HotTestWidget::HotTestWidget(QWidget *parent) :
hotkey_5(new QHotkey(NULL)), hotkey_5(new QHotkey(NULL)),
thread4(new QThread(this)), thread4(new QThread(this)),
thread5(new QThread(this)), thread5(new QThread(this)),
testHotkeys() testHotkeys(),
nativeHotkey(new QHotkey(this))
{ {
ui->setupUi(this); ui->setupUi(this);
this->thread4->start(); this->thread4->start();
this->thread5->start(); this->thread5->start();
#ifdef TEST_MAPPING
//shortcut mapping override
QHotkey::addGlobalMapping(QKeySequence("X"), QHotkey::NativeShortcut());// add invalid mapping to test if the overwrite works for all platforms
#endif
//1 //1
connect(this->ui->hotkeyCheckbox_1, &QCheckBox::toggled, connect(this->ui->hotkeyCheckbox_1, &QCheckBox::toggled,
this->hotkey_1, &QHotkey::setRegistered); this->hotkey_1, &QHotkey::setRegistered);
@@ -91,6 +99,10 @@ HotTestWidget::HotTestWidget(QWidget *parent) :
this->testHotkeys += new QHotkey(Qt::Key_K, Qt::ShiftModifier | Qt::AltModifier, false, this); this->testHotkeys += new QHotkey(Qt::Key_K, Qt::ShiftModifier | Qt::AltModifier, false, this);
connect(this->testHotkeys.last(), &QHotkey::activated, connect(this->testHotkeys.last(), &QHotkey::activated,
this->ui->hotkeyShiftAltKCheckBox_2, &QCheckBox::toggle); this->ui->hotkeyShiftAltKCheckBox_2, &QCheckBox::toggle);
//native
connect(this->nativeHotkey, &QHotkey::activated,
this, &HotTestWidget::increase_native);
} }
HotTestWidget::~HotTestWidget() HotTestWidget::~HotTestWidget()
@@ -217,3 +229,19 @@ void HotTestWidget::on_threadEnableCheckBox_clicked()
this->ui->tabWidget->setCurrentIndex(0); this->ui->tabWidget->setCurrentIndex(0);
} }
void HotTestWidget::on_registeredCheckBox_toggled(bool checked)
{
if(checked) {
this->nativeHotkey->setNativeShortcut({
(quint32)this->ui->nativeKeySpinBox->value(),
(quint32)this->ui->nativeModifiersSpinBox->value()
}, true);
} else
this->nativeHotkey->setRegistered(false);
}
void HotTestWidget::increase_native()
{
this->ui->nativeCount->display(this->ui->nativeCount->intValue() + 1);
}
+5
View File
@@ -39,6 +39,9 @@ private slots:
void on_groupBox_toggled(bool checked); void on_groupBox_toggled(bool checked);
void on_threadEnableCheckBox_clicked(); void on_threadEnableCheckBox_clicked();
void on_registeredCheckBox_toggled(bool checked);
void increase_native();
private: private:
Ui::HotTestWidget *ui; Ui::HotTestWidget *ui;
@@ -52,6 +55,8 @@ private:
QThread *thread5; QThread *thread5;
QList<QHotkey*> testHotkeys; QList<QHotkey*> testHotkeys;
QHotkey *nativeHotkey;
}; };
#endif // HOTTESTWIDGET_H #endif // HOTTESTWIDGET_H
+276 -40
View File
@@ -965,6 +965,194 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="nativeTab">
<attribute name="title">
<string>Native Shortcut</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,1">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;QHotkey allows you to set native shortcuts explicitly. These, of course, only work on the platform they were choosen for. All platform use special constants for their key codes and modifiers, which makes it pretty simple to use them from code. If you want to test them out here, google for the tables.&lt;/p&gt;&lt;p&gt;In most cases, you will not need to specify native shortcuts directly. However, as explaind on previos tabs, some shotcuts may not be creatable from Qt's key (e.g. Numblock numbers). In that case, you can set the directly.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Example: Ctrl+A&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Windows:&lt;/span&gt; Key: &lt;span style=&quot; font-style:italic;&quot;&gt;0x0041&lt;/span&gt;, Modifier: &lt;span style=&quot; font-style:italic;&quot;&gt;0x0002&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;X11:&lt;/span&gt; Key: &lt;span style=&quot; font-style:italic;&quot;&gt;0x0026&lt;/span&gt;, Modifier: &lt;span style=&quot; font-style:italic;&quot;&gt;0x0004&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;OsX:&lt;/span&gt; Key: &lt;span style=&quot; font-style:italic;&quot;&gt;0x0000&lt;/span&gt;, Modifier: &lt;span style=&quot; font-style:italic;&quot;&gt;0x0100&lt;/span&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="keyLabel">
<property name="text">
<string>Key:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="nativeKeySpinBox">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="modifiersLabel">
<property name="text">
<string>Modifiers:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="nativeModifiersSpinBox">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="countLabel">
<property name="text">
<string>Count:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLCDNumber" name="nativeCount">
<property name="enabled">
<bool>false</bool>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="registeredLabel">
<property name="text">
<string>Registered:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="registeredCheckBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@@ -996,12 +1184,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>36</x> <x>31</x>
<y>52</y> <y>45</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>375</x> <x>417</x>
<y>62</y> <y>43</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1012,12 +1200,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>44</x> <x>31</x>
<y>82</y> <y>74</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>359</x> <x>417</x>
<y>82</y> <y>72</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1028,12 +1216,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>52</x> <x>31</x>
<y>113</y> <y>103</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>375</x> <x>417</x>
<y>120</y> <y>101</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1044,12 +1232,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>58</x> <x>31</x>
<y>140</y> <y>132</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>375</x> <x>417</x>
<y>149</y> <y>130</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1060,12 +1248,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>28</x> <x>31</x>
<y>163</y> <y>161</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>375</x> <x>417</x>
<y>178</y> <y>159</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1076,12 +1264,12 @@
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>62</x> <x>31</x>
<y>50</y> <y>45</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>127</x> <x>109</x>
<y>52</y> <y>43</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1092,12 +1280,12 @@
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>83</x> <x>31</x>
<y>79</y> <y>74</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>161</x> <x>109</x>
<y>81</y> <y>72</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1108,12 +1296,12 @@
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>75</x> <x>31</x>
<y>106</y> <y>103</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>116</x> <x>109</x>
<y>109</y> <y>101</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1124,12 +1312,12 @@
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>69</x> <x>31</x>
<y>135</y> <y>132</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>117</x> <x>109</x>
<y>141</y> <y>130</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -1140,12 +1328,60 @@
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>81</x> <x>31</x>
<y>168</y> <y>161</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>145</x> <x>109</x>
<y>164</y> <y>159</y>
</hint>
</hints>
</connection>
<connection>
<sender>registeredCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>nativeCount</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>93</x>
<y>326</y>
</hint>
<hint type="destinationlabel">
<x>150</x>
<y>349</y>
</hint>
</hints>
</connection>
<connection>
<sender>registeredCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>nativeModifiersSpinBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>108</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>111</x>
<y>305</y>
</hint>
</hints>
</connection>
<connection>
<sender>registeredCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>nativeKeySpinBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>183</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>194</x>
<y>279</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
+9
View File
@@ -1,11 +1,20 @@
#include "hottestwidget.h" #include "hottestwidget.h"
#include <QApplication> #include <QApplication>
//#define START_BACKGROUND
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
HotTestWidget w; HotTestWidget w;
#ifdef START_BACKGROUND
auto startKey = new QHotkey(QKeySequence(Qt::MetaModifier | Qt::ControlModifier | Qt::Key_S), true, &w);
QObject::connect(startKey, &QHotkey::activated,
&w, &QWidget::show);
#else
w.show(); w.show();
#endif
return a.exec(); return a.exec();
} }
+2 -1
View File
@@ -1,7 +1,8 @@
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
HotkeyTest HotkeyTest \
QHotkey
DISTFILES += README.md \ DISTFILES += README.md \
LICENSE \ LICENSE \
+16
View File
@@ -0,0 +1,16 @@
TEMPLATE = lib
win32: CONFIG += dll
TARGET = QHotkey
VERSION = 1.2.1
include(../qhotkey.pri)
DEFINES += QHOTKEY_LIB QHOTKEY_LIB_BUILD
# use INSTALL_ROOT to modify the install location
headers.files = $$PUBLIC_HEADERS
headers.path = $$[QT_INSTALL_HEADERS]
target.path = $$[QT_INSTALL_LIBS]
INSTALLS += target headers
+163 -56
View File
@@ -8,72 +8,91 @@
Q_LOGGING_CATEGORY(logQHotkey, "QHotkey") Q_LOGGING_CATEGORY(logQHotkey, "QHotkey")
void QHotkey::addGlobalMapping(const QKeySequence &shortcut, const QHotkey::NativeShortcut &nativeShortcut)
{
QMetaObject::invokeMethod(QHotkeyPrivate::instance(), "addMappingInvoked", Qt::QueuedConnection,
Q_ARG(Qt::Key, Qt::Key(shortcut[0] & ~Qt::KeyboardModifierMask)),
Q_ARG(Qt::KeyboardModifiers, Qt::KeyboardModifiers(shortcut[0] & Qt::KeyboardModifierMask)),
Q_ARG(QHotkey::NativeShortcut, nativeShortcut));
}
QHotkey::QHotkey(QObject *parent) : QHotkey::QHotkey(QObject *parent) :
QObject(parent), QObject(parent),
key(Qt::Key_unknown), _keyCode(Qt::Key_unknown),
mods(Qt::NoModifier), _modifiers(Qt::NoModifier),
nativeShortcut(), _nativeShortcut(),
registered(false) _registered(false)
{} {}
QHotkey::QHotkey(const QKeySequence &sequence, bool autoRegister, QObject *parent) : QHotkey::QHotkey(const QKeySequence &sequence, bool autoRegister, QObject *parent) :
QHotkey(parent) QHotkey(parent)
{ {
this->setShortcut(sequence, autoRegister); setShortcut(sequence, autoRegister);
} }
QHotkey::QHotkey(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister, QObject *parent) : QHotkey::QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister, QObject *parent) :
QHotkey(parent) QHotkey(parent)
{ {
this->setShortcut(key, modifiers, autoRegister); setShortcut(keyCode, modifiers, autoRegister);
}
QHotkey::QHotkey(const QHotkey::NativeShortcut &shortcut, bool autoRegister, QObject *parent) :
QHotkey(parent)
{
setNativeShortcut(shortcut, autoRegister);
} }
QHotkey::~QHotkey() QHotkey::~QHotkey()
{ {
if(this->registered) if(_registered)
QHotkeyPrivate::instance()->removeShortcut(this); QHotkeyPrivate::instance()->removeShortcut(this);
} }
QKeySequence QHotkey::shortcut() const QKeySequence QHotkey::shortcut() const
{ {
if(this->key == Qt::Key_unknown) if(_keyCode == Qt::Key_unknown)
return QKeySequence(); return QKeySequence();
else else
return QKeySequence(this->key | this->mods); return QKeySequence(_keyCode | _modifiers);
} }
Qt::Key QHotkey::keyCode() const Qt::Key QHotkey::keyCode() const
{ {
return this->key; return _keyCode;
} }
Qt::KeyboardModifiers QHotkey::modifiers() const Qt::KeyboardModifiers QHotkey::modifiers() const
{ {
return this->mods; return _modifiers;
}
QHotkey::NativeShortcut QHotkey::currentNativeShortcut() const
{
return _nativeShortcut;
} }
bool QHotkey::isRegistered() const bool QHotkey::isRegistered() const
{ {
return this->registered; return _registered;
} }
bool QHotkey::setShortcut(const QKeySequence &shortcut, bool autoRegister) bool QHotkey::setShortcut(const QKeySequence &shortcut, bool autoRegister)
{ {
if(shortcut.isEmpty()) { if(shortcut.isEmpty()) {
return this->resetShortcut(); return resetShortcut();
} else if(shortcut.count() > 1) { } else if(shortcut.count() > 1) {
qCWarning(logQHotkey, "Keysequences with multiple shortcuts are not allowed! " qCWarning(logQHotkey, "Keysequences with multiple shortcuts are not allowed! "
"Only the first shortcut will be used!"); "Only the first shortcut will be used!");
} }
return this->setShortcut(Qt::Key(shortcut[0] & ~Qt::KeyboardModifierMask), return setShortcut(Qt::Key(shortcut[0] & ~Qt::KeyboardModifierMask),
Qt::KeyboardModifiers(shortcut[0] & Qt::KeyboardModifierMask), Qt::KeyboardModifiers(shortcut[0] & Qt::KeyboardModifierMask),
autoRegister); autoRegister);
} }
bool QHotkey::setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister) bool QHotkey::setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister)
{ {
if(this->registered) { if(_registered) {
if(autoRegister) { if(autoRegister) {
if(!QHotkeyPrivate::instance()->removeShortcut(this)) if(!QHotkeyPrivate::instance()->removeShortcut(this))
return false; return false;
@@ -81,49 +100,75 @@ bool QHotkey::setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers, bool aut
return false; return false;
} }
if(key == Qt::Key_unknown) { if(keyCode == Qt::Key_unknown) {
this->key = Qt::Key_unknown; _keyCode = Qt::Key_unknown;
this->mods = Qt::NoModifier; _modifiers = Qt::NoModifier;
this->nativeShortcut = NativeShortcut(); _nativeShortcut = NativeShortcut();
return true; return true;
} }
this->key = key; _keyCode = keyCode;
this->mods = modifiers; _modifiers = modifiers;
this->nativeShortcut = QHotkeyPrivate::instance()->nativeShortcut(key, modifiers); _nativeShortcut = QHotkeyPrivate::instance()->nativeShortcut(keyCode, modifiers);
if(QHotkeyPrivate::testValid(this->nativeShortcut)) { if(_nativeShortcut.isValid()) {
if(autoRegister) if(autoRegister)
return QHotkeyPrivate::instance()->addShortcut(this); return QHotkeyPrivate::instance()->addShortcut(this);
else else
return true; return true;
} else { } else {
qCWarning(logQHotkey) << "Unable to map shortcut to native keys. Key:" << key << "Modifiers:" << modifiers; qCWarning(logQHotkey) << "Unable to map shortcut to native keys. Key:" << keyCode << "Modifiers:" << modifiers;
this->key = Qt::Key_unknown; _keyCode = Qt::Key_unknown;
this->mods = Qt::NoModifier; _modifiers = Qt::NoModifier;
this->nativeShortcut = NativeShortcut(); _nativeShortcut = NativeShortcut();
return false; return false;
} }
} }
bool QHotkey::resetShortcut() bool QHotkey::resetShortcut()
{ {
if(this->registered && if(_registered &&
!QHotkeyPrivate::instance()->removeShortcut(this)) { !QHotkeyPrivate::instance()->removeShortcut(this)) {
return false; return false;
} }
this->key = Qt::Key_unknown; _keyCode = Qt::Key_unknown;
this->mods = Qt::NoModifier; _modifiers = Qt::NoModifier;
this->nativeShortcut = NativeShortcut(); _nativeShortcut = NativeShortcut();
return true; return true;
} }
bool QHotkey::setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool autoRegister)
{
if(_registered) {
if(autoRegister) {
if(!QHotkeyPrivate::instance()->removeShortcut(this))
return false;
} else
return false;
}
if(nativeShortcut.isValid()) {
_keyCode = Qt::Key_unknown;
_modifiers = Qt::NoModifier;
_nativeShortcut = nativeShortcut;
if(autoRegister)
return QHotkeyPrivate::instance()->addShortcut(this);
else
return true;
} else {
_keyCode = Qt::Key_unknown;
_modifiers = Qt::NoModifier;
_nativeShortcut = NativeShortcut();
return true;
}
}
bool QHotkey::setRegistered(bool registered) bool QHotkey::setRegistered(bool registered)
{ {
if(this->registered && !registered) if(_registered && !registered)
return QHotkeyPrivate::instance()->removeShortcut(this); return QHotkeyPrivate::instance()->removeShortcut(this);
else if(!this->registered && registered) { else if(!_registered && registered) {
if(!QHotkeyPrivate::testValid(this->nativeShortcut)) if(!_nativeShortcut.isValid())
return false; return false;
else else
return QHotkeyPrivate::instance()->addShortcut(this); return QHotkeyPrivate::instance()->addShortcut(this);
@@ -144,15 +189,15 @@ QHotkeyPrivate::QHotkeyPrivate() :
QHotkeyPrivate::~QHotkeyPrivate() QHotkeyPrivate::~QHotkeyPrivate()
{ {
if(!this->shortcuts.isEmpty()) if(!shortcuts.isEmpty())
qCWarning(logQHotkey, "QHotkeyPrivate destroyed with registered shortcuts!"); qCWarning(logQHotkey) << "QHotkeyPrivate destroyed with registered shortcuts!";
if(qApp && qApp->eventDispatcher()) if(qApp && qApp->eventDispatcher())
qApp->eventDispatcher()->removeNativeEventFilter(this); qApp->eventDispatcher()->removeNativeEventFilter(this);
} }
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers) QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
{ {
Qt::ConnectionType conType = (QThread::currentThread() == this->thread() ? Qt::ConnectionType conType = (QThread::currentThread() == thread() ?
Qt::DirectConnection : Qt::DirectConnection :
Qt::BlockingQueuedConnection); Qt::BlockingQueuedConnection);
QHotkey::NativeShortcut res; QHotkey::NativeShortcut res;
@@ -167,10 +212,10 @@ QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::Keyb
bool QHotkeyPrivate::addShortcut(QHotkey *hotkey) bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
{ {
if(hotkey->registered) if(hotkey->_registered)
return false; return false;
Qt::ConnectionType conType = (QThread::currentThread() == this->thread() ? Qt::ConnectionType conType = (QThread::currentThread() == thread() ?
Qt::DirectConnection : Qt::DirectConnection :
Qt::BlockingQueuedConnection); Qt::BlockingQueuedConnection);
bool res = false; bool res = false;
@@ -187,10 +232,10 @@ bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey) bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)
{ {
if(!hotkey->registered) if(!hotkey->_registered)
return false; return false;
Qt::ConnectionType conType = (QThread::currentThread() == this->thread() ? Qt::ConnectionType conType = (QThread::currentThread() == thread() ?
Qt::DirectConnection : Qt::DirectConnection :
Qt::BlockingQueuedConnection); Qt::BlockingQueuedConnection);
bool res = false; bool res = false;
@@ -208,34 +253,96 @@ bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)
void QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut) void QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut)
{ {
QMetaMethod signal = QMetaMethod::fromSignal(&QHotkey::activated); QMetaMethod signal = QMetaMethod::fromSignal(&QHotkey::activated);
for(QHotkey *hkey : this->shortcuts.values(shortcut)) for(QHotkey *hkey : shortcuts.values(shortcut))
signal.invoke(hkey, Qt::QueuedConnection); signal.invoke(hkey, Qt::QueuedConnection);
} }
void QHotkeyPrivate::addMappingInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers, const QHotkey::NativeShortcut &nativeShortcut)
{
mapping.insert({keycode, modifiers}, nativeShortcut);
}
bool QHotkeyPrivate::addShortcutInvoked(QHotkey *hotkey) bool QHotkeyPrivate::addShortcutInvoked(QHotkey *hotkey)
{ {
QHotkey::NativeShortcut shortcut = hotkey->nativeShortcut; QHotkey::NativeShortcut shortcut = hotkey->_nativeShortcut;
if(!this->shortcuts.contains(shortcut)) { if(!shortcuts.contains(shortcut)) {
if(!this->registerShortcut(shortcut)) if(!registerShortcut(shortcut))
return false; return false;
} }
this->shortcuts.insert(shortcut, hotkey); shortcuts.insert(shortcut, hotkey);
hotkey->registered = true; hotkey->_registered = true;
return true; return true;
} }
bool QHotkeyPrivate::removeShortcutInvoked(QHotkey *hotkey) bool QHotkeyPrivate::removeShortcutInvoked(QHotkey *hotkey)
{ {
QHotkey::NativeShortcut shortcut = hotkey->nativeShortcut; QHotkey::NativeShortcut shortcut = hotkey->_nativeShortcut;
if(this->shortcuts.remove(shortcut, hotkey) == 0) if(shortcuts.remove(shortcut, hotkey) == 0)
return false; return false;
hotkey->registered = false; hotkey->_registered = false;
emit hotkey->registeredChanged(true); emit hotkey->registeredChanged(true);
if(this->shortcuts.count(shortcut) == 0) if(shortcuts.count(shortcut) == 0)
return this->unregisterShortcut(shortcut); return unregisterShortcut(shortcut);
else else
return true; return true;
} }
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
{
if(mapping.contains({keycode, modifiers}))
return mapping.value({keycode, modifiers});
bool ok1, ok2 = false;
auto k = nativeKeycode(keycode, ok1);
auto m = nativeModifiers(modifiers, ok2);
if(ok1 && ok2)
return {k, m};
else
return {};
}
QHotkey::NativeShortcut::NativeShortcut() :
key(),
modifier(),
valid(false)
{}
QHotkey::NativeShortcut::NativeShortcut(quint32 key, quint32 modifier) :
key(key),
modifier(modifier),
valid(true)
{}
bool QHotkey::NativeShortcut::isValid() const
{
return valid;
}
bool QHotkey::NativeShortcut::operator ==(const QHotkey::NativeShortcut &other) const
{
return (key == other.key) &&
(modifier == other.modifier) &&
valid == other.valid;
}
bool QHotkey::NativeShortcut::operator !=(const QHotkey::NativeShortcut &other) const
{
return (key != other.key) ||
(modifier != other.modifier) ||
valid != other.valid;
}
uint qHash(const QHotkey::NativeShortcut &key)
{
return qHash(key.key) ^ qHash(key.modifier);
}
uint qHash(const QHotkey::NativeShortcut &key, uint seed)
{
return qHash(key.key, seed) ^ qHash(key.modifier, seed);
}
+58 -11
View File
@@ -6,8 +6,18 @@
#include <QPair> #include <QPair>
#include <QLoggingCategory> #include <QLoggingCategory>
#ifdef QHOTKEY_LIB
#ifdef QHOTKEY_LIB_BUILD
#define QHOTKEY_SHARED_EXPORT Q_DECL_EXPORT
#else
#define QHOTKEY_SHARED_EXPORT Q_DECL_IMPORT
#endif
#else
#define QHOTKEY_SHARED_EXPORT
#endif
//! A class to define global, systemwide Hotkeys //! A class to define global, systemwide Hotkeys
class QHotkey : public QObject class QHOTKEY_SHARED_EXPORT QHotkey : public QObject
{ {
Q_OBJECT Q_OBJECT
friend class QHotkeyPrivate; friend class QHotkeyPrivate;
@@ -19,14 +29,40 @@ class QHotkey : public QObject
public: public:
//! Defines shortcut with native keycodes //! Defines shortcut with native keycodes
typedef QPair<quint32, quint32> NativeShortcut; class QHOTKEY_SHARED_EXPORT NativeShortcut {
public:
//! The native keycode
quint32 key;
//! The native modifiers
quint32 modifier;
//! Creates an invalid native shortcut
NativeShortcut();
//! Creates a valid native shortcut, with the given key and modifiers
NativeShortcut(quint32 key, quint32 modifier = 0);
//! Checks, whether this shortcut is valid or not
bool isValid() const;
//! Equality operator
bool operator ==(const NativeShortcut &other) const;
//! Inequality operator
bool operator !=(const NativeShortcut &other) const;
private:
bool valid;
};
static void addGlobalMapping(const QKeySequence &shortcut, const NativeShortcut &nativeShortcut);
//! Constructor //! Constructor
explicit QHotkey(QObject *parent = 0); explicit QHotkey(QObject *parent = Q_NULLPTR);
//! Constructs a hotkey with a shortcut and optionally registers it //! Constructs a hotkey with a shortcut and optionally registers it
explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = 0); explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = Q_NULLPTR);
//! Constructs a hotkey with a key and modifiers and optionally registers it //! Constructs a hotkey with a key and modifiers and optionally registers it
explicit QHotkey(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister = false, QObject *parent = 0); explicit QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false, QObject *parent = Q_NULLPTR);
//! Constructs a hotkey from a native shortcut and optionally registers it
explicit QHotkey(const NativeShortcut &shortcut, bool autoRegister = false, QObject *parent = Q_NULLPTR);
//! Destructor //! Destructor
~QHotkey(); ~QHotkey();
@@ -39,6 +75,9 @@ public:
//! READ-Accessor for QHotkey::shortcut - the modifiers only //! READ-Accessor for QHotkey::shortcut - the modifiers only
Qt::KeyboardModifiers modifiers() const; Qt::KeyboardModifiers modifiers() const;
//! Get the current native shortcut
NativeShortcut currentNativeShortcut() const;
public slots: public slots:
//! WRITE-Accessor for QHotkey::registered //! WRITE-Accessor for QHotkey::registered
bool setRegistered(bool registered); bool setRegistered(bool registered);
@@ -46,10 +85,13 @@ public slots:
//! WRITE-Accessor for QHotkey::shortcut //! WRITE-Accessor for QHotkey::shortcut
bool setShortcut(const QKeySequence &shortcut, bool autoRegister = false); bool setShortcut(const QKeySequence &shortcut, bool autoRegister = false);
//! WRITE-Accessor for QHotkey::shortcut //! WRITE-Accessor for QHotkey::shortcut
bool setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister = false); bool setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false);
//! RESET-Accessor for QHotkey::shortcut //! RESET-Accessor for QHotkey::shortcut
bool resetShortcut(); bool resetShortcut();
//! Set this hotkey to a native shortcut
bool setNativeShortcut(NativeShortcut nativeShortcut, bool autoRegister = false);
signals: signals:
//! Will be emitted if the shortcut is pressed //! Will be emitted if the shortcut is pressed
void activated(QPrivateSignal); void activated(QPrivateSignal);
@@ -58,13 +100,18 @@ signals:
void registeredChanged(bool registered); void registeredChanged(bool registered);
private: private:
Qt::Key key; Qt::Key _keyCode;
Qt::KeyboardModifiers mods; Qt::KeyboardModifiers _modifiers;
NativeShortcut nativeShortcut; NativeShortcut _nativeShortcut;
bool registered; bool _registered;
}; };
Q_DECLARE_LOGGING_CATEGORY(logQHotkey) uint QHOTKEY_SHARED_EXPORT qHash(const QHotkey::NativeShortcut &key);
uint QHOTKEY_SHARED_EXPORT qHash(const QHotkey::NativeShortcut &key, uint seed);
QHOTKEY_SHARED_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey)
Q_DECLARE_METATYPE(QHotkey::NativeShortcut)
#endif // QHOTKEY_H #endif // QHOTKEY_H
+1 -20
View File
@@ -1,20 +1 @@
CONFIG += C++11 message(The pri file has been moved one directory up! use that one instead)
HEADERS += $$PWD/qhotkey.h \
$$PWD/qhotkey_p.h
SOURCES += $$PWD/qhotkey.cpp
mac {
SOURCES += $$PWD/qhotkey_mac.cpp
LIBS += -framework Carbon
} else:win32 {
SOURCES += $$PWD/qhotkey_win.cpp
LIBS += -lUser32
} else:unix {
SOURCES += $$PWD/qhotkey_x11.cpp
QT += x11extras
LIBS += -lX11
}
INCLUDEPATH += $$PWD
+23 -14
View File
@@ -13,8 +13,8 @@ public:
protected: protected:
// QHotkeyPrivate interface // QHotkeyPrivate interface
quint32 nativeKeycode(Qt::Key keycode) Q_DECL_OVERRIDE; quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE; quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE; bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE; bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
@@ -35,9 +35,10 @@ bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *mes
return false; return false;
} }
quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode) quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode, bool &ok)
{ {
// Constants found in NSEvent.h from AppKit.framework // Constants found in NSEvent.h from AppKit.framework
ok = true;
switch (keycode) { switch (keycode) {
case Qt::Key_Return: case Qt::Key_Return:
return kVK_Return; return kVK_Return;
@@ -120,7 +121,8 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
case Qt::Key_Up: case Qt::Key_Up:
return kVK_UpArrow; return kVK_UpArrow;
default: default:
; ok = false;
break;
} }
UTF16Char ch = keycode; UTF16Char ch = keycode;
@@ -157,19 +159,25 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; long idx = keyToChar[k] & kUCKeyOutputGetIndexMask;
if (stateRec && idx < stateRec->keyStateRecordCount) { if (stateRec && idx < stateRec->keyStateRecordCount) {
UCKeyStateRecord* rec = reinterpret_cast<UCKeyStateRecord*>(data + stateRec->keyStateRecordOffsets[idx]); UCKeyStateRecord* rec = reinterpret_cast<UCKeyStateRecord*>(data + stateRec->keyStateRecordOffsets[idx]);
if (rec->stateZeroCharData == ch) return k; if (rec->stateZeroCharData == ch) {
ok = true;
return k;
}
} }
} }
else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) { else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) {
if (keyToChar[k] == ch) return k; if (keyToChar[k] == ch) {
ok = true;
return k;
}
} }
} // for k }
} // for j }
} // for i }
return 0; return 0;
} }
quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers) quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
{ {
quint32 nMods = 0; quint32 nMods = 0;
if (modifiers & Qt::ShiftModifier) if (modifiers & Qt::ShiftModifier)
@@ -182,6 +190,7 @@ quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers)
nMods |= controlKey; nMods |= controlKey;
if (modifiers & Qt::KeypadModifier) if (modifiers & Qt::KeypadModifier)
nMods |= kEventKeyModifierNumLockMask; nMods |= kEventKeyModifierNumLockMask;
ok = true;
return nMods; return nMods;
} }
@@ -196,12 +205,12 @@ bool QHotkeyPrivateMac::registerShortcut(QHotkey::NativeShortcut shortcut)
} }
EventHotKeyID hkeyID; EventHotKeyID hkeyID;
hkeyID.signature = shortcut.first; hkeyID.signature = shortcut.key;
hkeyID.id = shortcut.second; hkeyID.id = shortcut.modifier;
EventHotKeyRef eventRef = 0; EventHotKeyRef eventRef = 0;
OSStatus status = RegisterEventHotKey(shortcut.first, OSStatus status = RegisterEventHotKey(shortcut.key,
shortcut.second, shortcut.modifier,
hkeyID, hkeyID,
GetApplicationEventTarget(), GetApplicationEventTarget(),
0, 0,
+11 -17
View File
@@ -7,7 +7,7 @@
#include <QMutex> #include <QMutex>
#include <QGlobalStatic> #include <QGlobalStatic>
class QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter
{ {
Q_OBJECT Q_OBJECT
@@ -16,7 +16,6 @@ public:
~QHotkeyPrivate(); ~QHotkeyPrivate();
static QHotkeyPrivate *instance(); static QHotkeyPrivate *instance();
static inline bool testValid(QHotkey::NativeShortcut nativeShortcut);
QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers); QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
@@ -26,19 +25,20 @@ public:
protected: protected:
void activateShortcut(QHotkey::NativeShortcut shortcut); void activateShortcut(QHotkey::NativeShortcut shortcut);
virtual quint32 nativeKeycode(Qt::Key keycode) = 0;//platform implement virtual quint32 nativeKeycode(Qt::Key keycode, bool &ok) = 0;//platform implement
virtual quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) = 0;//platform implement virtual quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) = 0;//platform implement
virtual bool registerShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement virtual bool registerShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement
virtual bool unregisterShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement virtual bool unregisterShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement
private:/*functions*/ private:
QHash<QPair<Qt::Key, Qt::KeyboardModifiers>, QHotkey::NativeShortcut> mapping;
QMultiHash<QHotkey::NativeShortcut, QHotkey*> shortcuts;
Q_INVOKABLE void addMappingInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers, const QHotkey::NativeShortcut &nativeShortcut);
Q_INVOKABLE bool addShortcutInvoked(QHotkey *hotkey); Q_INVOKABLE bool addShortcutInvoked(QHotkey *hotkey);
Q_INVOKABLE bool removeShortcutInvoked(QHotkey *hotkey); Q_INVOKABLE bool removeShortcutInvoked(QHotkey *hotkey);
Q_INVOKABLE inline QHotkey::NativeShortcut nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers); Q_INVOKABLE QHotkey::NativeShortcut nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
private:
QMultiHash<QHotkey::NativeShortcut, QHotkey*> shortcuts;
}; };
#define NATIVE_INSTANCE(ClassName) \ #define NATIVE_INSTANCE(ClassName) \
@@ -49,13 +49,7 @@ private:
return hotkeyPrivate;\ return hotkeyPrivate;\
} }
inline bool QHotkeyPrivate::testValid(QHotkey::NativeShortcut nativeShortcut) Q_DECLARE_METATYPE(Qt::Key)
{ Q_DECLARE_METATYPE(Qt::KeyboardModifiers)
return (nativeShortcut.first != 0);
}
inline QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers) {
return {this->nativeKeycode(keycode), this->nativeModifiers(modifiers)};
}
#endif // QHOTKEY_P_H #endif // QHOTKEY_P_H
+15 -8
View File
@@ -3,7 +3,7 @@
#include <qt_windows.h> #include <qt_windows.h>
#include <QDebug> #include <QDebug>
#define HKEY_ID(nativeShortcut) (((nativeShortcut.first ^ (nativeShortcut.second << 8)) & 0x0FFF) | 0x7000) #define HKEY_ID(nativeShortcut) (((nativeShortcut.key ^ (nativeShortcut.modifier << 8)) & 0x0FFF) | 0x7000)
class QHotkeyPrivateWin : public QHotkeyPrivate class QHotkeyPrivateWin : public QHotkeyPrivate
{ {
@@ -13,8 +13,8 @@ public:
protected: protected:
// QHotkeyPrivate interface // QHotkeyPrivate interface
quint32 nativeKeycode(Qt::Key keycode) Q_DECL_OVERRIDE; quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE; quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE; bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE; bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
@@ -35,8 +35,9 @@ bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *mes
return false; return false;
} }
quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode) quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok)
{ {
ok = true;
if(keycode <= 0xFFFF) {//Try to obtain the key from it's "character" if(keycode <= 0xFFFF) {//Try to obtain the key from it's "character"
const SHORT vKey = VkKeyScanW(keycode); const SHORT vKey = VkKeyScanW(keycode);
if(vKey > -1) if(vKey > -1)
@@ -201,11 +202,16 @@ quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode)
return VK_OEM_FJ_TOUROKU; return VK_OEM_FJ_TOUROKU;
default: default:
return 0; if(keycode <= 0xFFFF)
return (byte)keycode;
else {
ok = false;
return 0;
}
} }
} }
quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers) quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
{ {
quint32 nMods = 0; quint32 nMods = 0;
if (modifiers & Qt::ShiftModifier) if (modifiers & Qt::ShiftModifier)
@@ -216,6 +222,7 @@ quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers)
nMods |= MOD_ALT; nMods |= MOD_ALT;
if (modifiers & Qt::MetaModifier) if (modifiers & Qt::MetaModifier)
nMods |= MOD_WIN; nMods |= MOD_WIN;
ok = true;
return nMods; return nMods;
} }
@@ -223,8 +230,8 @@ bool QHotkeyPrivateWin::registerShortcut(QHotkey::NativeShortcut shortcut)
{ {
BOOL ok = RegisterHotKey(NULL, BOOL ok = RegisterHotKey(NULL,
HKEY_ID(shortcut), HKEY_ID(shortcut),
shortcut.second, shortcut.modifier,
shortcut.first); shortcut.key);
if(ok) if(ok)
return true; return true;
else { else {
+141 -102
View File
@@ -6,38 +6,44 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
//compability to pre Qt 5.8
#ifndef Q_FALLTHROUGH
#define Q_FALLTHROUGH() (void)0
#endif
class QHotkeyPrivateX11 : public QHotkeyPrivate class QHotkeyPrivateX11 : public QHotkeyPrivate
{ {
public: public:
// QAbstractNativeEventFilter interface // QAbstractNativeEventFilter interface
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
protected: protected:
// QHotkeyPrivate interface // QHotkeyPrivate interface
quint32 nativeKeycode(Qt::Key keycode) Q_DECL_OVERRIDE; quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE; quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE; QString getX11String(Qt::Key keycode);
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE; bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
private: private:
static const QVector<quint32> specialModifiers; static const QVector<quint32> specialModifiers;
static const quint32 validModsMask; static const quint32 validModsMask;
static QString formatX11Error(Display *display, int errorCode); static QString formatX11Error(Display *display, int errorCode);
class HotkeyErrorHandler { class HotkeyErrorHandler {
public: public:
HotkeyErrorHandler(); HotkeyErrorHandler();
~HotkeyErrorHandler(); ~HotkeyErrorHandler();
static bool hasError; static bool hasError;
static QString errorString; static QString errorString;
private: private:
XErrorHandler prevHandler; XErrorHandler prevHandler;
static int handleError(Display *display, XErrorEvent *error); static int handleError(Display *display, XErrorEvent *error);
}; };
}; };
NATIVE_INSTANCE(QHotkeyPrivateX11) NATIVE_INSTANCE(QHotkeyPrivateX11)
@@ -46,104 +52,133 @@ const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1M
bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, long *result) bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{ {
Q_UNUSED(eventType); Q_UNUSED(eventType);
Q_UNUSED(result); Q_UNUSED(result);
xcb_generic_event_t *genericEvent = static_cast<xcb_generic_event_t *>(message); xcb_generic_event_t *genericEvent = static_cast<xcb_generic_event_t *>(message);
if (genericEvent->response_type == XCB_KEY_PRESS) { if (genericEvent->response_type == XCB_KEY_PRESS) {
xcb_key_press_event_t *keyEvent = static_cast<xcb_key_press_event_t *>(message); xcb_key_press_event_t *keyEvent = static_cast<xcb_key_press_event_t *>(message);
this->activateShortcut({keyEvent->detail, keyEvent->state & QHotkeyPrivateX11::validModsMask}); this->activateShortcut({keyEvent->detail, keyEvent->state & QHotkeyPrivateX11::validModsMask});
} }
return false; return false;
} }
quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode) QString QHotkeyPrivateX11::getX11String(Qt::Key keycode)
{ {
KeySym keysym = XStringToKeysym(QKeySequence(keycode).toString(QKeySequence::NativeText).toLatin1().constData()); switch(keycode){
if (keysym == NoSymbol) {
//not found -> just use the key
if(keycode <= 0xFFFF)
keysym = keycode;
else
return 0;
}
Display *display = QX11Info::display(); case Qt::Key_MediaLast :
if(display) case Qt::Key_MediaPrevious :
return XKeysymToKeycode(QX11Info::display(), keysym); return "XF86AudioPrev";
else case Qt::Key_MediaNext :
return 0; return "XF86AudioNext";
case Qt::Key_MediaPause :
case Qt::Key_MediaPlay :
case Qt::Key_MediaTogglePlayPause :
return "XF86AudioPlay";
case Qt::Key_MediaRecord :
return "XF86AudioRecord";
case Qt::Key_MediaStop :
return "XF86AudioStop";
default :
return QKeySequence(keycode).toString(QKeySequence::NativeText);
}
} }
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers) quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode, bool &ok)
{ {
quint32 nMods = 0; QString keyString = getX11String(keycode);
if (modifiers & Qt::ShiftModifier)
nMods |= ShiftMask; KeySym keysym = XStringToKeysym(keyString.toLatin1().constData());
if (modifiers & Qt::ControlModifier) if (keysym == NoSymbol) {
nMods |= ControlMask; //not found -> just use the key
if (modifiers & Qt::AltModifier) if(keycode <= 0xFFFF)
nMods |= Mod1Mask; keysym = keycode;
if (modifiers & Qt::MetaModifier) else
nMods |= Mod4Mask; return 0;
return nMods; }
Display *display = QX11Info::display();
if(display) {
auto res = XKeysymToKeycode(QX11Info::display(), keysym);
if(res != 0)
ok = true;
return res;
} else
return 0;
}
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
{
quint32 nMods = 0;
if (modifiers & Qt::ShiftModifier)
nMods |= ShiftMask;
if (modifiers & Qt::ControlModifier)
nMods |= ControlMask;
if (modifiers & Qt::AltModifier)
nMods |= Mod1Mask;
if (modifiers & Qt::MetaModifier)
nMods |= Mod4Mask;
ok = true;
return nMods;
} }
bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut) bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
{ {
Display *display = QX11Info::display(); Display *display = QX11Info::display();
if(!display) if(!display)
return false; return false;
HotkeyErrorHandler errorHandler; HotkeyErrorHandler errorHandler;
for(quint32 specialMod : QHotkeyPrivateX11::specialModifiers) { for(quint32 specialMod : QHotkeyPrivateX11::specialModifiers) {
XGrabKey(display, XGrabKey(display,
shortcut.first, shortcut.key,
shortcut.second | specialMod, shortcut.modifier | specialMod,
DefaultRootWindow(display), DefaultRootWindow(display),
True, True,
GrabModeAsync, GrabModeAsync,
GrabModeAsync); GrabModeAsync);
} }
XSync(display, False);
if(errorHandler.hasError) { if(errorHandler.hasError) {
qCWarning(logQHotkey) << "[QHotkey] Failed to register hotkey. Error:" qCWarning(logQHotkey) << "Failed to register hotkey. Error:"
<< qPrintable(errorHandler.errorString); << qPrintable(errorHandler.errorString);
this->unregisterShortcut(shortcut); this->unregisterShortcut(shortcut);
return false; return false;
} else } else
return true; return true;
} }
bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut) bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
{ {
Display *display = QX11Info::display(); Display *display = QX11Info::display();
if(!display) if(!display)
return false; return false;
HotkeyErrorHandler errorHandler; HotkeyErrorHandler errorHandler;
for(quint32 specialMod : QHotkeyPrivateX11::specialModifiers) { for(quint32 specialMod : QHotkeyPrivateX11::specialModifiers) {
XUngrabKey(display, XUngrabKey(display,
shortcut.first, shortcut.key,
shortcut.second | specialMod, shortcut.modifier | specialMod,
DefaultRootWindow(display)); DefaultRootWindow(display));
} }
XSync(display, False);
if(errorHandler.hasError) { if(errorHandler.hasError) {
qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:" qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:"
<< qPrintable(errorHandler.errorString); << qPrintable(errorHandler.errorString);
this->unregisterShortcut(shortcut); return false;
return false; } else
} else return true;
return true;
} }
QString QHotkeyPrivateX11::formatX11Error(Display *display, int errorCode) QString QHotkeyPrivateX11::formatX11Error(Display *display, int errorCode)
{ {
char errStr[256]; char errStr[256];
XGetErrorText(display, errorCode, errStr, 256); XGetErrorText(display, errorCode, errStr, 256);
return QString::fromLatin1(errStr); return QString::fromLatin1(errStr);
} }
@@ -155,27 +190,31 @@ QString QHotkeyPrivateX11::HotkeyErrorHandler::errorString;
QHotkeyPrivateX11::HotkeyErrorHandler::HotkeyErrorHandler() QHotkeyPrivateX11::HotkeyErrorHandler::HotkeyErrorHandler()
{ {
this->prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError); prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError);
} }
QHotkeyPrivateX11::HotkeyErrorHandler::~HotkeyErrorHandler() QHotkeyPrivateX11::HotkeyErrorHandler::~HotkeyErrorHandler()
{ {
XSetErrorHandler(this->prevHandler); XSetErrorHandler(prevHandler);
hasError = false;
errorString.clear();
} }
int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorEvent *error) int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorEvent *error)
{ {
switch (error->error_code) { switch (error->error_code) {
case BadAccess: case BadAccess:
case BadValue: case BadValue:
case BadWindow: case BadWindow:
if (error->request_code == 33 || //grab key if (error->request_code == 33 || //grab key
error->request_code == 34) {// ungrab key error->request_code == 34) {// ungrab key
HotkeyErrorHandler::hasError = true; hasError = true;
HotkeyErrorHandler::errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code); errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code);
return 1; return 1;
} }
default: Q_FALLTHROUGH();
return 0; // fall through
} default:
return 0;
}
} }
+34 -16
View File
@@ -4,15 +4,31 @@ A global shortcut/hotkey for Desktop Qt-Applications.
The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka shortcuts that work everywhere, independent of the application state. This means your application can be active, inactive, minimized or not visible at all and still receive the shortcuts. The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka shortcuts that work everywhere, independent of the application state. This means your application can be active, inactive, minimized or not visible at all and still receive the shortcuts.
## Features ## Features
- Works on Windows, Mac and X11 - Works on Windows, Mac and X11
- Easy to use, can use `QKeySequence` for easy shortcut input - Easy to use, can use `QKeySequence` for easy shortcut input
- Supports almost all common keys (Depends on OS & Keyboard-Layout) - Supports almost all common keys (Depends on OS & Keyboard-Layout)
- Allows direct input of Key/Modifier-Combinations - Allows direct input of Key/Modifier-Combinations
- Supports multiple QHotkey-instances for the same shortcut (with optimisations) - Supports multiple QHotkey-instances for the same shortcut (with optimisations)
- Thread-Safe - Can be used on all threads (See section Thread safety) - Thread-Safe - Can be used on all threads (See section Thread safety)
- Allows usage of native keycodes and modifiers, if needed
**Note:** For now Wayland is not supported, as it is simply not possible to register a global shortcut with wayland. For more details, or possible Ideas on how to get Hotkeys working on wayland, see [Issue #14](https://github.com/Skycoder42/QHotkey/issues/14).
## Installation
The package is providet as qpm package, [`de.skycoder42.qhotkey`](https://www.qpm.io/packages/de.skycoder42.qhotkey/index.html). To install:
1. Install qpm (See [GitHub - Installing](https://github.com/Cutehacks/qpm/blob/master/README.md#installing), for **windows** see below)
2. In your projects root directory, run `qpm install de.skycoder42.qhotkey`
3. Include qpm to your project by adding `include(vendor/vendor.pri)` to your `.pro` file
Check their [GitHub - Usage for App Developers](https://github.com/Cutehacks/qpm/blob/master/README.md#usage-for-app-developers) to learn more about qpm.
**Important for Windows users:** QPM Version *0.10.0* (the one you can download on the website) is currently broken on windows! It's already fixed in master, but not released yet. Until a newer versions gets released, you can download the latest dev build from here:
- https://storage.googleapis.com/www.qpm.io/download/latest/windows_amd64/qpm.exe
- https://storage.googleapis.com/www.qpm.io/download/latest/windows_386/qpm.exe
## Usage ## Usage
Just copy the `./QHotkey` folder into you application and add the line `include(./QHotkey/qhotkey.pri)` to your .pro-file. This way all files and required libraries will automatically be added. Use `#include <QHotkey>` to access the class. The general usage is to create QHotkey instances for specific hotkeys, register them and then simply connect to the signal emitted once the hotkey is pressed.
### Example ### Example
The following example shows a simple application that will run without a window in the background until you press the key-combination <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Q</kbd> (<kbd>⌘</kbd>+<kbd>⌥</kbd>+<kbd>Q</kbd> on Mac). This will quit the application. The debug output will tell if the hotkey was successfully registered and that it was pressed. The following example shows a simple application that will run without a window in the background until you press the key-combination <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Q</kbd> (<kbd>⌘</kbd>+<kbd>⌥</kbd>+<kbd>Q</kbd> on Mac). This will quit the application. The debug output will tell if the hotkey was successfully registered and that it was pressed.
@@ -40,10 +56,11 @@ int main(int argc, char *argv[])
**Note:** You need the .pri include for this to work. **Note:** You need the .pri include for this to work.
### Testing ### Testing
By running the example in `./HotkeyTest` you can test out the QHotkey class. There are 3 sections: By running the example in `./HotkeyTest` you can test out the QHotkey class. There are 4 sections:
- **Playground:** You can enter some sequences here and try it out with different key combinations. - **Playground:** You can enter some sequences here and try it out with different key combinations.
- **Testings:** A list of selected hotkeys. Activate it and try out which ones work for you (*Hint:* Depending on OS and keyboard layout, it's very possible that a few don't work). - **Testings:** A list of selected hotkeys. Activate it and try out which ones work for you (*Hint:* Depending on OS and keyboard layout, it's very possible that a few don't work).
- **Threading:** Activate the checkbox to move 2 Hotkeys of the playground to seperate threads. It should work without a difference. - **Threading:** Activate the checkbox to move 2 Hotkeys of the playground to seperate threads. It should work without a difference.
- **Native Shortcut**: Allows you to try out the direct usage of native shortcuts
### Logging ### Logging
By default, QHotkey prints some warning messages if something goes wrong (For example, a key that cannot be translated). All messages of QHotkey are grouped into the [QLoggingCategory](https://doc.qt.io/qt-5/qloggingcategory.html) `"QHotkey"`. If you want to simply disable the logging, call the folling function somewhere in your code: By default, QHotkey prints some warning messages if something goes wrong (For example, a key that cannot be translated). All messages of QHotkey are grouped into the [QLoggingCategory](https://doc.qt.io/qt-5/qloggingcategory.html) `"QHotkey"`. If you want to simply disable the logging, call the folling function somewhere in your code:
@@ -60,18 +77,19 @@ However, this singleton instance only runs on the main thread. (One reason is th
For you this means: QHotkey instances on other threads than the main thread may take a little longer to register/unregister/translate hotkeys, because they have to wait for the main thread to do this for them. **Important:** there is however, one additional limitation that comes with that feature: QHotkey instances on other threads but the main thread *must* be unregistered or destroyed *before* the main eventloop ends. Otherwise, your application will hangup on destruction of the hotkey. This limitation does not apply for instances on the main thread. Furthermore, the same happens if you change the shortcut or register/unregister before the loop started, until it actually starts. For you this means: QHotkey instances on other threads than the main thread may take a little longer to register/unregister/translate hotkeys, because they have to wait for the main thread to do this for them. **Important:** there is however, one additional limitation that comes with that feature: QHotkey instances on other threads but the main thread *must* be unregistered or destroyed *before* the main eventloop ends. Otherwise, your application will hangup on destruction of the hotkey. This limitation does not apply for instances on the main thread. Furthermore, the same happens if you change the shortcut or register/unregister before the loop started, until it actually starts.
## Documentation ## Documentation
The documentation is available within the releases and on [github pages](https://skycoder42.github.io/QHotkey/). The documentation is available as release and on [github pages](https://skycoder42.github.io/QHotkey/).
The documentation was created using [doxygen](http://www.doxygen.org). It includes an HTML-documentation and Qt-Help files that can be included into QtCreator (QtAssistant) to show F1-Help (See [Adding External Documentation](https://doc.qt.io/qtcreator/creator-help.html#adding-external-documentation) for more details). The documentation was created using [doxygen](http://www.doxygen.org). It includes an HTML-documentation and Qt-Help files that can be included into QtCreator (QtAssistant) to show F1-Help (See [Adding External Documentation](https://doc.qt.io/qtcreator/creator-help.html#adding-external-documentation) for more details).
## Technical ## Technical
### Requirements ### Requirements
- I built it with Qt 5.5.1, but may work with earlier versions, too - I built it with Qt 5.7, but may work with earlier versions, too
- At least the QtGui-Module (a QGuiApplication). Hotkeys on console based applications are not supported. (By the operating systems) - At least the QtGui-Module (a QGuiApplication). Hotkeys on console based applications are not supported (By the operating systems). You can however create a gui application without any visible window.
- C++11 - C++11
### Known Limitations ### Known Limitations
- Only single key/modifier combinations are possible. If using QKeySequence, only the first key+modifier of the sequence will be used. - Only single key/modifier combinations are possible. If using QKeySequence, only the first key+modifier of the sequence will be used.
- Qt::Key makes no difference between normal numbers and the Numpad numbers. Most keyboards however require this. Thus, you can't register shortcuts for the numpad. - Qt::Key makes no difference between normal numbers and the Numpad numbers. Most keyboards however require this. Thus, you can't register shortcuts for the numpad, unless you use a native shortcut.
- Supports not all keys, but most of the common ones. There are differences between platforms and it depends on the Keyboard-Layout. "Delete", for example, works on windows and mac, but not on X11 (At least on my test machines). I tried to use OS-Functions where possible, but since the Qt::Key values need to be converted into native keys, there are some limitations. - Supports not all keys, but most of the common ones. There are differences between platforms and it depends on the Keyboard-Layout. "Delete", for example, works on windows and mac, but not on X11 (At least on my test machines). I tried to use OS-Functions where possible, but since the Qt::Key values need to be converted into native keys, there are some limitations. I can use need such a key, try using the native shortcut.
- The registered keys will be "taken" by QHotkey. This means after a hotkey was cosumend by your application, it will not be sent to the active application. This is done this way by the operating systems and cannot be changed. - The registered keys will be "taken" by QHotkey. This means after a hotkey was cosumend by your application, it will not be sent to the active application. This is done this way by the operating systems and cannot be changed.
- If you get a `QHotkey: Failed to register hotkey. Error: BadAccess (attempt to access private resource denied)` error on X11, this means you are trying to register a hotkey that is private to X11. Those keys simply cannot be registered using the normal API
+50 -23
View File
@@ -60,29 +60,7 @@ it does. This does not happen if used from the main thread.
} }
} }
@sa QHotkey::registered, QHotkey::isKeyCaptured @sa QHotkey::registered, QHotkey::isKeyCaptured, QHotkey::currentNativeShortcut, QHotkey::setNativeShortcut
*/
/*!
@typedef QHotkey::NativeShortcut
<table>
<tr>
<th>Member</th>
<th>Details</th>
</tr>
<tr>
<td>first</td>
<td>The keycode of the key to be pressed</td>
</tr>
<tr>
<td>second</td>
<td>The modifiers that have to be pressed together with the key</td>
</tr>
</table>
The NativeShortcut is used internally only and holds the native keycode and modifiers, after they have been translated
from Qt::Key and Qt::Modifiers into the native ones.
*/ */
/*! /*!
@@ -95,6 +73,7 @@ from Qt::Key and Qt::Modifiers into the native ones.
@povElem{QHotkey::QHotkey(QObject *)} @povElem{QHotkey::QHotkey(QObject *)}
@ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)} @ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)}
@ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)} @ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)}
@ovElem{QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)}
} }
*/ */
@@ -110,6 +89,7 @@ from Qt::Key and Qt::Modifiers into the native ones.
@povElem{QHotkey::QHotkey(QObject *)} @povElem{QHotkey::QHotkey(QObject *)}
@ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)} @ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)}
@ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)} @ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)}
@ovElem{QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)}
} }
@sa QHotkey::shortcut, QHotkey::registered @sa QHotkey::shortcut, QHotkey::registered
@@ -128,11 +108,32 @@ from Qt::Key and Qt::Modifiers into the native ones.
@povElem{QHotkey::QHotkey(QObject *)} @povElem{QHotkey::QHotkey(QObject *)}
@ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)} @ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)}
@ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)} @ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)}
@ovElem{QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)}
} }
@sa QHotkey::shortcut, QHotkey::registered @sa QHotkey::shortcut, QHotkey::registered
*/ */
/*!
@fn QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)
@overload
@param parent The parent object
@param shortcut The native shortcut this hotkey should be registered for
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
@note Please check QHotkey::setNativeShortcut for important hints!
@overloads{
@povElem{QHotkey::QHotkey(QObject *)}
@ovElem{QHotkey::QHotkey(const QKeySequence &, bool, QObject *)}
@ovElem{QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)}
@ovElem{QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)}
}
@sa QHotkey::setNativeShortcut, QHotkey::registered
*/
/*! /*!
@fn QHotkey::~QHotkey @fn QHotkey::~QHotkey
@@ -144,6 +145,20 @@ Otherwise your application will hang up.
@sa QHotkey::registered @sa QHotkey::registered
*/ */
/*!
@fn QHotkey::setNativeShortcut
@param nativeShortcut The native shortcut to be set
@param autoRegister Specifies, whether the hotkey should be automatically registered, or not
@returns `true`, if the shortcut could be successfully set/registered, `false` if not
@warning Setting the native shortcut will cause the shortcut(), keyCode() and modifiers() functions
to return "invalid values", i.e. if a hotkey has an explicitly set native shortcut, it will not be able
to get the Qt values for them.
@sa QHotkey::currentNativeShortcut, QHotkey::shortcut, QHotkey::registered
*/
/*! /*!
@fn QHotkey::activated @fn QHotkey::activated
@@ -152,3 +167,15 @@ from the thread this instance lives on.
@note This is a private signal. It can be used in signal connections but cannot be emitted by the user. @note This is a private signal. It can be used in signal connections but cannot be emitted by the user.
*/ */
/*!
@class QHotkey::NativeShortcut
The NativeShortcut holds the native keycode and modifiers, after they have been translated
from Qt::Key and Qt::Modifiers into the native ones.
It can be used to find out how a current hotkey is mapped to the system, or to explicitly create
a shortcut from those native values
@sa QHotkey::setNativeShortcut
*/
+52 -43
View File
@@ -1,4 +1,4 @@
# Doxyfile 1.8.11 # Doxyfile 1.8.12
# This file describes the settings to be used by the documentation system # This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project. # doxygen (www.doxygen.org) for a project.
@@ -38,7 +38,7 @@ PROJECT_NAME = QHotkey
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 1.0.0 PROJECT_NUMBER = 1.1.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a
@@ -251,11 +251,11 @@ ALIASES = "accessors{1}=<table><tr><th colspan= 2>Accessors</th><
userAc{1}=<tr><td><b>USER</b></td><td>\1</td></tr> \ userAc{1}=<tr><td><b>USER</b></td><td>\1</td></tr> \
"constantAc=<tr><td colspan= 2><b>CONSTANT</b></td></tr>" \ "constantAc=<tr><td colspan= 2><b>CONSTANT</b></td></tr>" \
"finalAc=<tr><td colspan= 2><b>FINAL</b></td></tr>" \ "finalAc=<tr><td colspan= 2><b>FINAL</b></td></tr>" \
"default{1}=<b>Default:</b> \1 <br>" \ "default{1}=<b>Default:</b> \1 <br>" \
overloads{1}=<b>Overloads:</b><ul>\1</ul> \ overloads{1}=<b>Overloads:</b><ul>\1</ul> \
ovElem{1}=<li>\1</li> \ ovElem{1}=<li>\1</li> \
"overload=<i>This is an overloaded function.</i>" \ "overload=<i>This is an overloaded function.</i>" \
"povElem{1}=<li>\1 <i>(primary, check for more details)</i></li>" "povElem{1}=<li>\1 <i>(primary, check for more details)</i></li>"
# This tag can be used to specify a number of word-keyword mappings (TCL only). # This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class" # A mapping has the form "name=value". For example adding "class=itcl::class"
@@ -320,6 +320,15 @@ EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES MARKDOWN_SUPPORT = YES
# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
# to that level are automatically included in the table of contents, even if
# they do not have an id attribute.
# Note: This feature currently applies only to Markdown headings.
# Minimum value: 0, maximum value: 99, default value: 0.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 0
# When enabled doxygen tries to link words that correspond to documented # When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can # classes, or namespaces to their corresponding documentation. Such a link can
# be prevented in individual cases by putting a % sign in front of the word or # be prevented in individual cases by putting a % sign in front of the word or
@@ -822,8 +831,8 @@ INPUT_ENCODING = UTF-8
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.cc \ *.cc \
@@ -912,7 +921,12 @@ EXCLUDE_PATTERNS = moc_* \
# Note that the wildcards are matched against the file with absolute path, so to # Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/* # exclude all test directories use the pattern */test/*
EXCLUDE_SYMBOLS = EXCLUDE_SYMBOLS = QBasicAtomicInteger \
QBasicAtomicPointer \
QFutureWatcherBase \
QListSpecialMethods \
QPaintEngineEx \
QQmlExtensionInterface
# The EXAMPLE_PATH tag can be used to specify one or more files or directories # The EXAMPLE_PATH tag can be used to specify one or more files or directories
# that contain example code fragments that are included (see the \include # that contain example code fragments that are included (see the \include
@@ -1403,7 +1417,7 @@ QCH_FILE = QHotkeyHelp.qch
# The default value is: org.doxygen.Project. # The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
QHP_NAMESPACE = com.github.Skycoder42.QHotkey QHP_NAMESPACE = com.Skycoder42.QHotkey.110
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual # Help Project output. For more information please see Qt Help Project / Virtual
@@ -1442,7 +1456,7 @@ QHP_SECT_FILTER_ATTRS =
# generated .qhp file. # generated .qhp file.
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
QHG_LOCATION = C:/Qt/5.5/msvc2013_64/bin/qhelpgenerator.exe QHG_LOCATION = C:/Qt/5.7/msvc2015_64/bin/qhelpgenerator.exe
# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
# generated, together with the HTML files, they form an Eclipse help plugin. To # generated, together with the HTML files, they form an Eclipse help plugin. To
@@ -2093,7 +2107,7 @@ SEARCH_INCLUDES = YES
# preprocessor. # preprocessor.
# This tag requires that the tag SEARCH_INCLUDES is set to YES. # This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH = C:/Qt/5.5/msvc2013_64/include INCLUDE_PATH = C:/Qt/5.7/msvc2015_64/include
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the # patterns (like *.h and *.hpp) to filter out the header-files in the
@@ -2151,36 +2165,31 @@ SKIP_FUNCTION_MACROS = YES
# the path). If a tag file is not located in the directory in which doxygen is # the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here. # run, you must also specify the path to the tagfile here.
TAGFILES = C:/Qt/Docs/Qt-5.5/qtwebengine/qtwebengine.tags=http://doc.qt.io/qt-5 \ TAGFILES = C:/Qt/Docs/Qt-5.7/qtwebengine/qtwebengine.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtgraphicaleffects/qtgraphicaleffects.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtgraphicaleffects/qtgraphicaleffects.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qt3dcollision/qt3dcollision.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtwebchannel/qtwebchannel.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qt3dlogic/qt3dlogic.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtwebsockets/qtwebsockets.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qt3dcore/qt3dcore.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtbluetooth/qtbluetooth.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qt3drenderer/qt3drenderer.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtnfc/qtnfc.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtwebchannel/qtwebchannel.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtsensors/qtsensors.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtwebsockets/qtwebsockets.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtlocation/qtlocation.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtbluetooth/qtbluetooth.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtpositioning/qtpositioning.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtnfc/qtnfc.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/activeqt/activeqt.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtsensors/qtsensors.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtquickcontrols/qtquickcontrols.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtlocation/qtlocation.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtqml/qtqml.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtpositioning/qtpositioning.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtquick/qtquick.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/activeqt/activeqt.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtxmlpatterns/qtxmlpatterns.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtquickcontrols/qtquickcontrols.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtsvg/qtsvg.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtqml/qtqml.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qdoc/qdoc.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtquick/qtquick.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtprintsupport/qtprintsupport.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtxmlpatterns/qtxmlpatterns.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtconcurrent/qtconcurrent.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtsvg/qtsvg.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtgui/qtgui.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qdoc/qdoc.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qttestlib/qttestlib.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtprintsupport/qtprintsupport.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtwidgets/qtwidgets.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtconcurrent/qtconcurrent.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtcore/qtcore.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtgui/qtgui.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtnetwork/qtnetwork.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qttestlib/qttestlib.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtsql/qtsql.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtwidgets/qtwidgets.tags=http://doc.qt.io/qt-5 \ C:/Qt/Docs/Qt-5.7/qtxml/qtxml.tags=http://doc.qt.io/qt-5
C:/Qt/Docs/Qt-5.5/qtcore/qtcore.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtnetwork/qtnetwork.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtsql/qtsql.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtxml/qtxml.tags=http://doc.qt.io/qt-5 \
C:/Qt/Docs/Qt-5.5/qtwebenginewidgets/qtwebenginewidgets.tags=http://doc.qt.io/qt-5
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a # When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to # tag file that is based on the input files it reads. See section "Linking to
+6
View File
@@ -0,0 +1,6 @@
mac: LIBS += -framework Carbon
else:win32: LIBS += -luser32
else:unix {
QT += x11extras
LIBS += -lX11
}
+17
View File
@@ -0,0 +1,17 @@
CONFIG += C++11
PUBLIC_HEADERS += $$PWD/QHotkey/qhotkey.h \
$$PWD/QHotkey/QHotkey
HEADERS += $$PUBLIC_HEADERS \
$$PWD/QHotkey/qhotkey_p.h
SOURCES += $$PWD/QHotkey/qhotkey.cpp
mac: SOURCES += $$PWD/QHotkey/qhotkey_mac.cpp
else:win32: SOURCES += $$PWD/QHotkey/qhotkey_win.cpp
else:unix: SOURCES += $$PWD/QHotkey/qhotkey_x11.cpp
INCLUDEPATH += $$PWD/QHotkey
include($$PWD/qhotkey.prc)
+22
View File
@@ -0,0 +1,22 @@
{
"author": {
"email": "skycoder42.de@gmx.de",
"name": "Skycoder"
},
"dependencies": [
],
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
"license": "BSD_3_CLAUSE",
"name": "de.skycoder42.qhotkey",
"pri_filename": "qhotkey.pri",
"repository": {
"type": "GITHUB",
"url": "https://github.com/Skycoder42/QHotkey.git"
},
"version": {
"fingerprint": "",
"label": "1.2.2",
"revision": ""
},
"webpage": "https://github.com/Skycoder42/QHotkey"
}
+28
View File
@@ -0,0 +1,28 @@
{
"dependencies": [
],
"license": {
"file": "LICENSE",
"name": "BSD_3_CLAUSE"
},
"prcFile": "qhotkey.prc",
"priFile": "qhotkey.pri",
"priIncludes": [
],
"publishers": {
"qpm": {
"author": {
"email": "skycoder42.de@gmx.de",
"name": "Skycoder"
},
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
"name": "de.skycoder42.qhotkey",
"repository": {
"type": "GITHUB",
"url": "https://github.com/Skycoder42/QHotkey.git"
},
"webpage": "https://github.com/Skycoder42/QHotkey"
}
},
"source": false
}