mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-01-17 04:32:04 +01:00
Add win shortcut base
This commit is contained in:
@@ -147,7 +147,6 @@ win32: {
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
nativeeventfilter-x11.cpp \
|
||||
nativeeventfilterbase.cpp \
|
||||
shortcut.cpp \
|
||||
systrayxlink.cpp \
|
||||
@@ -159,6 +158,7 @@ SOURCES += \
|
||||
windowctrl.cpp
|
||||
unix: {
|
||||
SOURCES += \
|
||||
nativeeventfilter-x11.cpp \
|
||||
windowctrl-unix.cpp
|
||||
contains(DEFINES,KDE_INTEGRATION) {
|
||||
SOURCES += \
|
||||
@@ -167,12 +167,12 @@ SOURCES += \
|
||||
}
|
||||
win32: {
|
||||
SOURCES += \
|
||||
nativeeventfilter-win.cpp \
|
||||
windowctrl-win.cpp
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
debug.h \
|
||||
nativeeventfilter-x11.h \
|
||||
nativeeventfilterbase.h \
|
||||
shortcut.h \
|
||||
systrayxlink.h \
|
||||
@@ -184,6 +184,7 @@ HEADERS += \
|
||||
windowctrl.h
|
||||
unix: {
|
||||
HEADERS += \
|
||||
nativeeventfilter-x11.h \
|
||||
windowctrl-unix.h
|
||||
|
||||
contains(DEFINES,KDE_INTEGRATION) {
|
||||
@@ -193,6 +194,7 @@ HEADERS += \
|
||||
}
|
||||
win32: {
|
||||
HEADERS += \
|
||||
nativeeventfilter-win.h \
|
||||
windowctrl-win.h
|
||||
}
|
||||
|
||||
|
||||
58
app/SysTray-X/SysTray-X-app/nativeeventfilter-win.cpp
Normal file
58
app/SysTray-X/SysTray-X-app/nativeeventfilter-win.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "nativeeventfilter-win.h"
|
||||
|
||||
|
||||
/*
|
||||
* System includes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Qt includes
|
||||
*/
|
||||
#include <QKeySequence>
|
||||
|
||||
|
||||
/*
|
||||
* Catch the key press
|
||||
*/
|
||||
bool NativeEventFilterWin::nativeEventFilter( const QByteArray& eventType, void* message, long* result )
|
||||
{
|
||||
Q_UNUSED( eventType )
|
||||
Q_UNUSED( message )
|
||||
Q_UNUSED( result )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Connect the shortcut key
|
||||
*/
|
||||
bool NativeEventFilterWin::connectShortcut( QKeySequence key_seq )
|
||||
{
|
||||
Qt::Key key_code = Qt::Key( key_seq[ 0 ] & static_cast< int >( ~Qt::KeyboardModifierMask ) );
|
||||
Qt::KeyboardModifiers key_modifiers = Qt::KeyboardModifiers( key_seq[ 0 ] & static_cast<int>( Qt::KeyboardModifierMask ) );
|
||||
|
||||
return connectShortcut( key_code, key_modifiers );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Connect the shortcut key
|
||||
*/
|
||||
bool NativeEventFilterWin::connectShortcut( Qt::Key key_code, Qt::KeyboardModifiers key_modifiers )
|
||||
{
|
||||
// Set windows callback
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Disconnect the shortcut key
|
||||
*/
|
||||
bool NativeEventFilterWin::disconnectShortcut()
|
||||
{
|
||||
// Remove windows callback
|
||||
|
||||
return true;
|
||||
}
|
||||
80
app/SysTray-X/SysTray-X-app/nativeeventfilter-win.h
Normal file
80
app/SysTray-X/SysTray-X-app/nativeeventfilter-win.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef NATIVEEVENTFILTERWIN_H
|
||||
#define NATIVEEVENTFILTERWIN_H
|
||||
|
||||
/*
|
||||
* Local includes
|
||||
*/
|
||||
#include "nativeeventfilterbase.h"
|
||||
|
||||
/*
|
||||
* System includes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Qt includes
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief The NativeEventFilterWin class
|
||||
*/
|
||||
class NativeEventFilterWin : public NativeEventFilterBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief nativeEventFilter. Set the native event filter to catch the key press.
|
||||
*
|
||||
* @param eventType Event type to handle.
|
||||
* @param message Message to handle.
|
||||
* @param result Result to handle.
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
bool nativeEventFilter( const QByteArray& eventType, void* message, long* result ) override;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief connectShortcut. Connect the shortcut to the system.
|
||||
*
|
||||
* @param key_seq Key sequence to connect.
|
||||
*
|
||||
* @return Succeeded?
|
||||
*/
|
||||
bool connectShortcut( QKeySequence key_seq );
|
||||
|
||||
/**
|
||||
* @brief connectShortcut. Connect the shortcut to the system.
|
||||
*
|
||||
* @param key_code Qt key code to connect.
|
||||
* @param key_modifiers Qt key modifiers to connect.
|
||||
*
|
||||
* @return Succeeded?
|
||||
*/
|
||||
bool connectShortcut( Qt::Key key_code, Qt::KeyboardModifiers key_modifiers );
|
||||
|
||||
/**
|
||||
* @brief disconnectShortcut. Disconnect the shortcut.
|
||||
*
|
||||
* @return Succeeded?
|
||||
*/
|
||||
bool disconnectShortcut();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief m_key_modifiers_win. Storage for the X11 key modifiers.
|
||||
*/
|
||||
int m_key_modifiers_win;
|
||||
|
||||
/**
|
||||
* @brief m_key_code_win. Storage for the X11 key code.
|
||||
*/
|
||||
int m_key_code_win;
|
||||
|
||||
};
|
||||
|
||||
SINGLETON( NativeEventFilterWin )
|
||||
|
||||
#endif // NATIVEEVENTFILTERWIN_H
|
||||
Reference in New Issue
Block a user