Compare commits

..

2 Commits

Author SHA1 Message Date
jessequ 4c5141caa0 modified README.md 2025-08-29 16:59:45 +08:00
jessequ b975eb5af2 modified README.md 2025-08-29 16:42:13 +08:00
4 changed files with 13 additions and 15 deletions

View File

@ -28,5 +28,3 @@ include(cmake/library.cmake)
include(cmake/platform.cmake)
include(cmake/qt.cmake)
include(cmake/pkg-config.cmake)
add_subdirectory(example)

View File

@ -8,9 +8,9 @@ This code was originally part of [Qtx](https://bitbucket.org/libqxt/libqxt/wiki/
# Supported Platforms
- Windows
- OS X
- Linux/X11
- Windows     (由于环境原因,还没有尝试)
- OS X           (由于采用的技术过时了,已经试过了,不好用)
- Linux/X11    (试过了,好用的)
# Requirements

View File

@ -1,7 +1,11 @@
cmake_minimum_required(VERSION 2.8.8)
project(qxtglobalshortcut_test)
find_package(qxtglobalshortcut REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
include_directories(${PROJECT_BINARY_DIR}/exports)
set(bin qxtglobalshortcut_test)
add_executable(${bin} src/main.cpp)
add_executable(qxtglobalshortcut_test src/main.cpp)
target_link_libraries(qxtglobalshortcut_test qxtglobalshortcut Qt6::Widgets)
target_link_libraries(${bin} qxtglobalshortcut)
target_link_libraries(${bin} Qt6::Widgets)

View File

@ -34,7 +34,6 @@
#include <QHash>
#include <QtDebug>
#include <QApplication>
#include <QTextStream>
using Identifier = QPair<uint, uint>;
static QMap<quint32, EventHotKeyRef> keyRefs;
@ -44,9 +43,6 @@ static bool qxt_mac_handler_installed = false;
OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data)
{
QTextStream out(stdout);
out << QLatin1String("Shortcut maybe pressed!") << Qt::endl;
Q_UNUSED(nextHandler);
Q_UNUSED(data);
if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
@ -363,7 +359,7 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ
EventTypeSpec t;
t.eventClass = kEventClassKeyboard;
t.eventKind = kEventHotKeyPressed;
// InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, nullptr, nullptr);
InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, nullptr, nullptr);
}
EventHotKeyID keyID;
@ -371,7 +367,7 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ
keyID.id = ++hotKeySerial;
EventHotKeyRef ref = 0;
bool rv = true; // = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref);
bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref);
if (rv)
{
keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id);