From 5246f618a7efb74bf5f11b395702880f010b8268 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 6 Mar 2023 12:26:38 +0100 Subject: [PATCH] qskIsButtonPressKey moved to QskEvent.h, Qt5 build break fixed --- src/controls/QskAbstractButton.cpp | 32 ++-------------------------- src/controls/QskComboBox.cpp | 30 +------------------------- src/controls/QskEvent.cpp | 34 ++++++++++++++++++++++++++++++ src/controls/QskEvent.h | 1 + 4 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/controls/QskAbstractButton.cpp b/src/controls/QskAbstractButton.cpp index 5655961d..51af683b 100644 --- a/src/controls/QskAbstractButton.cpp +++ b/src/controls/QskAbstractButton.cpp @@ -10,37 +10,9 @@ #include -QSK_QT_PRIVATE_BEGIN -#include -QSK_QT_PRIVATE_END - -#include - QSK_SYSTEM_STATE( QskAbstractButton, Checked, QskAspect::LastSystemState >> 3 ) QSK_SYSTEM_STATE( QskAbstractButton, Pressed, QskAspect::LastSystemState >> 2 ) -#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) - -static inline QList< Qt::Key > qskButtonPressKeys() -{ - const auto hint = QGuiApplicationPrivate::platformTheme()->themeHint( - QPlatformTheme::ButtonPressKeys ); - - return hint.value< QList< Qt::Key > >(); -} - -#else - -static inline QList< Qt::Key > qskButtonPressKeys() -{ - static const QList< Qt::Key > keys = - { Qt::Key_Space, Qt::Key_Enter, Qt::Key_Return, Qt::Key_Select }; - - return keys; -} - -#endif - static QskAbstractButton* qskCheckedSibling( const QskAbstractButton * button ) { const auto parentItem = button->parentItem(); @@ -292,7 +264,7 @@ bool QskAbstractButton::event( QEvent* event ) void QskAbstractButton::keyPressEvent( QKeyEvent* event ) { - if ( qskButtonPressKeys().contains( event->key() ) ) + if ( qskIsButtonPressKey( event ) ) { if ( !event->isAutoRepeat() ) setPressed( true ); @@ -306,7 +278,7 @@ void QskAbstractButton::keyPressEvent( QKeyEvent* event ) void QskAbstractButton::keyReleaseEvent( QKeyEvent* event ) { - if ( qskButtonPressKeys().contains( event->key() ) ) + if ( qskIsButtonPressKey( event ) ) { releaseButton(); return; diff --git a/src/controls/QskComboBox.cpp b/src/controls/QskComboBox.cpp index 5aa79cac..4bc501ec 100644 --- a/src/controls/QskComboBox.cpp +++ b/src/controls/QskComboBox.cpp @@ -12,12 +12,6 @@ #include -QSK_QT_PRIVATE_BEGIN -#include -QSK_QT_PRIVATE_END - -#include - QSK_SUBCONTROL( QskComboBox, Panel ) QSK_SUBCONTROL( QskComboBox, Graphic ) QSK_SUBCONTROL( QskComboBox, Text ) @@ -26,28 +20,6 @@ QSK_SUBCONTROL( QskComboBox, Splash ) QSK_SYSTEM_STATE( QskComboBox, PopupOpen, QskAspect::FirstSystemState << 1 ) -#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) - -static inline QList< Qt::Key > qskButtonPressKeys() -{ - const auto hint = QGuiApplicationPrivate::platformTheme()->themeHint( - QPlatformTheme::ButtonPressKeys ); - - return hint.value< QList< Qt::Key > >(); -} - -#else - -static inline QList< Qt::Key > qskButtonPressKeys() -{ - static const QList< Qt::Key > keys = - { Qt::Key_Space, Qt::Key_Enter, Qt::Key_Return, Qt::Key_Select }; - - return keys; -} - -#endif - class QskComboBox::PrivateData { public: @@ -212,7 +184,7 @@ void QskComboBox::mouseReleaseEvent( QMouseEvent* ) void QskComboBox::keyPressEvent( QKeyEvent* event ) { - if ( qskButtonPressKeys().contains( event->key() ) ) + if ( qskIsButtonPressKey( event ) ) { if ( !event->isAutoRepeat() ) { diff --git a/src/controls/QskEvent.cpp b/src/controls/QskEvent.cpp index cd84b5f4..3d9b1995 100644 --- a/src/controls/QskEvent.cpp +++ b/src/controls/QskEvent.cpp @@ -8,6 +8,15 @@ #include +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) + + QSK_QT_PRIVATE_BEGIN + #include + QSK_QT_PRIVATE_END + + #include +#endif + static void qskRegisterEventTypes() { // We don't ask QEvent::registerEventType for unique ids as it prevents @@ -125,6 +134,31 @@ bool qskIsStandardKeyInput( const QKeyEvent* event, QKeySequence::StandardKey ke #endif } +bool qskIsButtonPressKey( const QKeyEvent* event ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) + + const auto hint = QGuiApplicationPrivate::platformTheme()->themeHint( + QPlatformTheme::ButtonPressKeys ); + + const auto keys = hint.value< QList< Qt::Key > >(); + return keys.contains( static_cast< Qt::Key >( event->key() ) ); + +#else + + switch( event->key() ) + { + case Qt::Key_Space: + case Qt::Key_Enter: + case Qt::Key_Return: + case Qt::Key_Select: + return true; + } + + return false; +#endif +} + QskEvent::QskEvent( QskEvent::Type type ) : QEvent( static_cast< QEvent::Type >( type ) ) { diff --git a/src/controls/QskEvent.h b/src/controls/QskEvent.h index 355614e8..d26b812c 100644 --- a/src/controls/QskEvent.h +++ b/src/controls/QskEvent.h @@ -176,5 +176,6 @@ QSK_EXPORT qreal qskWheelIncrement( const QWheelEvent* ); #endif QSK_EXPORT bool qskIsStandardKeyInput( const QKeyEvent*, QKeySequence::StandardKey ); +QSK_EXPORT bool qskIsButtonPressKey( const QKeyEvent* ); #endif