From 308c96c28f9be4dc9139371200cd50c68f823a73 Mon Sep 17 00:00:00 2001 From: waneon Date: Sun, 6 Feb 2022 06:52:21 +0900 Subject: [PATCH 01/11] Fix invalid variable name in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 95ab938..5e40930 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ QHotkey supports both Qt6 and Qt5. When using Qt6, version 6.2.0 or later requir ### CMake -The CMake `QT_MAJOR` variable controls which major version of Qt is used for building, and defaults to `5`. For example, use the CMake command line option `-DQT_MAJOR=6` for building with Qt6. To build the testing application `QHotkeyTest`, specify `-DQHOTKEY_EXAMPLES=ON`. CMake example usage: +The CMake `QT_DEFAULT_MAJOR_VERSION` variable controls which major version of Qt is used for building, and defaults to `5`. For example, use the CMake command line option `-DQT_DEFAULT_MAJOR_VERSION=6` for building with Qt6. To build the testing application `QHotkeyTest`, specify `-DQHOTKEY_EXAMPLES=ON`. CMake example usage: ``` $ cd QHotkey -$ cmake -B build -S . -DQT_MAJOR=6 +$ cmake -B build -S . -DQT_DEFAULT_MAJOR_VERSION=6 $ cmake --build build # cmake --install build ``` From 52e25acf221e5ac86ce648f6922620fb2d6a7121 Mon Sep 17 00:00:00 2001 From: YueLiang <38413990+Yue-Liang@users.noreply.github.com> Date: Mon, 21 Feb 2022 16:01:45 +0800 Subject: [PATCH 02/11] Fix bug for get natice keycode failed in mac (#66) TISCopyCurrentKeyboardInputSource will return null when using Chinese input method. Use TISCopyCurrentASCIICapableKeyboardLayoutInputSource instead. --- QHotkey/qhotkey_mac.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QHotkey/qhotkey_mac.cpp b/QHotkey/qhotkey_mac.cpp index 2cf0db4..799f515 100644 --- a/QHotkey/qhotkey_mac.cpp +++ b/QHotkey/qhotkey_mac.cpp @@ -134,7 +134,7 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode, bool &ok) UTF16Char ch = keycode; CFDataRef currentLayoutData; - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + TISInputSourceRef currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource(); if (currentKeyboard == NULL) return 0; From c501fbbadaf9f561ad5a5c35964f924783a69647 Mon Sep 17 00:00:00 2001 From: luz paz Date: Wed, 22 Jun 2022 19:20:55 -0400 Subject: [PATCH 03/11] Fix typos Found via `codespell -q 3` --- HotkeyTest/hottestwidget.ui | 6 +++--- QHotkey/qhotkey_x11.cpp | 2 +- README.md | 12 ++++++------ doc/qhotkey.dox | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/HotkeyTest/hottestwidget.ui b/HotkeyTest/hottestwidget.ui index c1db840..8da0d92 100644 --- a/HotkeyTest/hottestwidget.ui +++ b/HotkeyTest/hottestwidget.ui @@ -769,7 +769,7 @@ - <b>Testing:</b> Please press the combinations listed below to check whether they work properly or not. Everytime a shortcut is triggered, the checkbox will toggle it's value. Set the test active to begin. + <b>Testing:</b> Please press the combinations listed below to check whether they work properly or not. Every time a shortcut is triggered, the checkbox will toggle it's value. Set the test active to begin. true @@ -927,7 +927,7 @@ - <html><head/><body><p>This test was designed to try out multi-threaded shortcuts. The QHotkey class is completly <span style=" font-weight:600;">threadsafe</span>, but this test can help to see if it acutally works (It does).</p><p>If activated, <span style=" font-style:italic;">Hotkey 4 and Hotkey 5 </span>of the Playground will each run on their own thread. This means:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Mainthread:</span> Hotkey 1, 2, 3</li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Second thread:</span> Hotkey 4</li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Third thread:</span> Hotkey 5</li></ul><p><span style=" font-weight:600;">Note:</span> The two hotkeys will be moved to the threads. For simplicity-reasons, you can't move them back in this test (But its possible, just not done here). Restart the test to get them back.</p></body></html> + <html><head/><body><p>This test was designed to try out multi-threaded shortcuts. The QHotkey class is completely <span style=" font-weight:600;">threadsafe</span>, but this test can help to see if it actually works (It does).</p><p>If activated, <span style=" font-style:italic;">Hotkey 4 and Hotkey 5 </span>of the Playground will each run on their own thread. This means:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Mainthread:</span> Hotkey 1, 2, 3</li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Second thread:</span> Hotkey 4</li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Third thread:</span> Hotkey 5</li></ul><p><span style=" font-weight:600;">Note:</span> The two hotkeys will be moved to the threads. For simplicity-reasons, you can't move them back in this test (But its possible, just not done here). Restart the test to get them back.</p></body></html> Qt::RichText @@ -973,7 +973,7 @@ - <html><head/><body><p>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.</p><p>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.</p><p><span style=" text-decoration: underline;">Example: Ctrl+A</span></p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Windows:</span> Key: <span style=" font-style:italic;">0x0041</span>, Modifier: <span style=" font-style:italic;">0x0002</span></li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">X11:</span> Key: <span style=" font-style:italic;">0x0026</span>, Modifier: <span style=" font-style:italic;">0x0004</span></li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">OsX:</span> Key: <span style=" font-style:italic;">0x0000</span>, Modifier: <span style=" font-style:italic;">0x0100</span><span style=" text-decoration: underline;"><br/></span></li></ul></body></html> + <html><head/><body><p>QHotkey allows you to set native shortcuts explicitly. These, of course, only work on the platform they were chosen 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.</p><p>In most cases, you will not need to specify native shortcuts directly. However, as explained on previous tabs, some shortcuts may not be creatable from Qt's key (e.g. Numblock numbers). In that case, you can set the directly.</p><p><span style=" text-decoration: underline;">Example: Ctrl+A</span></p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Windows:</span> Key: <span style=" font-style:italic;">0x0041</span>, Modifier: <span style=" font-style:italic;">0x0002</span></li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">X11:</span> Key: <span style=" font-style:italic;">0x0026</span>, Modifier: <span style=" font-style:italic;">0x0004</span></li><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">OsX:</span> Key: <span style=" font-style:italic;">0x0000</span>, Modifier: <span style=" font-style:italic;">0x0100</span><span style=" text-decoration: underline;"><br/></span></li></ul></body></html> true diff --git a/QHotkey/qhotkey_x11.cpp b/QHotkey/qhotkey_x11.cpp index ce408e6..d3ac1d1 100644 --- a/QHotkey/qhotkey_x11.cpp +++ b/QHotkey/qhotkey_x11.cpp @@ -13,7 +13,7 @@ #include #include -//compability to pre Qt 5.8 +//compatibility to pre Qt 5.8 #ifndef Q_FALLTHROUGH #define Q_FALLTHROUGH() (void)0 #endif diff --git a/README.md b/README.md index 5e40930..47595e0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ $ cmake --build build ### qmake -The major version of Qt is chosen by the qmake invokation itself, as the qmake executable is tied to a specific Qt version. The executable name can vary between operating systems. qmake example usage: +The major version of Qt is chosen by the qmake invocation itself, as the qmake executable is tied to a specific Qt version. The executable name can vary between operating systems. qmake example usage: ``` $ cd QHotkey @@ -94,18 +94,18 @@ int main(int argc, char *argv[]) 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. - **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 separate threads. It should work without a difference. - **Native Shortcut**: Allows you to try out the direct usage of native shortcuts ### 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 following function somewhere in your code: ```cpp QLoggingCategory::setFilterRules(QStringLiteral("QHotkey.warning=false")); ``` -This will turn all warnings of QHotkey of (It only uses warnings for now, thats why this is enough). For more information about all the things you can do with the logging categories, check the Qt-Documentation +This will turn all warnings of QHotkey of (It only uses warnings for now, that's why this is enough). For more information about all the things you can do with the logging categories, check the Qt-Documentation -## Thread saftey -The QHotkey class itself is reentrant - wich means you can create as many instances as required on any thread. This allows you to use the QHotkey on all threads. **But** you should never use the QHotkey instance on a thread that is different from the one the instance belongs to! Internally the system uses a singleton instance that handles the hotkey events and distributes them to the QHotkey instances. This internal class is completley threadsafe. +## Thread safety +The QHotkey class itself is reentrant - which means you can create as many instances as required on any thread. This allows you to use the QHotkey on all threads. **But** you should never use the QHotkey instance on a thread that is different from the one the instance belongs to! Internally the system uses a singleton instance that handles the hotkey events and distributes them to the QHotkey instances. This internal class is completely threadsafe. However, this singleton instance only runs on the main thread. (One reason is that some of the OS-Functions are not thread safe). To make threaded hotkeys possible, the critical functions (registering/unregistering hotkeys and keytranslation) are all run on the mainthread too. The QHotkey instances on other threads use `QMetaObject::invokeMethod` with a `Qt::BlockingQueuedConnection`. diff --git a/doc/qhotkey.dox b/doc/qhotkey.dox index fe184f3..dabde3c 100644 --- a/doc/qhotkey.dox +++ b/doc/qhotkey.dox @@ -38,7 +38,7 @@ In addition to the normal accessors, a modification of the QHotkey::shortcut pro @default{`QKeySequence()` (`Qt::Key_unknown` + `Qt::NoModifier`)} Holds the shortcut this hotkey will be registered on. It can be used as QKeySequence or as a combination of -a Qt::Key and Qt::KeyboardModifiers. All write-accessors specifiy an additional parameter to immediatly register +a Qt::Key and Qt::KeyboardModifiers. All write-accessors specify an additional parameter to immediately register the hotkey. @note Since the operating systems do not support hotkeys that consist of multiple key-combinations in a sequence, @@ -107,7 +107,7 @@ it does. This does not happen if used from the main thread. If the hotkey is still registered on destruction, it will automatically unregister itself. -@warning If using a hotkey on a thread other than the main thread, make shure the QApplication is still running it's eventloop. +@warning If using a hotkey on a thread other than the main thread, make sure the QApplication is still running it's eventloop. Otherwise your application will hang up. @sa QHotkey::registered @@ -144,7 +144,7 @@ from the thread this instance lives on. This method can be used to remap specific hotkey to a different native representation than the one that would be used by default. This can be useful if specific key combinations work fine -on allmost all platforms, but on one you need a different keycode for the same effect. See +on almost all platforms, but on one you need a different keycode for the same effect. See [Issue #15](https://github.com/Skycoder42/QHotkey/issues/15) for an example where this is the case. From 6b1c6f1f4e2a26e346e6a813adba6427f3d2c054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Tue, 21 Jun 2022 15:35:35 -0400 Subject: [PATCH 04/11] Made Windows BYTE typedef uppercase in attempt to get QHotkey to compile with MSVC 2019. --- QHotkey/qhotkey_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index 715b92e..9a88e30 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -235,7 +235,7 @@ quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok) default: if(keycode <= 0xFFFF) - return (byte)keycode; + return (BYTE)keycode; else { ok = false; return 0; From 94efd5fb61178b10d94b83838740b580ce79cd6c Mon Sep 17 00:00:00 2001 From: "Javier O. Cordero" Date: Thu, 30 Jun 2022 20:16:06 -0400 Subject: [PATCH 05/11] Using static_cast as suggested by Shatur. --- QHotkey/qhotkey_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index 9a88e30..e6bbc36 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -235,7 +235,7 @@ quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok) default: if(keycode <= 0xFFFF) - return (BYTE)keycode; + return static_cast(keycode); else { ok = false; return 0; From 34777f2e91b72cdc62a415975cc3ec53475ed022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Thu, 7 Jul 2022 09:01:21 -0400 Subject: [PATCH 06/11] CPack instructions to build Debian package Co-authored-by: Hennadii Chernyshchyk --- CMakeLists.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d1097..d34519e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(qhotkey VERSION 1.5.0 LANGUAGES CXX) +project(qhotkey + VERSION 1.5.0 + DESCRIPTION "Global hotkey library for Qt software" + HOMEPAGE_URL "https://skycoder42.github.io/QHotkey/" + LANGUAGES CXX) option(QHOTKEY_EXAMPLES "Build examples" OFF) option(QHOTKEY_INSTALL "Enable install rule" ON) @@ -18,6 +22,21 @@ else() find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Core Gui REQUIRED) endif() +# General settings +set(CPACK_PACKAGE_VENDOR "Skycoder42") +set(CPACK_PACKAGE_CONTACT "Shatur") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") +# CPACK: DEB Specific Settings +set(CPACK_DEBIAN_PACKAGE_NAME "libqhotkey") +set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries") +# Set dependencies +if(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt6x11extras6 (>= 6.2.0)") +else() + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5x11extras5 (>= 5.15.2)") +endif() +include(CPack) + add_library(qhotkey QHotkey/qhotkey.cpp) add_library(QHotkey::QHotkey ALIAS qhotkey) target_link_libraries(qhotkey PUBLIC Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Gui) From cd72a013275803fce33e028fc8b05ae32248da1f Mon Sep 17 00:00:00 2001 From: FredBill1 <36622430+FredBill1@users.noreply.github.com> Date: Tue, 18 Apr 2023 17:14:52 +0800 Subject: [PATCH 07/11] Properly emit `released` signal when pressing multiple hotkeys at the same time on Windows (#86) Co-authored-by: Hennadii Chernyshchyk --- QHotkey/qhotkey_win.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index e6bbc36..949d87a 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -1,7 +1,9 @@ #include "qhotkey.h" #include "qhotkey_p.h" #include +#include #include +#include #include #define HKEY_ID(nativeShortcut) (((nativeShortcut.key ^ (nativeShortcut.modifier << 8)) & 0x0FFF) | 0x7000) @@ -28,7 +30,7 @@ class QHotkeyPrivateWin : public QHotkeyPrivate private: static QString formatWinError(DWORD winError); QTimer pollTimer; - QHotkey::NativeShortcut polledShortcut; + QList polledShortcuts; }; NATIVE_INSTANCE(QHotkeyPrivateWin) @@ -51,8 +53,9 @@ bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *mes if(msg->message == WM_HOTKEY) { QHotkey::NativeShortcut shortcut = {HIWORD(msg->lParam), LOWORD(msg->lParam)}; this->activateShortcut(shortcut); - this->polledShortcut = shortcut; - this->pollTimer.start(); + if (this->polledShortcuts.empty()) + this->pollTimer.start(); + this->polledShortcuts.append(shortcut); } return false; @@ -60,11 +63,15 @@ bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *mes void QHotkeyPrivateWin::pollForHotkeyRelease() { - bool pressed = (GetAsyncKeyState(this->polledShortcut.key) & (1 << 15)) != 0; - if(!pressed) { + auto it = std::remove_if(this->polledShortcuts.begin(), this->polledShortcuts.end(), [this](const QHotkey::NativeShortcut &shortcut) { + bool pressed = (GetAsyncKeyState(shortcut.key) & (1 << 15)) != 0; + if (!pressed) + this->releaseShortcut(shortcut); + return !pressed; + }); + this->polledShortcuts.erase(it, this->polledShortcuts.end()); + if (this->polledShortcuts.empty()) this->pollTimer.stop(); - this->releaseShortcut(this->polledShortcut); - } } quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok) From b519155479a1a0af816f4b5f4b00d49a165cd8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Mon, 20 May 2024 09:09:14 -0400 Subject: [PATCH 08/11] Bump Qt and CI script versions, fix macOS support, and drop support for qmake (#98) --- .github/workflows/build.yml | 25 +++++-------------------- HotkeyTest/HotkeyTest.pro | 21 --------------------- QHotkey.pro | 10 ---------- QHotkey/QHotkey.pro | 16 ---------------- QHotkey/qhotkey.pri | 1 - README.md | 13 +------------ qhotkey.prc | 15 --------------- qhotkey.pri | 17 ----------------- 8 files changed, 6 insertions(+), 112 deletions(-) delete mode 100644 HotkeyTest/HotkeyTest.pro delete mode 100644 QHotkey.pro delete mode 100644 QHotkey/QHotkey.pro delete mode 100644 QHotkey/qhotkey.pri delete mode 100644 qhotkey.prc delete mode 100644 qhotkey.pri diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7affb86..89d7c90 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,10 +14,10 @@ jobs: build: strategy: matrix: - qt_version: [5.12.11, 5.15.2, 6.2.0] + qt_version: [5.12.12, 5.15.2, 6.2.2] platform: [ubuntu-20.04, windows-latest, macos-latest] include: - - qt_version: 6.2.0 + - qt_version: 6.2.2 additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6 - platform: ubuntu-20.04 make: make @@ -41,31 +41,16 @@ jobs: uses: actions/checkout@v2.3.4 - name: Install Qt - uses: jurplel/install-qt-action@v2.14.0 + uses: jurplel/install-qt-action@v3.3.0 with: version: ${{ matrix.qt_version }} - name: Build with CMake as static run: | - cmake . -D QHOTKEY_EXAMPLES=ON ${{ matrix.additional_arguments }} + cmake . -D QHOTKEY_EXAMPLES=ON -D CMAKE_OSX_ARCHITECTURES="x86_64" ${{ matrix.additional_arguments }} cmake --build . - name: Build with CMake as shared run: | - cmake . -D BUILD_SHARED_LIBS=ON -D QHOTKEY_EXAMPLES=ON ${{ matrix.additional_arguments }} + cmake . -D BUILD_SHARED_LIBS=ON -D QHOTKEY_EXAMPLES=ON -D CMAKE_OSX_ARCHITECTURES="x86_64" ${{ matrix.additional_arguments }} cmake --build . - - - name: Setup MSVC environment for QMake - uses: ilammy/msvc-dev-cmd@v1 - - - name: Build with QMake as static - working-directory: HotkeyTest - run: | - qmake - ${{ matrix.make }} - - - name: Build with QMake as shared - working-directory: HotkeyTest - run: | - qmake "DEFINES+=QHOTKEY_SHARED QHOTKEY_LIBRARY" - ${{ matrix.make }} diff --git a/HotkeyTest/HotkeyTest.pro b/HotkeyTest/HotkeyTest.pro deleted file mode 100644 index a43f662..0000000 --- a/HotkeyTest/HotkeyTest.pro +++ /dev/null @@ -1,21 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2016-02-05T22:01:03 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = HotkeyTest -TEMPLATE = app - -include(../qhotkey.pri) - -SOURCES += main.cpp\ - hottestwidget.cpp - -HEADERS += hottestwidget.h - -FORMS += hottestwidget.ui diff --git a/QHotkey.pro b/QHotkey.pro deleted file mode 100644 index 5fa7cbe..0000000 --- a/QHotkey.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - HotkeyTest \ - QHotkey - -DISTFILES += README.md \ - LICENSE \ - doc/qhotkey.doxy \ - doc/qhotkey.dox diff --git a/QHotkey/QHotkey.pro b/QHotkey/QHotkey.pro deleted file mode 100644 index 3a79376..0000000 --- a/QHotkey/QHotkey.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = lib -win32: CONFIG += dll - -TARGET = QHotkey -VERSION = 1.5.0 - -include(../qhotkey.pri) - -DEFINES += QHOTKEY_SHARED QHOTKEY_LIBRARY - -# 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 - diff --git a/QHotkey/qhotkey.pri b/QHotkey/qhotkey.pri deleted file mode 100644 index a7c9725..0000000 --- a/QHotkey/qhotkey.pri +++ /dev/null @@ -1 +0,0 @@ -message(The pri file has been moved one directory up! use that one instead) diff --git a/README.md b/README.md index 47595e0..4058dfd 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka ## Building -QHotkey supports both Qt6 and Qt5. When using Qt6, version 6.2.0 or later required. It can be built by either the CMake or qmake building systems. +QHotkey supports both Qt6 and Qt5. When using Qt6, version 6.2.0 or later required. It can be built using the CMake building system. ### CMake @@ -29,17 +29,6 @@ $ cmake --build build # cmake --install build ``` -### qmake - -The major version of Qt is chosen by the qmake invocation itself, as the qmake executable is tied to a specific Qt version. The executable name can vary between operating systems. qmake example usage: - -``` -$ cd QHotkey -$ qmake -$ make -# make install -``` - ## Installation The package is providet as qpm package, [`de.skycoder42.qhotkey`](https://www.qpm.io/packages/de.skycoder42.qhotkey/index.html). You can install it either via qpmx (preferred) or directly via qpm. diff --git a/qhotkey.prc b/qhotkey.prc deleted file mode 100644 index d8e8ac0..0000000 --- a/qhotkey.prc +++ /dev/null @@ -1,15 +0,0 @@ -mac: LIBS += -framework Carbon -else:win32: LIBS += -luser32 -else:unix { - equals(QT_MAJOR_VERSION, 6) { - lessThan(QT_VERSION, 6.2.0) { - error("Qt 6.2.0 or greater is required when using Qt6") - } - } - else { - lessThan(QT_MAJOR_VERSION, 6) { - QT += x11extras - } - } - LIBS += -lX11 -} diff --git a/qhotkey.pri b/qhotkey.pri deleted file mode 100644 index 1dc2ae9..0000000 --- a/qhotkey.pri +++ /dev/null @@ -1,17 +0,0 @@ -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) From bb630252684d3556b79ac7a521616692f348fcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Mon, 20 May 2024 15:13:12 -0400 Subject: [PATCH 09/11] Fix: Prevent crash on Wayland when using Qt 6 (#97) --- QHotkey/qhotkey_x11.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/QHotkey/qhotkey_x11.cpp b/QHotkey/qhotkey_x11.cpp index d3ac1d1..d9d73f7 100644 --- a/QHotkey/qhotkey_x11.cpp +++ b/QHotkey/qhotkey_x11.cpp @@ -132,13 +132,16 @@ quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode, bool &ok) #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface(); - Display *display = x11Interface->display(); #else const bool x11Interface = QX11Info::isPlatformX11(); - Display *display = QX11Info::display(); #endif if(x11Interface) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + Display *display = x11Interface->display(); +#else + Display *display = QX11Info::display(); +#endif auto res = XKeysymToKeycode(display, keysym); if(res != 0) ok = true; From 8f90bdf90c0f98f639bcff6c49d8da80ad4b31ea Mon Sep 17 00:00:00 2001 From: Daniel Bermond Date: Sun, 6 Jul 2025 07:48:05 -0300 Subject: [PATCH 10/11] Add compatibility with CMake 4.0 (#103) Starting at CMake 4.0, the minimum required policy version is 3.5.0[1], either specified by 'cmake_minimum_required()' or by 'cmake_policy()'. This also applies to individual policies when they are set, which must match 3.5.0 or later policies. [1] https://cmake.org/cmake/help/v4.0/command/cmake_minimum_required.html --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d34519e..727218e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(qhotkey VERSION 1.5.0 From 6c0e98492c59206139f8490706aadeb8ed033057 Mon Sep 17 00:00:00 2001 From: Daniel Bermond Date: Sun, 6 Jul 2025 07:48:54 -0300 Subject: [PATCH 11/11] Add compatibility with QT_NO_KEYWORDS macro (#104) The Qt documentation recommends[1] not using Qt keywords in the public API of Qt libraries, specially the 'signals' and 'slots' Qt keywords. Without this, client applications that are compiled with the 'QT_NO_KEYWORDS'[2] macro (or that are compiled in conjunction with other libraries that also defines the same Qt keywords) will fail to build. The 'QT_NO_SIGNALS_SLOTS_KEYWORDS'[1] macro assures that the library is not using 'signals' and 'slots' Qt keywords, since it will fail to build when they are used. Useful for code sanity and for avoiding future pull requests that may try to use these Qt keywords. [1] https://doc.qt.io/qt-6/signalsandslots.html#signals-and-slots-in-qt-based-libraries [2] https://doc.qt.io/qt-6/qtglobal.html#QT_NO_KEYWORDS --- CMakeLists.txt | 2 ++ QHotkey/qhotkey.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 727218e..32cda4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,8 @@ add_library(qhotkey QHotkey/qhotkey.cpp) add_library(QHotkey::QHotkey ALIAS qhotkey) target_link_libraries(qhotkey PUBLIC Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Gui) +target_compile_definitions(qhotkey PRIVATE QT_NO_SIGNALS_SLOTS_KEYWORDS) + if(BUILD_SHARED_LIBS) target_compile_definitions(qhotkey PRIVATE QHOTKEY_LIBRARY) target_compile_definitions(qhotkey PUBLIC QHOTKEY_SHARED) diff --git a/QHotkey/qhotkey.h b/QHotkey/qhotkey.h index 3697c8e..12f5fec 100644 --- a/QHotkey/qhotkey.h +++ b/QHotkey/qhotkey.h @@ -88,7 +88,7 @@ class QHOTKEY_EXPORT QHotkey : public QObject //! Get the current native shortcut NativeShortcut currentNativeShortcut() const; -public slots: +public Q_SLOTS: //! @writeAcFn{QHotkey::registered} bool setRegistered(bool registered); @@ -102,7 +102,7 @@ public slots: //! Set this hotkey to a native shortcut bool setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool autoRegister = false); -signals: +Q_SIGNALS: //! Will be emitted if the shortcut is pressed void activated(QPrivateSignal); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy