QTabletEvent manual test: show keyboard modifiers
Task-number: QTBUG-59415 Change-Id: Ibb7ebc29797712535d82c6eb02c78dc28ad4131d Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
550d7930d1
commit
68009a7d43
@ -68,6 +68,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
|
|||||||
mRot = event->rotation();
|
mRot = event->rotation();
|
||||||
mButton = event->button();
|
mButton = event->button();
|
||||||
mButtons = event->buttons();
|
mButtons = event->buttons();
|
||||||
|
mModifiers = event->modifiers();
|
||||||
mTimestamp = event->timestamp();
|
mTimestamp = event->timestamp();
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
update();
|
update();
|
||||||
@ -172,6 +173,7 @@ void TabletWidget::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16);
|
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("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("Pressure: %1").arg(QString::number(mPress));
|
||||||
eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential));
|
eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential));
|
||||||
eventInfo << QString("Rotation: %1").arg(QString::number(mRot));
|
eventInfo << QString("Rotation: %1").arg(QString::number(mRot));
|
||||||
@ -205,6 +207,24 @@ QString TabletWidget::buttonsToString(Qt::MouseButtons bs)
|
|||||||
return ret.join(QLatin1Char('|'));
|
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)
|
void TabletWidget::tabletEvent(QTabletEvent *event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
@ -43,6 +43,7 @@ protected:
|
|||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
const char *buttonToString(Qt::MouseButton b);
|
const char *buttonToString(Qt::MouseButton b);
|
||||||
QString buttonsToString(Qt::MouseButtons bs);
|
QString buttonsToString(Qt::MouseButtons bs);
|
||||||
|
QString modifiersToString(Qt::KeyboardModifiers m);
|
||||||
private:
|
private:
|
||||||
void resetAttributes() {
|
void resetAttributes() {
|
||||||
mType = mDev = mPointerType = mXT = mYT = mZ = 0;
|
mType = mDev = mPointerType = mXT = mYT = mZ = 0;
|
||||||
@ -57,6 +58,7 @@ private:
|
|||||||
int mDev, mPointerType, mXT, mYT, mZ;
|
int mDev, mPointerType, mXT, mYT, mZ;
|
||||||
Qt::MouseButton mButton;
|
Qt::MouseButton mButton;
|
||||||
Qt::MouseButtons mButtons;
|
Qt::MouseButtons mButtons;
|
||||||
|
Qt::KeyboardModifiers mModifiers;
|
||||||
qreal mPress, mTangential, mRot;
|
qreal mPress, mTangential, mRot;
|
||||||
qint64 mUnique;
|
qint64 mUnique;
|
||||||
bool mMouseToo;
|
bool mMouseToo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user