Fix shortcuts

This commit is contained in:
Ximi1970
2024-03-31 23:50:52 +02:00
parent d296660b9f
commit 809a36caff
7 changed files with 35 additions and 48 deletions

View File

@@ -19,7 +19,7 @@ include( ../SysTray-X.pri )
#
# Set the Qt modules
#
QT += core gui
QT += core gui widgets
unix:!macx: {
contains(DEFINES,KDE_INTEGRATION) {
lessThan(QT_MAJOR_VERSION, 6): {
@@ -37,8 +37,6 @@ unix:!macx: {
}
}
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
#
# Define the target
#
@@ -161,74 +159,54 @@ win32: {
SOURCES += \
debugwidget.cpp \
main.cpp \
nativeeventfilterbase.cpp \
systrayxlink.cpp \
systrayxicon.cpp \
systrayx.cpp \
debugwidget.cpp \
preferencesdialog.cpp \
preferences.cpp \
windowctrl.cpp
lessThan(QT_MAJOR_VERSION, 6): {
SOURCES += \
shortcut.cpp \
nativeeventfilterbase.cpp
}
windowctrl.cpp
unix: {
SOURCES += \
windowctrl-unix.cpp
nativeeventfilter-x11.cpp \
windowctrl-unix.cpp
contains(DEFINES,KDE_INTEGRATION) {
SOURCES += \
systrayxstatusnotifier.cpp
}
lessThan(QT_MAJOR_VERSION, 6): {
SOURCES += \
nativeeventfilter-x11.cpp
}
}
win32: {
SOURCES += \
nativeeventfilter-win.cpp
windowctrl-win.cpp
lessThan(QT_MAJOR_VERSION, 6): {
SOURCES += \
nativeeventfilter-win.cpp
}
}
HEADERS += \
debug.h \
debugwidget.h \
nativeeventfilterbase.h \
preferencesdialog.h \
preferences.h \
systrayxlink.h \
systrayxicon.h \
systrayx.h \
debugwidget.h \
preferencesdialog.h \
preferences.h \
windowctrl.h
lessThan(QT_MAJOR_VERSION, 6): {
HEADERS += \
shortcut.h \
nativeeventfilterbase.h
}
windowctrl.h
unix: {
HEADERS += \
nativeeventfilter-x11.h \
windowctrl-unix.h
contains(DEFINES,KDE_INTEGRATION) {
HEADERS += \
systrayxstatusnotifier.h
}
lessThan(QT_MAJOR_VERSION, 6): {
HEADERS += \
nativeeventfilter-x11.h
}
}
win32: {
HEADERS += \

View File

@@ -24,7 +24,12 @@ const int NativeEventFilterX11::m_valid_mods_mask = ShiftMask | ControlMask | Mo
/*
* Catch the key press
*/
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool NativeEventFilterX11::nativeEventFilter( const QByteArray& eventType, void* message, long* result )
#else
bool NativeEventFilterX11::nativeEventFilter( const QByteArray& eventType, void* message, qintptr* result )
#endif
{
Q_UNUSED( eventType )
Q_UNUSED( result )
@@ -50,8 +55,8 @@ bool NativeEventFilterX11::nativeEventFilter( const QByteArray& eventType, void*
*/
bool NativeEventFilterX11::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 ) );
Qt::Key key_code = Qt::Key( key_seq[ 0 ].toCombined() & static_cast< int >( ~Qt::KeyboardModifierMask ) );
Qt::KeyboardModifiers key_modifiers = Qt::KeyboardModifiers( key_seq[ 0 ].toCombined() & static_cast<int>( Qt::KeyboardModifierMask ) );
return connectShortcut( key_code, key_modifiers );
}
@@ -132,7 +137,8 @@ bool NativeEventFilterX11::connectShortcut( Qt::Key key_code, Qt::KeyboardModifi
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Display *display = QX11Info::display();
#else
Display *display = 0;
QNativeInterface::QX11Application *x11App = qApp->nativeInterface<QNativeInterface::QX11Application>();
Display *display = x11App->display();
#endif
/*
@@ -162,7 +168,8 @@ bool NativeEventFilterX11::disconnectShortcut()
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Display *display = QX11Info::display();
#else
Display *display = 0;
QNativeInterface::QX11Application *x11App = qApp->nativeInterface<QNativeInterface::QX11Application>();
Display *display = x11App->display();
#endif
/*

View File

@@ -33,7 +33,11 @@ class NativeEventFilterX11 : public NativeEventFilterBase
*
* @return Result
*/
bool nativeEventFilter( const QByteArray& eventType, void* message, long* result ) override;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter( const QByteArray& eventType, void* message, long* result ) override;
#else
bool nativeEventFilter( const QByteArray& eventType, void* message, qintptr* result ) override;
#endif
protected:

View File

@@ -12,7 +12,6 @@
/*
* Qt includes
*/
#include <QCoreApplication>
#include <QAbstractEventDispatcher>

View File

@@ -15,6 +15,7 @@
#include <QObject>
#include <QAbstractNativeEventFilter>
#include <QGlobalStatic>
#include <QGuiApplication>
/*
* Predefines

View File

@@ -49,8 +49,8 @@ Shortcut::~Shortcut()
*/
bool Shortcut::setShortcut( QKeySequence key_seq )
{
Qt::Key key_code = Qt::Key( key_seq[ 0 ] & ~Qt::KeyboardModifierMask );
Qt::KeyboardModifiers key_modifiers = Qt::KeyboardModifiers( key_seq[ 0 ] & Qt::KeyboardModifierMask);
Qt::Key key_code = Qt::Key( key_seq[ 0 ].toCombined() & ~Qt::KeyboardModifierMask );
Qt::KeyboardModifiers key_modifiers = Qt::KeyboardModifiers( key_seq[ 0 ].toCombined() & Qt::KeyboardModifierMask);
return setShortcut( key_code, key_modifiers );
}

View File

@@ -9,7 +9,7 @@
#include "systrayxicon.h"
#include "systrayxstatusnotifier.h"
#include "windowctrl.h"
//#include "shortcut.h"
#include "shortcut.h"
/*
* Qt includes
@@ -194,7 +194,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
m_preferences->displayDebug();
/*
m_preferences->setBrowserVersion( "115.1.0" );
// m_preferences->setBrowserVersion( "102.2.3" );
@@ -215,7 +215,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
// m_preferences->setStartApp( "/home/maxime/test.sh" );
// m_preferences->setStartAppArgs( "/home/maxime/startup.txt StartupString" );
// slotStartApp();
*/
}
@@ -784,7 +784,6 @@ void SysTrayX::slotCloseApp()
void SysTrayX::slotShowHideShortcutChange()
{
#ifdef ENABLE_SHORTCUT
if( m_show_hide_shortcut != nullptr )
{
disconnect( m_show_hide_shortcut, &Shortcut::activated, m_win_ctrl, &WindowCtrl::slotShowHide );
@@ -795,5 +794,4 @@ void SysTrayX::slotShowHideShortcutChange()
m_show_hide_shortcut = new Shortcut( m_preferences->getShowHideShortcut(), this );
connect( m_show_hide_shortcut, &Shortcut::activated, m_win_ctrl, &WindowCtrl::slotShowHide );
#endif
}