mirror of
https://github.com/Skycoder42/QHotkey.git
synced 2026-11-19 12:49:58 +03:00
Add compatibility with QT_NO_KEYWORDS macro (#104)
The Qt documentation recommends[1] not using Qt keywords in the public API of Qt libraries, specially the 'signals' and 'slots' Qt keywords. Without this, client applications that are compiled with the 'QT_NO_KEYWORDS'[2] macro (or that are compiled in conjunction with other libraries that also defines the same Qt keywords) will fail to build. The 'QT_NO_SIGNALS_SLOTS_KEYWORDS'[1] macro assures that the library is not using 'signals' and 'slots' Qt keywords, since it will fail to build when they are used. Useful for code sanity and for avoiding future pull requests that may try to use these Qt keywords. [1] https://doc.qt.io/qt-6/signalsandslots.html#signals-and-slots-in-qt-based-libraries [2] https://doc.qt.io/qt-6/qtglobal.html#QT_NO_KEYWORDS
This commit is contained in:
@@ -41,6 +41,8 @@ add_library(qhotkey QHotkey/qhotkey.cpp)
|
|||||||
add_library(QHotkey::QHotkey ALIAS qhotkey)
|
add_library(QHotkey::QHotkey ALIAS qhotkey)
|
||||||
target_link_libraries(qhotkey PUBLIC Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
|
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)
|
if(BUILD_SHARED_LIBS)
|
||||||
target_compile_definitions(qhotkey PRIVATE QHOTKEY_LIBRARY)
|
target_compile_definitions(qhotkey PRIVATE QHOTKEY_LIBRARY)
|
||||||
target_compile_definitions(qhotkey PUBLIC QHOTKEY_SHARED)
|
target_compile_definitions(qhotkey PUBLIC QHOTKEY_SHARED)
|
||||||
|
|||||||
+2
-2
@@ -88,7 +88,7 @@ public:
|
|||||||
//! Get the current native shortcut
|
//! Get the current native shortcut
|
||||||
NativeShortcut currentNativeShortcut() const;
|
NativeShortcut currentNativeShortcut() const;
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
//! @writeAcFn{QHotkey::registered}
|
//! @writeAcFn{QHotkey::registered}
|
||||||
bool setRegistered(bool registered);
|
bool setRegistered(bool registered);
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public slots:
|
|||||||
//! Set this hotkey to a native shortcut
|
//! Set this hotkey to a native shortcut
|
||||||
bool setNativeShortcut(QHotkey::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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user