mirror of
https://github.com/Skycoder42/QHotkey.git
synced 2026-11-19 12:49:58 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e3a244d87 | ||
|
|
d7b2589855 | ||
|
|
6c0e98492c | ||
|
|
8f90bdf90c | ||
|
|
bb63025268 | ||
|
|
b519155479 | ||
|
|
cd72a01327 | ||
|
|
34777f2e91 | ||
|
|
94efd5fb61 | ||
|
|
6b1c6f1f4e | ||
|
|
c501fbbada | ||
|
|
52e25acf22 | ||
|
|
308c96c28f | ||
|
|
34330d6ff5 | ||
|
|
6a0cc377e6 | ||
|
|
fcf83f3e36 | ||
|
|
64fec66d35 | ||
|
|
1114df5081 | ||
|
|
e0bc2a9b9f | ||
|
|
1d49a63827 | ||
|
|
7f5840fd34 | ||
|
|
7b10ea6d64 | ||
|
|
79e5dd65be | ||
|
|
dbec7d3a2d | ||
|
|
6b3cc35bbd | ||
|
|
25f21849b3 | ||
|
|
eb7ddaba57 | ||
|
|
8584ff1b15 | ||
|
|
384f780b28 | ||
|
|
4bb901a41e | ||
|
|
2a87965ed6 | ||
|
|
f0799fd4a4 | ||
|
|
53745ba936 | ||
|
|
b73b4955ae | ||
|
|
bd35d8b07a | ||
|
|
941cb2f15f | ||
|
|
4f76792098 | ||
|
|
483e07365e | ||
|
|
c373d83c36 | ||
|
|
055d242ded | ||
|
|
0352904ec1 | ||
|
|
7de281c4a6 | ||
|
|
83a0066760 | ||
|
|
7028920db5 | ||
|
|
df684dcc2a | ||
|
|
e113ace9a1 | ||
|
|
12e05bfd4e | ||
|
|
d32957e52c | ||
|
|
5b507a84df | ||
|
|
9583eafe76 | ||
|
|
96a0710e1b | ||
|
|
a7110cabb3 | ||
|
|
5557a02fcf | ||
|
|
9a44a0313b | ||
|
|
700367d132 | ||
|
|
547cf7a7cc | ||
|
|
f00ae2a071 | ||
|
|
9a90aff273 | ||
|
|
080ddd479a | ||
|
|
2d21833742 | ||
|
|
fc259100b2 | ||
|
|
670705e4e0 | ||
|
|
f549a7763f | ||
|
|
d46af31902 | ||
|
|
f4665e20ad | ||
|
|
9a04e8f539 | ||
|
|
974af9253c | ||
|
|
9a812a3eb4 | ||
|
|
0943bb0494 | ||
|
|
b910580fce | ||
|
|
c9cfd8fb6f | ||
|
|
7d214ac41e | ||
|
|
83910c8eca | ||
|
|
91f3542b5d | ||
|
|
1833a053f6 | ||
|
|
f288e85ef1 | ||
|
|
2578b69dc5 | ||
|
|
a0678c4cfc | ||
|
|
cdb4d37453 | ||
|
|
9eace8fbbd | ||
|
|
6baf644b40 | ||
|
|
3fa176a380 |
@@ -0,0 +1,56 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- "releases/**"
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
qt_version: [5.12.12, 5.15.2, 6.2.2]
|
||||||
|
platform: [ubuntu-20.04, windows-latest, macos-latest]
|
||||||
|
include:
|
||||||
|
- qt_version: 6.2.2
|
||||||
|
additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6
|
||||||
|
- platform: ubuntu-20.04
|
||||||
|
make: make
|
||||||
|
CXXFLAGS: -Wall -Wextra -pedantic -Werror
|
||||||
|
MAKEFLAGS: -j2
|
||||||
|
- platform: macos-latest
|
||||||
|
make: make
|
||||||
|
CXXFLAGS: -Wall -Wextra -pedantic -Werror -Wno-gnu-zero-variadic-macro-arguments # Ignore false-positive warning for qCWarning
|
||||||
|
MAKEFLAGS: -j3
|
||||||
|
- platform: windows-latest
|
||||||
|
make: nmake
|
||||||
|
CXXFLAGS: /W4 /WX /MP
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
env:
|
||||||
|
CXXFLAGS: ${{ matrix.CXXFLAGS }}
|
||||||
|
MAKEFLAGS: ${{ matrix.MAKEFLAGS }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v2.3.4
|
||||||
|
|
||||||
|
- name: Install Qt
|
||||||
|
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 -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 -D CMAKE_OSX_ARCHITECTURES="x86_64" ${{ matrix.additional_arguments }}
|
||||||
|
cmake --build .
|
||||||
+117
@@ -0,0 +1,117 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
if(NOT QT_DEFAULT_MAJOR_VERSION)
|
||||||
|
set(QT_DEFAULT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
|
||||||
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} 6.2.0 COMPONENTS Core Gui REQUIRED)
|
||||||
|
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)
|
||||||
|
|
||||||
|
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)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
find_library(CARBON_LIBRARY Carbon)
|
||||||
|
mark_as_advanced(CARBON_LIBRARY)
|
||||||
|
|
||||||
|
target_sources(qhotkey PRIVATE QHotkey/qhotkey_mac.cpp)
|
||||||
|
target_link_libraries(qhotkey PRIVATE ${CARBON_LIBRARY})
|
||||||
|
elseif(WIN32)
|
||||||
|
target_sources(qhotkey PRIVATE QHotkey/qhotkey_win.cpp)
|
||||||
|
else()
|
||||||
|
find_package(X11 REQUIRED)
|
||||||
|
if(QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6)
|
||||||
|
target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES})
|
||||||
|
else()
|
||||||
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS X11Extras REQUIRED)
|
||||||
|
target_link_libraries(qhotkey
|
||||||
|
PRIVATE
|
||||||
|
${X11_LIBRARIES}
|
||||||
|
Qt${QT_DEFAULT_MAJOR_VERSION}::X11Extras)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(${X11_INCLUDE_DIR})
|
||||||
|
target_sources(qhotkey PRIVATE QHotkey/qhotkey_x11.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
target_include_directories(qhotkey
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/QHotkey>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
set_target_properties(qhotkey PROPERTIES
|
||||||
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
INTERFACE_QHotkey_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}
|
||||||
|
COMPATIBLE_INTERFACE_STRING QHotkey_MAJOR_VERSION)
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/QHotkeyConfigVersion.cmake
|
||||||
|
VERSION "${PROJECT_VERSION}"
|
||||||
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
|
||||||
|
if(QHOTKEY_EXAMPLES)
|
||||||
|
add_subdirectory(HotkeyTest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(QHOTKEY_INSTALL)
|
||||||
|
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS qhotkey EXPORT QHotkeyConfig
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/qhotkey.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/QHotkey
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/QHotkeyConfigVersion.cmake
|
||||||
|
DESTINATION ${INSTALL_CONFIGDIR})
|
||||||
|
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})
|
||||||
|
|
||||||
|
export(TARGETS qhotkey FILE QHotkeyConfig.cmake)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
|
add_executable(HotkeyTest
|
||||||
|
main.cpp
|
||||||
|
hottestwidget.cpp
|
||||||
|
hottestwidget.ui)
|
||||||
|
|
||||||
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Widgets REQUIRED)
|
||||||
|
target_link_libraries(HotkeyTest Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets QHotkey::QHotkey)
|
||||||
@@ -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
|
|
||||||
@@ -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),
|
||||||
@@ -18,6 +20,11 @@ HotTestWidget::HotTestWidget(QWidget *parent) :
|
|||||||
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);
|
||||||
|
|||||||
@@ -769,7 +769,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><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.</string>
|
<string><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.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -927,7 +927,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><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></string>
|
<string><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></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::RichText</enum>
|
<enum>Qt::RichText</enum>
|
||||||
@@ -973,7 +973,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><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></string>
|
<string><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></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
TEMPLATE = subdirs
|
|
||||||
|
|
||||||
SUBDIRS += \
|
|
||||||
HotkeyTest
|
|
||||||
|
|
||||||
DISTFILES += README.md \
|
|
||||||
LICENSE \
|
|
||||||
doc/qhotkey.doxy \
|
|
||||||
doc/qhotkey.dox
|
|
||||||
+101
-50
@@ -8,18 +8,36 @@
|
|||||||
|
|
||||||
Q_LOGGING_CATEGORY(logQHotkey, "QHotkey")
|
Q_LOGGING_CATEGORY(logQHotkey, "QHotkey")
|
||||||
|
|
||||||
|
void QHotkey::addGlobalMapping(const QKeySequence &shortcut, QHotkey::NativeShortcut nativeShortcut)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
const int key = shortcut[0].toCombined();
|
||||||
|
#else
|
||||||
|
const int key = shortcut[0];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(QHotkeyPrivate::instance(), "addMappingInvoked", Qt::QueuedConnection,
|
||||||
|
Q_ARG(Qt::Key, Qt::Key(key & ~Qt::KeyboardModifierMask)),
|
||||||
|
Q_ARG(Qt::KeyboardModifiers, Qt::KeyboardModifiers(key & Qt::KeyboardModifierMask)),
|
||||||
|
Q_ARG(QHotkey::NativeShortcut, nativeShortcut));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::isPlatformSupported()
|
||||||
|
{
|
||||||
|
return QHotkeyPrivate::isPlatformSupported();
|
||||||
|
}
|
||||||
|
|
||||||
QHotkey::QHotkey(QObject *parent) :
|
QHotkey::QHotkey(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
_keyCode(Qt::Key_unknown),
|
_keyCode(Qt::Key_unknown),
|
||||||
_modifiers(Qt::NoModifier),
|
_modifiers(Qt::NoModifier),
|
||||||
_nativeShortcut(),
|
|
||||||
_registered(false)
|
_registered(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QHotkey::QHotkey(const QKeySequence &sequence, bool autoRegister, QObject *parent) :
|
QHotkey::QHotkey(const QKeySequence &shortcut, bool autoRegister, QObject *parent) :
|
||||||
QHotkey(parent)
|
QHotkey(parent)
|
||||||
{
|
{
|
||||||
setShortcut(sequence, autoRegister);
|
setShortcut(shortcut, autoRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHotkey::QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister, QObject *parent) :
|
QHotkey::QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister, QObject *parent) :
|
||||||
@@ -28,7 +46,7 @@ QHotkey::QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegi
|
|||||||
setShortcut(keyCode, modifiers, autoRegister);
|
setShortcut(keyCode, modifiers, autoRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHotkey::QHotkey(const QHotkey::NativeShortcut &shortcut, bool autoRegister, QObject *parent) :
|
QHotkey::QHotkey(QHotkey::NativeShortcut shortcut, bool autoRegister, QObject *parent) :
|
||||||
QHotkey(parent)
|
QHotkey(parent)
|
||||||
{
|
{
|
||||||
setNativeShortcut(shortcut, autoRegister);
|
setNativeShortcut(shortcut, autoRegister);
|
||||||
@@ -44,8 +62,12 @@ QKeySequence QHotkey::shortcut() const
|
|||||||
{
|
{
|
||||||
if(_keyCode == Qt::Key_unknown)
|
if(_keyCode == Qt::Key_unknown)
|
||||||
return QKeySequence();
|
return QKeySequence();
|
||||||
else
|
|
||||||
return QKeySequence(_keyCode | _modifiers);
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
return QKeySequence((_keyCode | _modifiers).toCombined());
|
||||||
|
#else
|
||||||
|
return QKeySequence(static_cast<int>(_keyCode | _modifiers));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Key QHotkey::keyCode() const
|
Qt::Key QHotkey::keyCode() const
|
||||||
@@ -70,15 +92,21 @@ bool QHotkey::isRegistered() const
|
|||||||
|
|
||||||
bool QHotkey::setShortcut(const QKeySequence &shortcut, bool autoRegister)
|
bool QHotkey::setShortcut(const QKeySequence &shortcut, bool autoRegister)
|
||||||
{
|
{
|
||||||
if(shortcut.isEmpty()) {
|
if(shortcut.isEmpty())
|
||||||
return resetShortcut();
|
return resetShortcut();
|
||||||
} else if(shortcut.count() > 1) {
|
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 setShortcut(Qt::Key(shortcut[0] & ~Qt::KeyboardModifierMask),
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
Qt::KeyboardModifiers(shortcut[0] & Qt::KeyboardModifierMask),
|
const int key = shortcut[0].toCombined();
|
||||||
|
#else
|
||||||
|
const int key = shortcut[0];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return setShortcut(Qt::Key(key & ~Qt::KeyboardModifierMask),
|
||||||
|
Qt::KeyboardModifiers(key & Qt::KeyboardModifierMask),
|
||||||
autoRegister);
|
autoRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,15 +133,14 @@ bool QHotkey::setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool
|
|||||||
if(_nativeShortcut.isValid()) {
|
if(_nativeShortcut.isValid()) {
|
||||||
if(autoRegister)
|
if(autoRegister)
|
||||||
return QHotkeyPrivate::instance()->addShortcut(this);
|
return QHotkeyPrivate::instance()->addShortcut(this);
|
||||||
else
|
return true;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
qCWarning(logQHotkey) << "Unable to map shortcut to native keys. Key:" << keyCode << "Modifiers:" << modifiers;
|
|
||||||
_keyCode = Qt::Key_unknown;
|
|
||||||
_modifiers = Qt::NoModifier;
|
|
||||||
_nativeShortcut = NativeShortcut();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCWarning(logQHotkey) << "Unable to map shortcut to native keys. Key:" << keyCode << "Modifiers:" << modifiers;
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = NativeShortcut();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkey::resetShortcut()
|
bool QHotkey::resetShortcut()
|
||||||
@@ -145,35 +172,32 @@ bool QHotkey::setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool aut
|
|||||||
_nativeShortcut = nativeShortcut;
|
_nativeShortcut = nativeShortcut;
|
||||||
if(autoRegister)
|
if(autoRegister)
|
||||||
return QHotkeyPrivate::instance()->addShortcut(this);
|
return QHotkeyPrivate::instance()->addShortcut(this);
|
||||||
else
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
_keyCode = Qt::Key_unknown;
|
|
||||||
_modifiers = Qt::NoModifier;
|
|
||||||
_nativeShortcut = NativeShortcut();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = NativeShortcut();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkey::setRegistered(bool registered)
|
bool QHotkey::setRegistered(bool registered)
|
||||||
{
|
{
|
||||||
if(_registered && !registered)
|
if(_registered && !registered)
|
||||||
return QHotkeyPrivate::instance()->removeShortcut(this);
|
return QHotkeyPrivate::instance()->removeShortcut(this);
|
||||||
else if(!_registered && registered) {
|
if(!_registered && registered) {
|
||||||
if(!_nativeShortcut.isValid())
|
if(!_nativeShortcut.isValid())
|
||||||
return false;
|
return false;
|
||||||
else
|
return QHotkeyPrivate::instance()->addShortcut(this);
|
||||||
return QHotkeyPrivate::instance()->addShortcut(this);
|
}
|
||||||
} else
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---------- QHotkeyPrivate implementation ----------
|
// ---------- QHotkeyPrivate implementation ----------
|
||||||
|
|
||||||
QHotkeyPrivate::QHotkeyPrivate() :
|
QHotkeyPrivate::QHotkeyPrivate()
|
||||||
shortcuts()
|
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(qApp, Q_FUNC_INFO, "QHotkey requires QCoreApplication to be instantiated");
|
Q_ASSERT_X(qApp, Q_FUNC_INFO, "QHotkey requires QCoreApplication to be instantiated");
|
||||||
qApp->eventDispatcher()->installNativeEventFilter(this);
|
qApp->eventDispatcher()->installNativeEventFilter(this);
|
||||||
@@ -198,8 +222,8 @@ QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::Keyb
|
|||||||
Q_ARG(Qt::Key, keycode),
|
Q_ARG(Qt::Key, keycode),
|
||||||
Q_ARG(Qt::KeyboardModifiers, modifiers))) {
|
Q_ARG(Qt::KeyboardModifiers, modifiers))) {
|
||||||
return QHotkey::NativeShortcut();
|
return QHotkey::NativeShortcut();
|
||||||
} else
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
|
bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
|
||||||
@@ -215,11 +239,11 @@ bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
|
|||||||
Q_RETURN_ARG(bool, res),
|
Q_RETURN_ARG(bool, res),
|
||||||
Q_ARG(QHotkey*, hotkey))) {
|
Q_ARG(QHotkey*, hotkey))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
if(res)
|
|
||||||
emit hotkey->registeredChanged(true);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
emit hotkey->registeredChanged(true);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)
|
bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)
|
||||||
@@ -235,11 +259,11 @@ bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)
|
|||||||
Q_RETURN_ARG(bool, res),
|
Q_RETURN_ARG(bool, res),
|
||||||
Q_ARG(QHotkey*, hotkey))) {
|
Q_ARG(QHotkey*, hotkey))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
if(res)
|
|
||||||
emit hotkey->registeredChanged(false);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
emit hotkey->registeredChanged(false);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut)
|
void QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
@@ -249,13 +273,27 @@ void QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
signal.invoke(hkey, Qt::QueuedConnection);
|
signal.invoke(hkey, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QHotkeyPrivate::releaseShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
QMetaMethod signal = QMetaMethod::fromSignal(&QHotkey::released);
|
||||||
|
for(QHotkey *hkey : shortcuts.values(shortcut))
|
||||||
|
signal.invoke(hkey, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHotkeyPrivate::addMappingInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers, 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(!shortcuts.contains(shortcut)) {
|
if(!shortcuts.contains(shortcut)) {
|
||||||
if(!registerShortcut(shortcut))
|
if(!registerShortcut(shortcut)) {
|
||||||
|
qCWarning(logQHotkey) << QHotkey::tr("Failed to register %1. Error: %2").arg(hotkey->shortcut().toString(), error);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shortcuts.insert(shortcut, hotkey);
|
shortcuts.insert(shortcut, hotkey);
|
||||||
@@ -271,15 +309,28 @@ bool QHotkeyPrivate::removeShortcutInvoked(QHotkey *hotkey)
|
|||||||
return false;
|
return false;
|
||||||
hotkey->_registered = false;
|
hotkey->_registered = false;
|
||||||
emit hotkey->registeredChanged(true);
|
emit hotkey->registeredChanged(true);
|
||||||
if(shortcuts.count(shortcut) == 0)
|
if(shortcuts.count(shortcut) == 0) {
|
||||||
return unregisterShortcut(shortcut);
|
if (!unregisterShortcut(shortcut)) {
|
||||||
else
|
qCWarning(logQHotkey) << QHotkey::tr("Failed to unregister %1. Error: %2").arg(hotkey->shortcut().toString(), error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
|
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
|
||||||
{
|
{
|
||||||
return {this->nativeKeycode(keycode), this->nativeModifiers(modifiers)};
|
if(mapping.contains({keycode, modifiers}))
|
||||||
|
return mapping.value({keycode, modifiers});
|
||||||
|
|
||||||
|
bool ok1 = false;
|
||||||
|
auto k = nativeKeycode(keycode, ok1);
|
||||||
|
bool ok2 = false;
|
||||||
|
auto m = nativeModifiers(modifiers, ok2);
|
||||||
|
if(ok1 && ok2)
|
||||||
|
return {k, m};
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -301,26 +352,26 @@ bool QHotkey::NativeShortcut::isValid() const
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkey::NativeShortcut::operator ==(const QHotkey::NativeShortcut &other) const
|
bool QHotkey::NativeShortcut::operator ==(QHotkey::NativeShortcut other) const
|
||||||
{
|
{
|
||||||
return (key == other.key) &&
|
return (key == other.key) &&
|
||||||
(modifier == other.modifier) &&
|
(modifier == other.modifier) &&
|
||||||
valid == other.valid;
|
valid == other.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkey::NativeShortcut::operator !=(const QHotkey::NativeShortcut &other) const
|
bool QHotkey::NativeShortcut::operator !=(QHotkey::NativeShortcut other) const
|
||||||
{
|
{
|
||||||
return (key != other.key) ||
|
return (key != other.key) ||
|
||||||
(modifier != other.modifier) ||
|
(modifier != other.modifier) ||
|
||||||
valid != other.valid;
|
valid != other.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint qHash(const QHotkey::NativeShortcut &key)
|
QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key)
|
||||||
{
|
{
|
||||||
return qHash(key.key) ^ qHash(key.modifier);
|
return qHash(key.key) ^ qHash(key.modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint qHash(const QHotkey::NativeShortcut &key, uint seed)
|
QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed)
|
||||||
{
|
{
|
||||||
return qHash(key.key, seed) ^ qHash(key.modifier, seed);
|
return qHash(key.key, seed) ^ qHash(key.modifier, seed);
|
||||||
}
|
}
|
||||||
|
|||||||
+56
-29
@@ -6,10 +6,27 @@
|
|||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#ifdef QHOTKEY_SHARED
|
||||||
|
# ifdef QHOTKEY_LIBRARY
|
||||||
|
# define QHOTKEY_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define QHOTKEY_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define QHOTKEY_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
#define QHOTKEY_HASH_SEED size_t
|
||||||
|
#else
|
||||||
|
#define QHOTKEY_HASH_SEED uint
|
||||||
|
#endif
|
||||||
|
|
||||||
//! A class to define global, systemwide Hotkeys
|
//! A class to define global, systemwide Hotkeys
|
||||||
class QHotkey : public QObject
|
class QHOTKEY_EXPORT QHotkey : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
//! @private
|
||||||
friend class QHotkeyPrivate;
|
friend class QHotkeyPrivate;
|
||||||
|
|
||||||
//! Specifies whether this hotkey is currently registered or not
|
//! Specifies whether this hotkey is currently registered or not
|
||||||
@@ -19,7 +36,7 @@ class QHotkey : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Defines shortcut with native keycodes
|
//! Defines shortcut with native keycodes
|
||||||
class NativeShortcut {
|
class QHOTKEY_EXPORT NativeShortcut {
|
||||||
public:
|
public:
|
||||||
//! The native keycode
|
//! The native keycode
|
||||||
quint32 key;
|
quint32 key;
|
||||||
@@ -35,56 +52,64 @@ public:
|
|||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
//! Equality operator
|
//! Equality operator
|
||||||
bool operator ==(const NativeShortcut &other) const;
|
bool operator ==(NativeShortcut other) const;
|
||||||
//! Inequality operator
|
//! Inequality operator
|
||||||
bool operator !=(const NativeShortcut &other) const;
|
bool operator !=(NativeShortcut other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool valid;
|
bool valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor
|
//! Adds a global mapping of a key sequence to a replacement native shortcut
|
||||||
explicit QHotkey(QObject *parent = Q_NULLPTR);
|
static void addGlobalMapping(const QKeySequence &shortcut, NativeShortcut nativeShortcut);
|
||||||
//! Constructs a hotkey with a shortcut and optionally registers it
|
|
||||||
explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = Q_NULLPTR);
|
|
||||||
//! Constructs a hotkey with a key and modifiers and optionally registers it
|
|
||||||
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
|
|
||||||
~QHotkey();
|
|
||||||
|
|
||||||
//! READ-Accessor for QHotkey::registered
|
//! Checks if global shortcuts are supported by the current platform
|
||||||
|
static bool isPlatformSupported();
|
||||||
|
|
||||||
|
//! Default Constructor
|
||||||
|
explicit QHotkey(QObject *parent = nullptr);
|
||||||
|
//! Constructs a hotkey with a shortcut and optionally registers it
|
||||||
|
explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = nullptr);
|
||||||
|
//! Constructs a hotkey with a key and modifiers and optionally registers it
|
||||||
|
explicit QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false, QObject *parent = nullptr);
|
||||||
|
//! Constructs a hotkey from a native shortcut and optionally registers it
|
||||||
|
explicit QHotkey(NativeShortcut shortcut, bool autoRegister = false, QObject *parent = nullptr);
|
||||||
|
~QHotkey() override;
|
||||||
|
|
||||||
|
//! @readAcFn{QHotkey::registered}
|
||||||
bool isRegistered() const;
|
bool isRegistered() const;
|
||||||
//! READ-Accessor for QHotkey::shortcut - the key and modifiers as a QKeySequence
|
//! @readAcFn{QHotkey::shortcut}
|
||||||
QKeySequence shortcut() const;
|
QKeySequence shortcut() const;
|
||||||
//! READ-Accessor for QHotkey::shortcut - the key only
|
//! @readAcFn{QHotkey::shortcut} - the key only
|
||||||
Qt::Key keyCode() const;
|
Qt::Key keyCode() const;
|
||||||
//! READ-Accessor for QHotkey::shortcut - the modifiers only
|
//! @readAcFn{QHotkey::shortcut} - the modifiers only
|
||||||
Qt::KeyboardModifiers modifiers() const;
|
Qt::KeyboardModifiers modifiers() const;
|
||||||
|
|
||||||
//! Get the current native shortcut
|
//! Get the current native shortcut
|
||||||
NativeShortcut currentNativeShortcut() const;
|
NativeShortcut currentNativeShortcut() const;
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
//! WRITE-Accessor for QHotkey::registered
|
//! @writeAcFn{QHotkey::registered}
|
||||||
bool setRegistered(bool registered);
|
bool setRegistered(bool registered);
|
||||||
|
|
||||||
//! WRITE-Accessor for QHotkey::shortcut
|
//! @writeAcFn{QHotkey::shortcut}
|
||||||
bool setShortcut(const QKeySequence &shortcut, bool autoRegister = false);
|
bool setShortcut(const QKeySequence &shortcut, bool autoRegister = false);
|
||||||
//! WRITE-Accessor for QHotkey::shortcut
|
//! @writeAcFn{QHotkey::shortcut}
|
||||||
bool setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false);
|
bool setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false);
|
||||||
//! RESET-Accessor for QHotkey::shortcut
|
//! @resetAcFn{QHotkey::shortcut}
|
||||||
bool resetShortcut();
|
bool resetShortcut();
|
||||||
|
|
||||||
//! Set this hotkey to a native shortcut
|
//! Set this hotkey to a native shortcut
|
||||||
bool setNativeShortcut(NativeShortcut nativeShortcut, bool autoRegister = false);
|
bool setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool autoRegister = false);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
//! Will be emitted if the shortcut is pressed
|
//! Will be emitted if the shortcut is pressed
|
||||||
void activated(QPrivateSignal);
|
void activated(QPrivateSignal);
|
||||||
|
|
||||||
//! NOTIFY-Accessor for QHotkey::registered
|
//! Will be emitted if the shortcut press is released
|
||||||
|
void released(QPrivateSignal);
|
||||||
|
|
||||||
|
//! @notifyAcFn{QHotkey::registered}
|
||||||
void registeredChanged(bool registered);
|
void registeredChanged(bool registered);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -95,9 +120,11 @@ private:
|
|||||||
bool _registered;
|
bool _registered;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint qHash(const QHotkey::NativeShortcut &key);
|
QHOTKEY_HASH_SEED QHOTKEY_EXPORT qHash(QHotkey::NativeShortcut key);
|
||||||
uint qHash(const QHotkey::NativeShortcut &key, uint seed);
|
QHOTKEY_HASH_SEED QHOTKEY_EXPORT qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed);
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(logQHotkey)
|
QHOTKEY_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey)
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QHotkey::NativeShortcut)
|
||||||
|
|
||||||
#endif // QHOTKEY_H
|
#endif // QHOTKEY_H
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
message(The pri file has been moved one directory up! use that one instead)
|
|
||||||
+62
-23
@@ -7,14 +7,15 @@ class QHotkeyPrivateMac : 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, _NATIVE_EVENT_RESULT *result) override;
|
||||||
|
|
||||||
static OSStatus hotkeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
|
static OSStatus hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
|
||||||
|
static OSStatus hotkeyReleaseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -24,20 +25,26 @@ private:
|
|||||||
};
|
};
|
||||||
NATIVE_INSTANCE(QHotkeyPrivateMac)
|
NATIVE_INSTANCE(QHotkeyPrivateMac)
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::isPlatformSupported()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
|
bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
|
||||||
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs;
|
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs;
|
||||||
|
|
||||||
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
|
||||||
{
|
{
|
||||||
Q_UNUSED(eventType);
|
Q_UNUSED(eventType)
|
||||||
Q_UNUSED(message);
|
Q_UNUSED(message)
|
||||||
Q_UNUSED(result);
|
Q_UNUSED(result)
|
||||||
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,13 +127,14 @@ 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;
|
||||||
|
|
||||||
CFDataRef currentLayoutData;
|
CFDataRef currentLayoutData;
|
||||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
TISInputSourceRef currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource();
|
||||||
|
|
||||||
if (currentKeyboard == NULL)
|
if (currentKeyboard == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -157,11 +165,17 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,7 +183,7 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
|
|||||||
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 +196,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,10 +204,15 @@ bool QHotkeyPrivateMac::registerShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
{
|
{
|
||||||
if (!this->isHotkeyHandlerRegistered)
|
if (!this->isHotkeyHandlerRegistered)
|
||||||
{
|
{
|
||||||
EventTypeSpec eventSpec;
|
EventTypeSpec pressEventSpec;
|
||||||
eventSpec.eventClass = kEventClassKeyboard;
|
pressEventSpec.eventClass = kEventClassKeyboard;
|
||||||
eventSpec.eventKind = kEventHotKeyPressed;
|
pressEventSpec.eventKind = kEventHotKeyPressed;
|
||||||
InstallApplicationEventHandler(&QHotkeyPrivateMac::hotkeyEventHandler, 1, &eventSpec, NULL, NULL);
|
InstallApplicationEventHandler(&QHotkeyPrivateMac::hotkeyPressEventHandler, 1, &pressEventSpec, NULL, NULL);
|
||||||
|
|
||||||
|
EventTypeSpec releaseEventSpec;
|
||||||
|
releaseEventSpec.eventClass = kEventClassKeyboard;
|
||||||
|
releaseEventSpec.eventKind = kEventHotKeyReleased;
|
||||||
|
InstallApplicationEventHandler(&QHotkeyPrivateMac::hotkeyReleaseEventHandler, 1, &releaseEventSpec, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHotKeyID hkeyID;
|
EventHotKeyID hkeyID;
|
||||||
@@ -207,8 +227,7 @@ bool QHotkeyPrivateMac::registerShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
0,
|
0,
|
||||||
&eventRef);
|
&eventRef);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
qCWarning(logQHotkey) << "Failed to register hotkey. Error:"
|
error = QString::number(status);
|
||||||
<< status;
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this->hotkeyRefs.insert(shortcut, eventRef);
|
this->hotkeyRefs.insert(shortcut, eventRef);
|
||||||
@@ -221,8 +240,7 @@ bool QHotkeyPrivateMac::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
EventHotKeyRef eventRef = QHotkeyPrivateMac::hotkeyRefs.value(shortcut);
|
EventHotKeyRef eventRef = QHotkeyPrivateMac::hotkeyRefs.value(shortcut);
|
||||||
OSStatus status = UnregisterEventHotKey(eventRef);
|
OSStatus status = UnregisterEventHotKey(eventRef);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:"
|
error = QString::number(status);
|
||||||
<< status;
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this->hotkeyRefs.remove(shortcut);
|
this->hotkeyRefs.remove(shortcut);
|
||||||
@@ -230,7 +248,7 @@ bool QHotkeyPrivateMac::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus QHotkeyPrivateMac::hotkeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
OSStatus QHotkeyPrivateMac::hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||||
{
|
{
|
||||||
Q_UNUSED(nextHandler);
|
Q_UNUSED(nextHandler);
|
||||||
Q_UNUSED(data);
|
Q_UNUSED(data);
|
||||||
@@ -250,3 +268,24 @@ OSStatus QHotkeyPrivateMac::hotkeyEventHandler(EventHandlerCallRef nextHandler,
|
|||||||
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSStatus QHotkeyPrivateMac::hotkeyReleaseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(nextHandler);
|
||||||
|
Q_UNUSED(data);
|
||||||
|
|
||||||
|
if (GetEventClass(event) == kEventClassKeyboard &&
|
||||||
|
GetEventKind(event) == kEventHotKeyReleased) {
|
||||||
|
EventHotKeyID hkeyID;
|
||||||
|
GetEventParameter(event,
|
||||||
|
kEventParamDirectObject,
|
||||||
|
typeEventHotKeyID,
|
||||||
|
NULL,
|
||||||
|
sizeof(EventHotKeyID),
|
||||||
|
NULL,
|
||||||
|
&hkeyID);
|
||||||
|
hotkeyPrivate->releaseShortcut({hkeyID.signature, hkeyID.id});
|
||||||
|
}
|
||||||
|
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|||||||
+15
-3
@@ -7,7 +7,13 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QGlobalStatic>
|
#include <QGlobalStatic>
|
||||||
|
|
||||||
class QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
#define _NATIVE_EVENT_RESULT qintptr
|
||||||
|
#else
|
||||||
|
#define _NATIVE_EVENT_RESULT long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QHOTKEY_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -16,6 +22,7 @@ public:
|
|||||||
~QHotkeyPrivate();
|
~QHotkeyPrivate();
|
||||||
|
|
||||||
static QHotkeyPrivate *instance();
|
static QHotkeyPrivate *instance();
|
||||||
|
static bool isPlatformSupported();
|
||||||
|
|
||||||
QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
||||||
|
|
||||||
@@ -24,16 +31,21 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void activateShortcut(QHotkey::NativeShortcut shortcut);
|
void activateShortcut(QHotkey::NativeShortcut shortcut);
|
||||||
|
void releaseShortcut(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
|
||||||
|
|
||||||
|
QString error;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QHash<QPair<Qt::Key, Qt::KeyboardModifiers>, QHotkey::NativeShortcut> mapping;
|
||||||
QMultiHash<QHotkey::NativeShortcut, QHotkey*> shortcuts;
|
QMultiHash<QHotkey::NativeShortcut, QHotkey*> shortcuts;
|
||||||
|
|
||||||
|
Q_INVOKABLE void addMappingInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers, 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 QHotkey::NativeShortcut nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
Q_INVOKABLE QHotkey::NativeShortcut nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
||||||
|
|||||||
+61
-17
@@ -1,44 +1,84 @@
|
|||||||
#include "qhotkey.h"
|
#include "qhotkey.h"
|
||||||
#include "qhotkey_p.h"
|
#include "qhotkey_p.h"
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QList>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#define HKEY_ID(nativeShortcut) (((nativeShortcut.key ^ (nativeShortcut.modifier << 8)) & 0x0FFF) | 0x7000)
|
#define HKEY_ID(nativeShortcut) (((nativeShortcut.key ^ (nativeShortcut.modifier << 8)) & 0x0FFF) | 0x7000)
|
||||||
|
|
||||||
|
#if !defined(MOD_NOREPEAT)
|
||||||
|
#define MOD_NOREPEAT 0x4000
|
||||||
|
#endif
|
||||||
|
|
||||||
class QHotkeyPrivateWin : public QHotkeyPrivate
|
class QHotkeyPrivateWin : public QHotkeyPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
QHotkeyPrivateWin();
|
||||||
// QAbstractNativeEventFilter interface
|
// QAbstractNativeEventFilter interface
|
||||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
|
bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void pollForHotkeyRelease();
|
||||||
// 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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString formatWinError(DWORD winError);
|
static QString formatWinError(DWORD winError);
|
||||||
|
QTimer pollTimer;
|
||||||
|
QList<QHotkey::NativeShortcut> polledShortcuts;
|
||||||
};
|
};
|
||||||
NATIVE_INSTANCE(QHotkeyPrivateWin)
|
NATIVE_INSTANCE(QHotkeyPrivateWin)
|
||||||
|
|
||||||
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
QHotkeyPrivateWin::QHotkeyPrivateWin(){
|
||||||
|
pollTimer.setInterval(50);
|
||||||
|
connect(&pollTimer, &QTimer::timeout, this, &QHotkeyPrivateWin::pollForHotkeyRelease);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::isPlatformSupported()
|
||||||
{
|
{
|
||||||
Q_UNUSED(eventType);
|
return true;
|
||||||
Q_UNUSED(result);
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
|
||||||
|
{
|
||||||
|
Q_UNUSED(eventType)
|
||||||
|
Q_UNUSED(result)
|
||||||
|
|
||||||
MSG* msg = static_cast<MSG*>(message);
|
MSG* msg = static_cast<MSG*>(message);
|
||||||
if(msg->message == WM_HOTKEY)
|
if(msg->message == WM_HOTKEY) {
|
||||||
this->activateShortcut({HIWORD(msg->lParam), LOWORD(msg->lParam)});
|
QHotkey::NativeShortcut shortcut = {HIWORD(msg->lParam), LOWORD(msg->lParam)};
|
||||||
|
this->activateShortcut(shortcut);
|
||||||
|
if (this->polledShortcuts.empty())
|
||||||
|
this->pollTimer.start();
|
||||||
|
this->polledShortcuts.append(shortcut);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode)
|
void QHotkeyPrivateWin::pollForHotkeyRelease()
|
||||||
{
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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(static_cast<WCHAR>(keycode));
|
||||||
if(vKey > -1)
|
if(vKey > -1)
|
||||||
return LOBYTE(vKey);
|
return LOBYTE(vKey);
|
||||||
}
|
}
|
||||||
@@ -201,11 +241,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 static_cast<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 +261,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,13 +269,12 @@ bool QHotkeyPrivateWin::registerShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
{
|
{
|
||||||
BOOL ok = RegisterHotKey(NULL,
|
BOOL ok = RegisterHotKey(NULL,
|
||||||
HKEY_ID(shortcut),
|
HKEY_ID(shortcut),
|
||||||
shortcut.modifier,
|
shortcut.modifier + MOD_NOREPEAT,
|
||||||
shortcut.key);
|
shortcut.key);
|
||||||
if(ok)
|
if(ok)
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
qCWarning(logQHotkey) << "Failed to register hotkey. Error:"
|
error = QHotkeyPrivateWin::formatWinError(::GetLastError());
|
||||||
<< qPrintable(QHotkeyPrivateWin::formatWinError(::GetLastError()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,8 +285,7 @@ bool QHotkeyPrivateWin::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
if(ok)
|
if(ok)
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:"
|
error = QHotkeyPrivateWin::formatWinError(::GetLastError());
|
||||||
<< qPrintable(QHotkeyPrivateWin::formatWinError(::GetLastError()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+125
-35
@@ -1,27 +1,42 @@
|
|||||||
#include "qhotkey.h"
|
#include "qhotkey.h"
|
||||||
#include "qhotkey_p.h"
|
#include "qhotkey_p.h"
|
||||||
#include <QDebug>
|
|
||||||
#include <QX11Info>
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#else
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QX11Info>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QThreadStorage>
|
#include <QThreadStorage>
|
||||||
|
#include <QTimer>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
//compatibility 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, _NATIVE_EVENT_RESULT *result) 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;
|
||||||
|
static QString getX11String(Qt::Key keycode);
|
||||||
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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QVector<quint32> specialModifiers;
|
static const QVector<quint32> specialModifiers;
|
||||||
static const quint32 validModsMask;
|
static const quint32 validModsMask;
|
||||||
|
xcb_key_press_event_t prevHandledEvent;
|
||||||
|
xcb_key_press_event_t prevEvent;
|
||||||
|
|
||||||
static QString formatX11Error(Display *display, int errorCode);
|
static QString formatX11Error(Display *display, int errorCode);
|
||||||
|
|
||||||
@@ -41,26 +56,72 @@ private:
|
|||||||
};
|
};
|
||||||
NATIVE_INSTANCE(QHotkeyPrivateX11)
|
NATIVE_INSTANCE(QHotkeyPrivateX11)
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::isPlatformSupported()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
return qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
#else
|
||||||
|
return QX11Info::isPlatformX11();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const QVector<quint32> QHotkeyPrivateX11::specialModifiers = {0, Mod2Mask, LockMask, (Mod2Mask | LockMask)};
|
const QVector<quint32> QHotkeyPrivateX11::specialModifiers = {0, Mod2Mask, LockMask, (Mod2Mask | LockMask)};
|
||||||
const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1Mask | Mod4Mask;
|
const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1Mask | Mod4Mask;
|
||||||
|
|
||||||
bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *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);
|
auto *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->prevEvent = keyEvent;
|
||||||
|
if (this->prevHandledEvent.response_type == XCB_KEY_RELEASE) {
|
||||||
|
if(this->prevHandledEvent.time == keyEvent.time) return false;
|
||||||
|
}
|
||||||
|
this->activateShortcut({keyEvent.detail, keyEvent.state & QHotkeyPrivateX11::validModsMask});
|
||||||
|
} else if (genericEvent->response_type == XCB_KEY_RELEASE) {
|
||||||
|
xcb_key_release_event_t keyEvent = *static_cast<xcb_key_release_event_t *>(message);
|
||||||
|
this->prevEvent = keyEvent;
|
||||||
|
QTimer::singleShot(50, [this, keyEvent] {
|
||||||
|
if(this->prevEvent.time == keyEvent.time && this->prevEvent.response_type == keyEvent.response_type && this->prevEvent.detail == keyEvent.detail){
|
||||||
|
this->releaseShortcut({keyEvent.detail, keyEvent.state & QHotkeyPrivateX11::validModsMask});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this->prevHandledEvent = keyEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
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){
|
||||||
|
|
||||||
|
case Qt::Key_MediaLast :
|
||||||
|
case Qt::Key_MediaPrevious :
|
||||||
|
return QStringLiteral("XF86AudioPrev");
|
||||||
|
case Qt::Key_MediaNext :
|
||||||
|
return QStringLiteral("XF86AudioNext");
|
||||||
|
case Qt::Key_MediaPause :
|
||||||
|
case Qt::Key_MediaPlay :
|
||||||
|
case Qt::Key_MediaTogglePlayPause :
|
||||||
|
return QStringLiteral("XF86AudioPlay");
|
||||||
|
case Qt::Key_MediaRecord :
|
||||||
|
return QStringLiteral("XF86AudioRecord");
|
||||||
|
case Qt::Key_MediaStop :
|
||||||
|
return QStringLiteral("XF86AudioStop");
|
||||||
|
default :
|
||||||
|
return QKeySequence(keycode).toString(QKeySequence::NativeText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||||
|
{
|
||||||
|
QString keyString = getX11String(keycode);
|
||||||
|
|
||||||
|
KeySym keysym = XStringToKeysym(keyString.toLatin1().constData());
|
||||||
if (keysym == NoSymbol) {
|
if (keysym == NoSymbol) {
|
||||||
//not found -> just use the key
|
//not found -> just use the key
|
||||||
if(keycode <= 0xFFFF)
|
if(keycode <= 0xFFFF)
|
||||||
@@ -69,14 +130,27 @@ quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Display *display = QX11Info::display();
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
if(display)
|
const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
return XKeysymToKeycode(QX11Info::display(), keysym);
|
#else
|
||||||
else
|
const bool x11Interface = QX11Info::isPlatformX11();
|
||||||
return 0;
|
#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;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||||
{
|
{
|
||||||
quint32 nMods = 0;
|
quint32 nMods = 0;
|
||||||
if (modifiers & Qt::ShiftModifier)
|
if (modifiers & Qt::ShiftModifier)
|
||||||
@@ -87,13 +161,21 @@ quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
|||||||
nMods |= Mod1Mask;
|
nMods |= Mod1Mask;
|
||||||
if (modifiers & Qt::MetaModifier)
|
if (modifiers & Qt::MetaModifier)
|
||||||
nMods |= Mod4Mask;
|
nMods |= Mod4Mask;
|
||||||
|
ok = true;
|
||||||
return nMods;
|
return nMods;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
|
bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
Display *display = x11Interface->display();
|
||||||
|
#else
|
||||||
|
const bool x11Interface = QX11Info::isPlatformX11();
|
||||||
Display *display = QX11Info::display();
|
Display *display = QX11Info::display();
|
||||||
if(!display)
|
#endif
|
||||||
|
|
||||||
|
if(!display || !x11Interface)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HotkeyErrorHandler errorHandler;
|
HotkeyErrorHandler errorHandler;
|
||||||
@@ -106,19 +188,24 @@ bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
GrabModeAsync,
|
GrabModeAsync,
|
||||||
GrabModeAsync);
|
GrabModeAsync);
|
||||||
}
|
}
|
||||||
|
XSync(display, False);
|
||||||
|
|
||||||
if(errorHandler.hasError) {
|
if(errorHandler.hasError) {
|
||||||
qCWarning(logQHotkey) << "Failed to register hotkey. Error:"
|
error = errorHandler.errorString;
|
||||||
<< qPrintable(errorHandler.errorString);
|
|
||||||
this->unregisterShortcut(shortcut);
|
this->unregisterShortcut(shortcut);
|
||||||
return false;
|
return false;
|
||||||
} else
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
Display *display = qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->display();
|
||||||
|
#else
|
||||||
Display *display = QX11Info::display();
|
Display *display = QX11Info::display();
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!display)
|
if(!display)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -127,16 +214,15 @@ bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
|||||||
XUngrabKey(display,
|
XUngrabKey(display,
|
||||||
shortcut.key,
|
shortcut.key,
|
||||||
shortcut.modifier | specialMod,
|
shortcut.modifier | specialMod,
|
||||||
DefaultRootWindow(display));
|
XDefaultRootWindow(display));
|
||||||
}
|
}
|
||||||
|
XSync(display, False);
|
||||||
|
|
||||||
if(errorHandler.hasError) {
|
if(HotkeyErrorHandler::hasError) {
|
||||||
qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:"
|
error = HotkeyErrorHandler::errorString;
|
||||||
<< qPrintable(errorHandler.errorString);
|
|
||||||
this->unregisterShortcut(shortcut);
|
|
||||||
return false;
|
return false;
|
||||||
} else
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QHotkeyPrivateX11::formatX11Error(Display *display, int errorCode)
|
QString QHotkeyPrivateX11::formatX11Error(Display *display, int errorCode)
|
||||||
@@ -155,12 +241,14 @@ 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)
|
||||||
@@ -171,10 +259,12 @@ int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorE
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
Q_FALLTHROUGH();
|
||||||
|
// fall through
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,45 @@ The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka
|
|||||||
- 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
|
- Allows usage of native keycodes and modifiers, if needed
|
||||||
|
|
||||||
## Installation
|
**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).
|
||||||
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))
|
## Building
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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_DEFAULT_MAJOR_VERSION=6
|
||||||
|
$ cmake --build build
|
||||||
|
# cmake --install build
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
### Via qpmx
|
||||||
|
[qpmx](https://github.com/Skycoder42/qpmx) is a frontend for qpm (and other tools) with additional features, and is the preferred way to install packages. To use it:
|
||||||
|
|
||||||
|
1. Install qpmx (See [GitHub - Installation](https://github.com/Skycoder42/qpmx#installation))
|
||||||
|
2. Install qpm (See [GitHub - Installing](https://github.com/Cutehacks/qpm/blob/master/README.md#installing), for **windows** see below)
|
||||||
|
3. In your projects root directory, run `qpmx install de.skycoder42.qhotkey`
|
||||||
|
|
||||||
|
### Via qpm
|
||||||
|
|
||||||
|
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`
|
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
|
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.
|
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
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -33,17 +63,17 @@ The following example shows a simple application that will run without a window
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QHotkey hotkey(QKeySequence("ctrl+alt+Q"), true);//The hotkey will be automatically registered
|
QHotkey hotkey(QKeySequence("Ctrl+Alt+Q"), true, &app); //The hotkey will be automatically registered
|
||||||
qDebug() << "Is Registered: " << hotkey.isRegistered();
|
qDebug() << "Is registered:" << hotkey.isRegistered();
|
||||||
|
|
||||||
QObject::connect(&hotkey, &QHotkey::activated, qApp, [&](){
|
QObject::connect(&hotkey, &QHotkey::activated, qApp, [&](){
|
||||||
qDebug() << "Hotkey Activated - the application will quit now";
|
qDebug() << "Hotkey Activated - the application will quit now";
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
return a.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -53,18 +83,18 @@ int main(int argc, char *argv[])
|
|||||||
By running the example in `./HotkeyTest` you can test out the QHotkey class. There are 4 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 separate threads. It should work without a difference.
|
||||||
- **Native Shortcut**: Allows you to try out the direct usage of native shortcuts
|
- **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 following function somewhere in your code:
|
||||||
```cpp
|
```cpp
|
||||||
QLoggingCategory::setFilterRules(QStringLiteral("QHotkey.warning=false"));
|
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
|
## Thread safety
|
||||||
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.
|
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`.
|
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`.
|
||||||
|
|
||||||
@@ -77,7 +107,7 @@ The documentation was created using [doxygen](http://www.doxygen.org). It includ
|
|||||||
|
|
||||||
## Technical
|
## Technical
|
||||||
### Requirements
|
### Requirements
|
||||||
- I built it with Qt 5.7, but may work with earlier versions, too
|
- Explicit support is only given down to the latest Qt LTS, 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). You can however create a gui application without any visible window.
|
- 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
|
||||||
|
|
||||||
@@ -86,3 +116,4 @@ The documentation was created using [doxygen](http://www.doxygen.org). It includ
|
|||||||
- 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.
|
- 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. I can use need such a key, try using the 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. 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
|
||||||
|
|||||||
+111
-91
@@ -1,4 +1,4 @@
|
|||||||
# Doxyfile 1.8.12
|
# Doxyfile 1.8.14
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
# This tag specifies the encoding used for all characters in the config file
|
# This tag specifies the encoding used for all characters in the config file
|
||||||
# that follow. The default is UTF-8 which is also the encoding used for all text
|
# that follow. The default is UTF-8 which is also the encoding used for all text
|
||||||
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
|
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
|
||||||
# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
|
# built into libc) for the transcoding. See
|
||||||
# for the list of possible encodings.
|
# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
|
||||||
# The default value is: UTF-8.
|
# The default value is: UTF-8.
|
||||||
|
|
||||||
DOXYFILE_ENCODING = UTF-8
|
DOXYFILE_ENCODING = UTF-8
|
||||||
@@ -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.1.0
|
PROJECT_NUMBER = 1.2.2
|
||||||
|
|
||||||
# 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
|
||||||
@@ -58,7 +58,7 @@ PROJECT_LOGO =
|
|||||||
# entered, it will be relative to the location where doxygen was started. If
|
# entered, it will be relative to the location where doxygen was started. If
|
||||||
# left blank the current directory will be used.
|
# left blank the current directory will be used.
|
||||||
|
|
||||||
OUTPUT_DIRECTORY = ../../QHotkey_doc_generated
|
OUTPUT_DIRECTORY = /tmp/qthotkeydoc
|
||||||
|
|
||||||
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
||||||
# directories (in 2 levels) under the output directory of each output format and
|
# directories (in 2 levels) under the output directory of each output format and
|
||||||
@@ -236,7 +236,8 @@ TAB_SIZE = 4
|
|||||||
# will allow you to put the command \sideeffect (or @sideeffect) in the
|
# will allow you to put the command \sideeffect (or @sideeffect) in the
|
||||||
# documentation, which will result in a user-defined paragraph with heading
|
# documentation, which will result in a user-defined paragraph with heading
|
||||||
# "Side Effects:". You can put \n's in the value part of an alias to insert
|
# "Side Effects:". You can put \n's in the value part of an alias to insert
|
||||||
# newlines.
|
# newlines (in the resulting output). You can put ^^ in the value part of an
|
||||||
|
# alias to insert a newline as if a physical newline was in the original file.
|
||||||
|
|
||||||
ALIASES = "accessors{1}=<table><tr><th colspan= 2>Accessors</th></tr>\1</table>" \
|
ALIASES = "accessors{1}=<table><tr><th colspan= 2>Accessors</th></tr>\1</table>" \
|
||||||
readAc{1}=<tr><td><b>READ</b></td><td>\1</td></tr> \
|
readAc{1}=<tr><td><b>READ</b></td><td>\1</td></tr> \
|
||||||
@@ -252,10 +253,13 @@ ALIASES = "accessors{1}=<table><tr><th colspan= 2>Accessors</th><
|
|||||||
"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> \
|
"readAcFn{1}=READ accessor for \1" \
|
||||||
ovElem{1}=<li>\1</li> \
|
"writeAcFn{1}=WRITE accessor for \1" \
|
||||||
"overload=<i>This is an overloaded function.</i>" \
|
"notifyAcFn{1}=NOTIFY accessor for \1" \
|
||||||
"povElem{1}=<li>\1 <i>(primary, check for more details)</i></li>"
|
"resetAcFn{1}=RESET accessor for \1" \
|
||||||
|
"memberAcFn{1}=MEMBER accessor for \1" \
|
||||||
|
"inherit{1}=Inherits \1" \
|
||||||
|
"privsig=<i>This is a private signal. It can be connect to as usual, but can only be emitted by the class it belongs to</i>"
|
||||||
|
|
||||||
# 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"
|
||||||
@@ -354,7 +358,7 @@ BUILTIN_STL_SUPPORT = NO
|
|||||||
CPP_CLI_SUPPORT = NO
|
CPP_CLI_SUPPORT = NO
|
||||||
|
|
||||||
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
|
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
|
||||||
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
|
# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
|
||||||
# will parse them like normal C++ but will assume all classes use public instead
|
# will parse them like normal C++ but will assume all classes use public instead
|
||||||
# of private inheritance when no explicit protection keyword is present.
|
# of private inheritance when no explicit protection keyword is present.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
@@ -725,7 +729,7 @@ LAYOUT_FILE =
|
|||||||
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
|
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
|
||||||
# the reference definitions. This must be a list of .bib files. The .bib
|
# the reference definitions. This must be a list of .bib files. The .bib
|
||||||
# extension is automatically appended if omitted. This requires the bibtex tool
|
# extension is automatically appended if omitted. This requires the bibtex tool
|
||||||
# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
|
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
|
||||||
# For LaTeX the style of the bibliography can be controlled using
|
# For LaTeX the style of the bibliography can be controlled using
|
||||||
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
|
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
|
||||||
# search path. See also \cite for info how to create references.
|
# search path. See also \cite for info how to create references.
|
||||||
@@ -773,7 +777,7 @@ WARN_IF_DOC_ERROR = YES
|
|||||||
# parameter documentation, but not about the absence of documentation.
|
# parameter documentation, but not about the absence of documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
WARN_NO_PARAMDOC = YES
|
WARN_NO_PARAMDOC = NO
|
||||||
|
|
||||||
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
|
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
|
||||||
# a warning is encountered.
|
# a warning is encountered.
|
||||||
@@ -814,7 +818,7 @@ INPUT = ../QHotkey/qhotkey.h \
|
|||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
|
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
|
||||||
# documentation (see: http://www.gnu.org/software/libiconv) for the list of
|
# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
|
||||||
# possible encodings.
|
# possible encodings.
|
||||||
# The default value is: UTF-8.
|
# The default value is: UTF-8.
|
||||||
|
|
||||||
@@ -921,12 +925,21 @@ 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 = QBasicAtomicInteger \
|
EXCLUDE_SYMBOLS = QAbstractAspect \
|
||||||
|
QBasicAtomicInteger \
|
||||||
QBasicAtomicPointer \
|
QBasicAtomicPointer \
|
||||||
|
QBasicMutex \
|
||||||
|
QComponent \
|
||||||
|
QEntity \
|
||||||
QFutureWatcherBase \
|
QFutureWatcherBase \
|
||||||
QListSpecialMethods \
|
QGeometry \
|
||||||
|
QGeometryRenderer \
|
||||||
|
QMaterial \
|
||||||
|
QNode \
|
||||||
|
QNodeCreatedChangeBase \
|
||||||
QPaintEngineEx \
|
QPaintEngineEx \
|
||||||
QQmlExtensionInterface
|
QQmlExtensionInterface \
|
||||||
|
QTechniqueFilter
|
||||||
|
|
||||||
# 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
|
||||||
@@ -1069,7 +1082,7 @@ SOURCE_TOOLTIPS = YES
|
|||||||
# If the USE_HTAGS tag is set to YES then the references to source code will
|
# If the USE_HTAGS tag is set to YES then the references to source code will
|
||||||
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
|
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
|
||||||
# source browser. The htags tool is part of GNU's global source tagging system
|
# source browser. The htags tool is part of GNU's global source tagging system
|
||||||
# (see http://www.gnu.org/software/global/global.html). You will need version
|
# (see https://www.gnu.org/software/global/global.html). You will need version
|
||||||
# 4.8.6 or higher.
|
# 4.8.6 or higher.
|
||||||
#
|
#
|
||||||
# To use it do the following:
|
# To use it do the following:
|
||||||
@@ -1096,25 +1109,6 @@ USE_HTAGS = NO
|
|||||||
|
|
||||||
VERBATIM_HEADERS = YES
|
VERBATIM_HEADERS = YES
|
||||||
|
|
||||||
# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
|
|
||||||
# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
|
|
||||||
# cost of reduced performance. This can be particularly helpful with template
|
|
||||||
# rich C++ code for which doxygen's built-in parser lacks the necessary type
|
|
||||||
# information.
|
|
||||||
# Note: The availability of this option depends on whether or not doxygen was
|
|
||||||
# generated with the -Duse-libclang=ON option for CMake.
|
|
||||||
# The default value is: NO.
|
|
||||||
|
|
||||||
CLANG_ASSISTED_PARSING = NO
|
|
||||||
|
|
||||||
# If clang assisted parsing is enabled you can provide the compiler with command
|
|
||||||
# line options that you would normally use when invoking the compiler. Note that
|
|
||||||
# the include paths will already be set by doxygen for the files and directories
|
|
||||||
# specified with INPUT and INCLUDE_PATH.
|
|
||||||
# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
|
|
||||||
|
|
||||||
CLANG_OPTIONS =
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options related to the alphabetical class index
|
# Configuration options related to the alphabetical class index
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
@@ -1233,7 +1227,7 @@ HTML_EXTRA_FILES =
|
|||||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||||
# will adjust the colors in the style sheet and background images according to
|
# will adjust the colors in the style sheet and background images according to
|
||||||
# this color. Hue is specified as an angle on a colorwheel, see
|
# this color. Hue is specified as an angle on a colorwheel, see
|
||||||
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
|
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
|
||||||
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
|
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
|
||||||
# purple, and 360 is red again.
|
# purple, and 360 is red again.
|
||||||
# Minimum value: 0, maximum value: 359, default value: 220.
|
# Minimum value: 0, maximum value: 359, default value: 220.
|
||||||
@@ -1269,6 +1263,17 @@ HTML_COLORSTYLE_GAMMA = 89
|
|||||||
|
|
||||||
HTML_TIMESTAMP = YES
|
HTML_TIMESTAMP = YES
|
||||||
|
|
||||||
|
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
||||||
|
# documentation will contain a main index with vertical navigation menus that
|
||||||
|
# are dynamically created via Javascript. If disabled, the navigation index will
|
||||||
|
# consists of multiple levels of tabs that are statically embedded in every HTML
|
||||||
|
# page. Disable this option to support browsers that do not have Javascript,
|
||||||
|
# like the Qt help browser.
|
||||||
|
# The default value is: YES.
|
||||||
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
|
HTML_DYNAMIC_MENUS = YES
|
||||||
|
|
||||||
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
|
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
|
||||||
# documentation will contain sections that can be hidden and shown after the
|
# documentation will contain sections that can be hidden and shown after the
|
||||||
# page has loaded.
|
# page has loaded.
|
||||||
@@ -1292,12 +1297,12 @@ HTML_INDEX_NUM_ENTRIES = 100
|
|||||||
|
|
||||||
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
|
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
|
||||||
# generated that can be used as input for Apple's Xcode 3 integrated development
|
# generated that can be used as input for Apple's Xcode 3 integrated development
|
||||||
# environment (see: http://developer.apple.com/tools/xcode/), introduced with
|
# environment (see: https://developer.apple.com/tools/xcode/), introduced with
|
||||||
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
|
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
|
||||||
# Makefile in the HTML output directory. Running make will produce the docset in
|
# Makefile in the HTML output directory. Running make will produce the docset in
|
||||||
# that directory and running make install will install the docset in
|
# that directory and running make install will install the docset in
|
||||||
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
|
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
|
||||||
# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
|
# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html
|
||||||
# for more information.
|
# for more information.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
@@ -1413,40 +1418,37 @@ QCH_FILE = QHotkeyHelp.qch
|
|||||||
|
|
||||||
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
|
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
|
||||||
# Project output. For more information please see Qt Help Project / Namespace
|
# Project output. For more information please see Qt Help Project / Namespace
|
||||||
# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
|
# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace).
|
||||||
# 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.Skycoder42.QHotkey.110
|
QHP_NAMESPACE = de.skycoder42.QHotkey.122
|
||||||
|
|
||||||
# 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
|
||||||
# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
|
# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders).
|
||||||
# folders).
|
|
||||||
# The default value is: doc.
|
# The default value is: doc.
|
||||||
# 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_VIRTUAL_FOLDER = doc_QHotkey
|
QHP_VIRTUAL_FOLDER = doc_qhotkey
|
||||||
|
|
||||||
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
|
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
|
||||||
# filter to add. For more information please see Qt Help Project / Custom
|
# filter to add. For more information please see Qt Help Project / Custom
|
||||||
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
|
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
|
||||||
# filters).
|
|
||||||
# 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_CUST_FILTER_NAME =
|
QHP_CUST_FILTER_NAME = "QHotkey 1.2.2"
|
||||||
|
|
||||||
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
|
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
|
||||||
# custom filter to add. For more information please see Qt Help Project / Custom
|
# custom filter to add. For more information please see Qt Help Project / Custom
|
||||||
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
|
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
|
||||||
# filters).
|
|
||||||
# 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_CUST_FILTER_ATTRS =
|
QHP_CUST_FILTER_ATTRS = "qhotkey 1.2.2"
|
||||||
|
|
||||||
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
|
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
|
||||||
# project's filter section matches. Qt Help Project / Filter Attributes (see:
|
# project's filter section matches. Qt Help Project / Filter Attributes (see:
|
||||||
# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
|
# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes).
|
||||||
# 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_SECT_FILTER_ATTRS =
|
QHP_SECT_FILTER_ATTRS =
|
||||||
@@ -1456,7 +1458,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.7/msvc2015_64/bin/qhelpgenerator.exe
|
QHG_LOCATION = /usr/bin/qhelpgenerator
|
||||||
|
|
||||||
# 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
|
||||||
@@ -1539,7 +1541,7 @@ EXT_LINKS_IN_WINDOW = YES
|
|||||||
|
|
||||||
FORMULA_FONTSIZE = 10
|
FORMULA_FONTSIZE = 10
|
||||||
|
|
||||||
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
|
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
|
||||||
# generated for formulas are transparent PNGs. Transparent PNGs are not
|
# generated for formulas are transparent PNGs. Transparent PNGs are not
|
||||||
# supported properly for IE 6.0, but are supported on all modern browsers.
|
# supported properly for IE 6.0, but are supported on all modern browsers.
|
||||||
#
|
#
|
||||||
@@ -1551,7 +1553,7 @@ FORMULA_FONTSIZE = 10
|
|||||||
FORMULA_TRANSPARENT = YES
|
FORMULA_TRANSPARENT = YES
|
||||||
|
|
||||||
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
|
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
|
||||||
# http://www.mathjax.org) which uses client side Javascript for the rendering
|
# https://www.mathjax.org) which uses client side Javascript for the rendering
|
||||||
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
|
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
|
||||||
# installed or if you want to formulas look prettier in the HTML output. When
|
# installed or if you want to formulas look prettier in the HTML output. When
|
||||||
# enabled you may also need to install MathJax separately and configure the path
|
# enabled you may also need to install MathJax separately and configure the path
|
||||||
@@ -1578,8 +1580,8 @@ MATHJAX_FORMAT = HTML-CSS
|
|||||||
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
|
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
|
||||||
# Content Delivery Network so you can quickly see the result without installing
|
# Content Delivery Network so you can quickly see the result without installing
|
||||||
# MathJax. However, it is strongly recommended to install a local copy of
|
# MathJax. However, it is strongly recommended to install a local copy of
|
||||||
# MathJax from http://www.mathjax.org before deployment.
|
# MathJax from https://www.mathjax.org before deployment.
|
||||||
# The default value is: http://cdn.mathjax.org/mathjax/latest.
|
# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/.
|
||||||
# This tag requires that the tag USE_MATHJAX is set to YES.
|
# This tag requires that the tag USE_MATHJAX is set to YES.
|
||||||
|
|
||||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||||
@@ -1640,7 +1642,7 @@ SERVER_BASED_SEARCH = NO
|
|||||||
#
|
#
|
||||||
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
||||||
# (doxysearch.cgi) which are based on the open source search engine library
|
# (doxysearch.cgi) which are based on the open source search engine library
|
||||||
# Xapian (see: http://xapian.org/).
|
# Xapian (see: https://xapian.org/).
|
||||||
#
|
#
|
||||||
# See the section "External Indexing and Searching" for details.
|
# See the section "External Indexing and Searching" for details.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
@@ -1653,7 +1655,7 @@ EXTERNAL_SEARCH = NO
|
|||||||
#
|
#
|
||||||
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
||||||
# (doxysearch.cgi) which are based on the open source search engine library
|
# (doxysearch.cgi) which are based on the open source search engine library
|
||||||
# Xapian (see: http://xapian.org/). See the section "External Indexing and
|
# Xapian (see: https://xapian.org/). See the section "External Indexing and
|
||||||
# Searching" for details.
|
# Searching" for details.
|
||||||
# This tag requires that the tag SEARCHENGINE is set to YES.
|
# This tag requires that the tag SEARCHENGINE is set to YES.
|
||||||
|
|
||||||
@@ -1840,7 +1842,7 @@ LATEX_SOURCE_CODE = NO
|
|||||||
|
|
||||||
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
||||||
# bibliography, e.g. plainnat, or ieeetr. See
|
# bibliography, e.g. plainnat, or ieeetr. See
|
||||||
# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||||
# The default value is: plain.
|
# The default value is: plain.
|
||||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||||
|
|
||||||
@@ -2023,9 +2025,9 @@ DOCBOOK_PROGRAMLISTING = NO
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
|
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
|
||||||
# AutoGen Definitions (see http://autogen.sf.net) file that captures the
|
# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
|
||||||
# structure of the code including all documentation. Note that this feature is
|
# the structure of the code including all documentation. Note that this feature
|
||||||
# still experimental and incomplete at the moment.
|
# is still experimental and incomplete at the moment.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
GENERATE_AUTOGEN_DEF = NO
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
@@ -2107,7 +2109,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.7/msvc2015_64/include
|
INCLUDE_PATH = /usr/include/qt
|
||||||
|
|
||||||
# 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
|
||||||
@@ -2127,7 +2129,7 @@ INCLUDE_FILE_PATTERNS = *.h \
|
|||||||
# recursively expanded use the := operator instead of the = operator.
|
# recursively expanded use the := operator instead of the = operator.
|
||||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||||
|
|
||||||
PREDEFINED =
|
PREDEFINED = __cplusplus=201402L
|
||||||
|
|
||||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||||
# tag can be used to specify a list of macro names that should be expanded. The
|
# tag can be used to specify a list of macro names that should be expanded. The
|
||||||
@@ -2165,37 +2167,50 @@ 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.7/qtwebengine/qtwebengine.tags=http://doc.qt.io/qt-5 \
|
TAGFILES = "/home/sky/Qt/Docs/Qt-5.10.1/qdoc/qdoc.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtgraphicaleffects/qtgraphicaleffects.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtlabsplatform/qtlabsplatform.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtwebchannel/qtwebchannel.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtqml/qtqml.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtwebsockets/qtwebsockets.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtprintsupport/qtprintsupport.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtbluetooth/qtbluetooth.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qttestlib/qttestlib.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtnfc/qtnfc.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtsensors/qtsensors.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtlabscalendar/qtlabscalendar.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtlocation/qtlocation.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtdatasync/qtdatasync.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtpositioning/qtpositioning.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtwebchannel/qtwebchannel.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/activeqt/activeqt.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtpositioning/qtpositioning.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtquickcontrols/qtquickcontrols.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtrestclient/qtrestclient.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtqml/qtqml.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtquick/qtquick.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtnfc/qtnfc.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtxmlpatterns/qtxmlpatterns.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtquickcontrols/qtquickcontrols.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtsvg/qtsvg.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtwidgets/qtwidgets.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qdoc/qdoc.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtgraphicaleffects/qtgraphicaleffects.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtprintsupport/qtprintsupport.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtlocation/qtlocation.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtconcurrent/qtconcurrent.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtgui/qtgui.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtgui/qtgui.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtwebengine/qtwebengine.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qttestlib/qttestlib.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtnetwork/qtnetwork.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtwidgets/qtwidgets.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtxml/qtxml.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtcore/qtcore.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtscxml/qtscxml.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtnetwork/qtnetwork.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/activeqt/activeqt.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtsql/qtsql.tags=http://doc.qt.io/qt-5 \
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtjsonserializer/qtjsonserializer.tags=https://doc.qt.io/qt-5" \
|
||||||
C:/Qt/Docs/Qt-5.7/qtxml/qtxml.tags=http://doc.qt.io/qt-5
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtsensors/qtsensors.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtnetworkauth/qtnetworkauth.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtxmlpatterns/qtxmlpatterns.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtspeech/qtspeech.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtsvg/qtsvg.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtserialbus/qtserialbus.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtbluetooth/qtbluetooth.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtsql/qtsql.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtwebsockets/qtwebsockets.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtquick/qtquick.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qt3d/qt3d.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtquickcontrols2/qtquickcontrols2.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtremoteobjects/qtremoteobjects.tags=https://doc.qt.io/qt-5" \
|
||||||
|
"/home/sky/Qt/Docs/Qt-5.10.1/qtconcurrent/qtconcurrent.tags=https://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
|
||||||
# external documentation" for more information about the usage of tag files.
|
# external documentation" for more information about the usage of tag files.
|
||||||
|
|
||||||
GENERATE_TAGFILE = ../../QHotkey_doc_generated/QHotkey.tag
|
GENERATE_TAGFILE = /tmp/qthotkeydoc/QHotkey.tag
|
||||||
|
|
||||||
# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
|
# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
|
||||||
# the class index. If set to NO, only the inherited external classes will be
|
# the class index. If set to NO, only the inherited external classes will be
|
||||||
@@ -2473,6 +2488,11 @@ DIAFILE_DIRS =
|
|||||||
|
|
||||||
PLANTUML_JAR_PATH =
|
PLANTUML_JAR_PATH =
|
||||||
|
|
||||||
|
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
|
||||||
|
# configuration file for plantuml.
|
||||||
|
|
||||||
|
PLANTUML_CFG_FILE =
|
||||||
|
|
||||||
# When using plantuml, the specified paths are searched for files specified by
|
# When using plantuml, the specified paths are searched for files specified by
|
||||||
# the !include statement in a plantuml block.
|
# the !include statement in a plantuml block.
|
||||||
|
|
||||||
+31
-47
@@ -22,9 +22,9 @@ thread until the applications eventloop has the time to handle it. If the loop i
|
|||||||
it does. This does not happen if used from the main thread.
|
it does. This does not happen if used from the main thread.
|
||||||
|
|
||||||
@accessors{
|
@accessors{
|
||||||
@readAc{isRegistered()}
|
@readAc{isRegistered()}
|
||||||
@writeAc{setRegistered()}
|
@writeAc{setRegistered()}
|
||||||
@notifyAc{registeredChanged()}
|
@notifyAc{registeredChanged()}
|
||||||
}
|
}
|
||||||
|
|
||||||
In addition to the normal accessors, a modification of the QHotkey::shortcut property can change this property, too.
|
In addition to the normal accessors, a modification of the QHotkey::shortcut property can change this property, too.
|
||||||
@@ -38,7 +38,7 @@ In addition to the normal accessors, a modification of the QHotkey::shortcut pro
|
|||||||
@default{`QKeySequence()` (`Qt::Key_unknown` + `Qt::NoModifier`)}
|
@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
|
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.
|
the hotkey.
|
||||||
|
|
||||||
@note Since the operating systems do not support hotkeys that consist of multiple key-combinations in a sequence,
|
@note Since the operating systems do not support hotkeys that consist of multiple key-combinations in a sequence,
|
||||||
@@ -49,15 +49,15 @@ thread until the applications eventloop has the time to handle it. If the loop i
|
|||||||
it does. This does not happen if used from the main thread.
|
it does. This does not happen if used from the main thread.
|
||||||
|
|
||||||
@accessors{
|
@accessors{
|
||||||
@readAc{
|
@readAc{
|
||||||
<b>shortcut()</b><br/>
|
<b>shortcut()</b><br/>
|
||||||
keyCode()<br/>
|
keyCode()<br/>
|
||||||
modifiers()
|
modifiers()
|
||||||
}
|
}
|
||||||
@writeAc{
|
@writeAc{
|
||||||
<b>setShortcut(const QKeySequence &, bool)</b><br/>
|
<b>setShortcut(const QKeySequence &, bool)</b><br/>
|
||||||
setShortcut(Qt::Key, Qt::KeyboardModifiers, bool)
|
setShortcut(Qt::Key, Qt::KeyboardModifiers, bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@sa QHotkey::registered, QHotkey::isKeyCaptured, QHotkey::currentNativeShortcut, QHotkey::setNativeShortcut
|
@sa QHotkey::registered, QHotkey::isKeyCaptured, QHotkey::currentNativeShortcut, QHotkey::setNativeShortcut
|
||||||
@@ -66,71 +66,39 @@ it does. This does not happen if used from the main thread.
|
|||||||
/*!
|
/*!
|
||||||
@fn QHotkey::QHotkey(QObject *)
|
@fn QHotkey::QHotkey(QObject *)
|
||||||
|
|
||||||
@overload
|
|
||||||
@param parent The parent object
|
@param parent The parent object
|
||||||
|
|
||||||
@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 *)}
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@fn QHotkey::QHotkey(const QKeySequence &, bool, QObject *)
|
@fn QHotkey::QHotkey(const QKeySequence &, bool, QObject *)
|
||||||
|
|
||||||
@overload
|
|
||||||
@param parent The parent object
|
@param parent The parent object
|
||||||
@param shortcut The shortcut this hotkey should be registered for
|
@param shortcut The shortcut this hotkey should be registered for
|
||||||
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
|
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
|
||||||
|
|
||||||
@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::shortcut, QHotkey::registered
|
@sa QHotkey::shortcut, QHotkey::registered
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@fn QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)
|
@fn QHotkey::QHotkey(Qt::Key, Qt::KeyboardModifiers, bool, QObject *)
|
||||||
|
|
||||||
@overload
|
|
||||||
@param parent The parent object
|
@param parent The parent object
|
||||||
@param key The key this hotkey should be registered for
|
@param keyCode The key this hotkey should be registered for
|
||||||
@param modifiers The modifiers that have to be pressed together with the `key`
|
@param modifiers The modifiers that have to be pressed together with the `key`
|
||||||
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
|
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
|
||||||
|
|
||||||
@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::shortcut, QHotkey::registered
|
@sa QHotkey::shortcut, QHotkey::registered
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@fn QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)
|
@fn QHotkey::QHotkey(const NativeShortcut &, bool, QObject *)
|
||||||
|
|
||||||
@overload
|
|
||||||
@param parent The parent object
|
@param parent The parent object
|
||||||
@param shortcut The native shortcut this hotkey should be registered for
|
@param shortcut The native shortcut this hotkey should be registered for
|
||||||
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
|
@param autoRegister Specifies, whether the hotkey should be automatically registered or not
|
||||||
|
|
||||||
@note Please check QHotkey::setNativeShortcut for important hints!
|
@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
|
@sa QHotkey::setNativeShortcut, QHotkey::registered
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -139,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.
|
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.
|
Otherwise your application will hang up.
|
||||||
|
|
||||||
@sa QHotkey::registered
|
@sa QHotkey::registered
|
||||||
@@ -168,6 +136,22 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@fn QHotkey::addGlobalMapping
|
||||||
|
|
||||||
|
@param shortcut The keysequence to add the mapping for
|
||||||
|
@param nativeShortcut The native shortcut to overwrite the sequence with
|
||||||
|
|
||||||
|
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 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.
|
||||||
|
|
||||||
|
The advantage of using this approach via simply registering it as native key directly, is that
|
||||||
|
these mappings work for cases where users input their own hotkeys.
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@class QHotkey::NativeShortcut
|
@class QHotkey::NativeShortcut
|
||||||
|
|
||||||
|
|||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
CONFIG += C++11
|
|
||||||
|
|
||||||
HEADERS += $$PWD/QHotkey/qhotkey.h \
|
|
||||||
$$PWD/QHotkey/qhotkey_p.h
|
|
||||||
|
|
||||||
SOURCES += $$PWD/QHotkey/qhotkey.cpp
|
|
||||||
|
|
||||||
mac {
|
|
||||||
SOURCES += $$PWD/QHotkey/qhotkey_mac.cpp
|
|
||||||
LIBS += -framework Carbon
|
|
||||||
} else:win32 {
|
|
||||||
SOURCES += $$PWD/QHotkey/qhotkey_win.cpp
|
|
||||||
LIBS += -luser32
|
|
||||||
} else:unix {
|
|
||||||
SOURCES += $$PWD/QHotkey/qhotkey_x11.cpp
|
|
||||||
QT += x11extras
|
|
||||||
LIBS += -lX11
|
|
||||||
}
|
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/QHotkey
|
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "de.skycoder42.qhotkey",
|
"author": {
|
||||||
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
|
"email": "skycoder42.de@gmx.de",
|
||||||
"author": {
|
"name": "Skycoder"
|
||||||
"name": "Skycoder",
|
},
|
||||||
"email": "skycoder42.de@gmx.de"
|
"dependencies": [
|
||||||
},
|
],
|
||||||
"repository": {
|
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
|
||||||
"type": "GITHUB",
|
"license": "BSD_3_CLAUSE",
|
||||||
"url": "https://github.com/Skycoder42/QHotkey.git"
|
"name": "de.skycoder42.qhotkey",
|
||||||
},
|
"pri_filename": "qhotkey.pri",
|
||||||
"version": {
|
"repository": {
|
||||||
"label": "1.1.2",
|
"type": "GITHUB",
|
||||||
"revision": "",
|
"url": "https://github.com/Skycoder42/QHotkey.git"
|
||||||
"fingerprint": ""
|
},
|
||||||
},
|
"version": {
|
||||||
"dependencies": [
|
"fingerprint": "",
|
||||||
],
|
"label": "1.2.2",
|
||||||
"license": "BSD_3_CLAUSE",
|
"revision": ""
|
||||||
"pri_filename": "qhotkey.pri",
|
},
|
||||||
"webpage": "https://github.com/Skycoder42/QHotkey"
|
"webpage": "https://github.com/Skycoder42/QHotkey"
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user