From 68009a7d4334b7923dd777af086c234bec7acf98 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 13 Mar 2017 14:05:12 +0100 Subject: QTabletEvent manual test: show keyboard modifiers Task-number: QTBUG-59415 Change-Id: Ibb7ebc29797712535d82c6eb02c78dc28ad4131d Reviewed-by: Andy Shaw --- .../qtabletevent/device_information/tabletwidget.cpp | 20 ++++++++++++++++++++ .../qtabletevent/device_information/tabletwidget.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'tests/manual') diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index b4273bde8e..3a0b1e0f21 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -68,6 +68,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mRot = event->rotation(); mButton = event->button(); mButtons = event->buttons(); + mModifiers = event->modifiers(); mTimestamp = event->timestamp(); if (isVisible()) update(); @@ -172,6 +173,7 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16); eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16); + eventInfo << QString("Keyboard modifiers: %1 (0x%2)").arg(modifiersToString(mModifiers)).arg(mModifiers, 0, 16); eventInfo << QString("Pressure: %1").arg(QString::number(mPress)); eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential)); eventInfo << QString("Rotation: %1").arg(QString::number(mRot)); @@ -205,6 +207,24 @@ QString TabletWidget::buttonsToString(Qt::MouseButtons bs) return ret.join(QLatin1Char('|')); } +QString TabletWidget::modifiersToString(Qt::KeyboardModifiers m) +{ + QStringList ret; + if (m & Qt::ShiftModifier) + ret << QLatin1String("Shift"); + if (m & Qt::ControlModifier) + ret << QLatin1String("Control"); + if (m & Qt::AltModifier) + ret << QLatin1String("Alt"); + if (m & Qt::MetaModifier) + ret << QLatin1String("Meta"); + if (m & Qt::KeypadModifier) + ret << QLatin1String("Keypad"); + if (m & Qt::GroupSwitchModifier) + ret << QLatin1String("GroupSwitch"); + return ret.join(QLatin1Char('|')); +} + void TabletWidget::tabletEvent(QTabletEvent *event) { event->accept(); diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 2b014a213a..0d27c2eea0 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -43,6 +43,7 @@ protected: void paintEvent(QPaintEvent *event); const char *buttonToString(Qt::MouseButton b); QString buttonsToString(Qt::MouseButtons bs); + QString modifiersToString(Qt::KeyboardModifiers m); private: void resetAttributes() { mType = mDev = mPointerType = mXT = mYT = mZ = 0; @@ -57,6 +58,7 @@ private: int mDev, mPointerType, mXT, mYT, mZ; Qt::MouseButton mButton; Qt::MouseButtons mButtons; + Qt::KeyboardModifiers mModifiers; qreal mPress, mTangential, mRot; qint64 mUnique; bool mMouseToo; -- cgit v1.2.3 From 35c8a21fe49a06dca6287be82ec4608d35ea794c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 13 Mar 2017 14:05:50 +0100 Subject: QTabletEvent manual test: add quit shortcut Change-Id: I73012ec2d02856e5bbbc27d269f89b3918dd7c2d Reviewed-by: Andy Shaw --- tests/manual/qtabletevent/device_information/tabletwidget.cpp | 3 ++- tests/manual/qtabletevent/device_information/tabletwidget.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index 3a0b1e0f21..14d059abc1 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -33,7 +33,7 @@ #include #include -TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0) +TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0), mQuitShortcut(QKeySequence::Quit, this) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); @@ -41,6 +41,7 @@ TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCoun setPalette(newPalette); qApp->installEventFilter(this); resetAttributes(); + connect(&mQuitShortcut, SIGNAL(activated()), qApp, SLOT(quit())); } bool TabletWidget::eventFilter(QObject *, QEvent *ev) diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 0d27c2eea0..404be1289f 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -31,6 +31,7 @@ #include #include +#include // a widget showing the information of the last tablet event class TabletWidget : public QWidget @@ -64,6 +65,7 @@ private: bool mMouseToo; ulong mTimestamp; int mWheelEventCount; + QShortcut mQuitShortcut; }; #endif // TABLETWIDGET_H -- cgit v1.2.3