diff --git a/src/controls/QskBoundedInput.cpp b/src/controls/QskBoundedInput.cpp index 26aac2e6..02d88313 100644 --- a/src/controls/QskBoundedInput.cpp +++ b/src/controls/QskBoundedInput.cpp @@ -181,13 +181,15 @@ void QskBoundedInput::keyPressEvent( QKeyEvent* event ) { if ( !isReadOnly() ) { - if ( event->key() == Qt::Key_Up || event->matches( QKeySequence::MoveToNextChar ) ) + if ( event->key() == Qt::Key_Up || + qskKeyMatches( event, QKeySequence::MoveToNextChar ) ) { increment( m_stepSize ); return; } - if ( event->key() == Qt::Key_Down || event->matches( QKeySequence::MoveToPreviousChar ) ) + if ( event->key() == Qt::Key_Down || + qskKeyMatches( event, QKeySequence::MoveToPreviousChar ) ) { increment( -m_stepSize ); return; diff --git a/src/controls/QskEvent.cpp b/src/controls/QskEvent.cpp index 84d16d8b..85965d70 100644 --- a/src/controls/QskEvent.cpp +++ b/src/controls/QskEvent.cpp @@ -114,6 +114,21 @@ qreal qskWheelIncrement( const QWheelEvent* event ) #endif +bool qskKeyMatches( const QKeyEvent* event, QKeySequence::StandardKey key ) +{ +#if 1 + return event->matches( key ); +#else + constexpr auto mask = ~(Qt::KeypadModifier | Qt::GroupSwitchModifier); + + // We should route this call through the skin. TODO + const auto theme = QGuiApplicationPrivate::platformTheme(); + const auto bindings = theme->keyBindings( ( event->modifiers() | event->key() ) & mask ); + + return bindings.contains( QKeySequence(searchkey) ); +#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 51efd964..d0db70a3 100644 --- a/src/controls/QskEvent.h +++ b/src/controls/QskEvent.h @@ -10,6 +10,7 @@ #include #include +#include #include class QskGesture; @@ -20,6 +21,7 @@ class QQuickItem; class QMouseEvent; class QWheelEvent; class QHoverEvent; +class QKeyEvent; class QSK_EXPORT QskEvent : public QEvent { @@ -148,4 +150,6 @@ QSK_EXPORT qreal qskWheelIncrement( const QWheelEvent* ); #endif +QSK_EXPORT bool qskKeyMatches( const QKeyEvent*, QKeySequence::StandardKey ); + #endif diff --git a/src/controls/QskPageIndicator.cpp b/src/controls/QskPageIndicator.cpp index 3b9a8071..750b5cb2 100644 --- a/src/controls/QskPageIndicator.cpp +++ b/src/controls/QskPageIndicator.cpp @@ -15,10 +15,10 @@ QSK_SYSTEM_STATE( QskPageIndicator, Selected, QskAspect::FirstSystemState << 1 ) static int qskKeyIncrement( const QskPageIndicator* indicator, const QKeyEvent* event ) { - if ( event->matches( QKeySequence::MoveToNextChar ) ) + if ( qskKeyMatches( event, QKeySequence::MoveToNextChar ) ) return 1; - if ( event->matches( QKeySequence::MoveToPreviousChar ) ) + if ( qskKeyMatches( event, QKeySequence::MoveToPreviousChar ) ) return -1; const auto key = event->key(); diff --git a/src/dialogs/QskDialogSubWindow.cpp b/src/dialogs/QskDialogSubWindow.cpp index 3113c226..23c86e00 100644 --- a/src/dialogs/QskDialogSubWindow.cpp +++ b/src/dialogs/QskDialogSubWindow.cpp @@ -7,6 +7,7 @@ #include "QskDialogButtonBox.h" #include "QskPushButton.h" #include "QskQuick.h" +#include "QskEvent.h" #include #include @@ -280,7 +281,7 @@ void QskDialogSubWindow::keyPressEvent( QKeyEvent* event ) button->click(); } - if ( event->matches( QKeySequence::Cancel ) ) + if ( qskKeyMatches( event, QKeySequence::Cancel ) ) { // using shortcuts instead ??? diff --git a/src/dialogs/QskDialogWindow.cpp b/src/dialogs/QskDialogWindow.cpp index 6eb40646..5a726192 100644 --- a/src/dialogs/QskDialogWindow.cpp +++ b/src/dialogs/QskDialogWindow.cpp @@ -8,6 +8,7 @@ #include "QskLinearBox.h" #include "QskPushButton.h" #include "QskQuick.h" +#include "QskEvent.h" #include #include @@ -248,7 +249,7 @@ void QskDialogWindow::keyPressEvent( QKeyEvent* event ) button->click(); } - if ( event->matches( QKeySequence::Cancel ) ) + if ( qskKeyMatches( event, QKeySequence::Cancel ) ) { // using shortcuts instead ???