summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.cpp78
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.h14
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp14
-rw-r--r--tests/manual/touch/main.cpp2
-rw-r--r--tests/manual/touchGraphicsItem/main.cpp20
5 files changed, 62 insertions, 66 deletions
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
index e146175109..18ea50c854 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite module of the Qt Toolkit.
@@ -58,8 +58,13 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mPos = event->pos();
mGPos = event->globalPos();
mHiResGlobalPos = event->posF();
- mDev = event->deviceType();
- mPointerType = event->pointerType();
+ if (event->pointingDevice()) {
+ mDev = event->pointingDevice()->type();
+ mPointerType = event->pointingDevice()->pointerType();
+ mCaps = event->pointingDevice()->capabilities();
+ } else {
+ qWarning() << "missing device in tablet event";
+ }
mUnique = event->uniqueId();
mXT = event->xTilt();
mYT = event->yTilt();
@@ -132,46 +137,9 @@ void TabletWidget::paintEvent(QPaintEvent *)
eventInfo << QString("High res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y()));
- QString pointerType("Pointer type: ");
- switch (mPointerType) {
- case QTabletEvent::UnknownPointer:
- pointerType += "QTabletEvent::UnknownPointer";
- break;
- case QTabletEvent::Pen:
- pointerType += "QTabletEvent::Pen";
- break;
- case QTabletEvent::Cursor:
- pointerType += "QTabletEvent::Cursor";
- break;
- case QTabletEvent::Eraser:
- pointerType += "QTabletEvent::Eraser";
- break;
- }
- eventInfo << pointerType;
-
- QString deviceString = "Device type: ";
- switch (mDev) {
- case QTabletEvent::NoDevice:
- deviceString += "QTabletEvent::NoDevice";
- break;
- case QTabletEvent::Puck:
- deviceString += "QTabletEvent::Puck";
- break;
- case QTabletEvent::Stylus:
- deviceString += "QTabletEvent::Stylus";
- break;
- case QTabletEvent::Airbrush:
- deviceString += "QTabletEvent::Airbrush";
- break;
- case QTabletEvent::FourDMouse:
- deviceString += "QTabletEvent::FourDMouse";
- break;
- case QTabletEvent::RotationStylus:
- deviceString += "QTabletEvent::RotationStylus";
- break;
- }
- eventInfo << deviceString;
-
+ eventInfo << QString("Device type: %1").arg(deviceTypeToString(mDev));
+ eventInfo << QString("Pointer type: %1").arg(pointerTypeToString(mPointerType));
+ eventInfo << QString("Capabilities: %1").arg(pointerCapabilitiesToString(mCaps));
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);
@@ -182,7 +150,7 @@ void TabletWidget::paintEvent(QPaintEvent *)
eventInfo << QString("yTilt: %1").arg(QString::number(mYT));
eventInfo << QString("z: %1").arg(QString::number(mZ));
- eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique));
+ eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique, 16));
eventInfo << QString("Total wheel events: %1").arg(QString::number(mWheelEventCount));
}
@@ -191,10 +159,28 @@ void TabletWidget::paintEvent(QPaintEvent *)
painter.drawText(rect(), text);
}
+const char *TabletWidget::deviceTypeToString(QInputDevice::DeviceType t)
+{
+ static int enumIdx = QInputDevice::staticMetaObject.indexOfEnumerator("DeviceType");
+ return QPointingDevice::staticMetaObject.enumerator(enumIdx).valueToKey(int(t));
+}
+
+const char *TabletWidget::pointerTypeToString(QPointingDevice::PointerType t)
+{
+ static int enumIdx = QPointingDevice::staticMetaObject.indexOfEnumerator("PointerType");
+ return QPointingDevice::staticMetaObject.enumerator(enumIdx).valueToKey(int(t));
+}
+
+QString TabletWidget::pointerCapabilitiesToString(QPointingDevice::Capabilities c)
+{
+ static int enumIdx = QPointingDevice::staticMetaObject.indexOfEnumerator("Capabilities");
+ return QString::fromLatin1(QPointingDevice::staticMetaObject.enumerator(enumIdx).valueToKeys(c));
+}
+
const char *TabletWidget::buttonToString(Qt::MouseButton b)
{
- static int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons");
- return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(b);
+ static int enumIdx = QObject::staticMetaObject.indexOfEnumerator("MouseButtons");
+ return QObject::staticMetaObject.enumerator(enumIdx).valueToKey(b);
}
QString TabletWidget::buttonsToString(Qt::MouseButtons bs)
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h
index 404be1289f..d05b89a74e 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.h
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.h
@@ -31,6 +31,7 @@
#include <QWidget>
#include <QTabletEvent>
+#include <QPointingDevice>
#include <QShortcut>
// a widget showing the information of the last tablet event
@@ -42,12 +43,18 @@ protected:
bool eventFilter(QObject *obj, QEvent *ev);
void tabletEvent(QTabletEvent *event);
void paintEvent(QPaintEvent *event);
+ const char *deviceTypeToString(QInputDevice::DeviceType t);
+ const char *pointerTypeToString(QPointingDevice::PointerType t);
+ QString pointerCapabilitiesToString(QPointingDevice::Capabilities c);
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;
+ mDev = QInputDevice::DeviceType::Unknown;
+ mPointerType = QPointingDevice::PointerType::Unknown;
+ mCaps = {};
+ mType = mXT = mYT = mZ = 0;
mPress = mTangential = mRot = 0.0;
mPos = mGPos = QPoint();
mHiResGlobalPos = QPointF();
@@ -56,7 +63,10 @@ private:
int mType;
QPoint mPos, mGPos;
QPointF mHiResGlobalPos;
- int mDev, mPointerType, mXT, mYT, mZ;
+ QInputDevice::DeviceType mDev;
+ QPointingDevice::PointerType mPointerType;
+ QPointingDevice::Capabilities mCaps;
+ int mXT, mYT, mZ;
Qt::MouseButton mButton;
Qt::MouseButtons mButtons;
Qt::KeyboardModifiers mModifiers;
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index 1d0af4559b..38b8ae816d 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -48,14 +48,14 @@ enum TabletPointType {
struct TabletPoint
{
- TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove,
- Qt::MouseButton b = Qt::LeftButton, QTabletEvent::PointerType pt = QTabletEvent::UnknownPointer, qreal prs = 0, qreal rotation = 0) :
+ TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove, Qt::MouseButton b = Qt::LeftButton,
+ QPointingDevice::PointerType pt = QPointingDevice::PointerType::Unknown, qreal prs = 0, qreal rotation = 0) :
pos(p), type(t), button(b), ptype(pt), pressure(prs), angle(rotation) {}
QPointF pos;
TabletPointType type;
Qt::MouseButton button;
- QTabletEvent::PointerType ptype;
+ QPointingDevice::PointerType ptype;
qreal pressure;
qreal angle;
};
@@ -167,7 +167,7 @@ void EventReportWidget::paintEvent(QPaintEvent *)
break;
case TabletMove:
if (t.pressure > 0.0) {
- p.setPen(t.ptype == QTabletEvent::Eraser ? Qt::red : Qt::black);
+ p.setPen(t.ptype == QPointingDevice::PointerType::Eraser ? Qt::red : Qt::black);
if (t.angle != 0.0) {
p.save();
p.translate(t.pos);
@@ -205,7 +205,7 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
{
QWidget::tabletEvent(event);
bool isMove = false;
- m_tabletPos = event->posF();
+ m_tabletPos = event->position();
switch (event->type()) {
case QEvent::TabletMove:
m_points.push_back(TabletPoint(m_tabletPos, TabletMove, m_lastButton, event->pointerType(), event->pressure(), event->rotation()));
@@ -229,7 +229,7 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
if (!(isMove && m_lastIsTabletMove)) {
QDebug d = qDebug();
- d << event << " global position = " << event->globalPos()
+ d << event << " global position = " << event->globalPosition()
<< " cursor at " << QCursor::pos();
if (event->button() != Qt::NoButton)
d << " changed button " << event->button();
@@ -245,7 +245,7 @@ bool EventReportWidget::event(QEvent *event)
event->accept();
m_touchPoints.clear();
for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints())
- m_touchPoints.append(p.pos());
+ m_touchPoints.append(p.position());
update();
break;
case QEvent::TouchEnd:
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
index 8572e18955..c8d1950f8c 100644
--- a/tests/manual/touch/main.cpp
+++ b/tests/manual/touch/main.cpp
@@ -536,7 +536,7 @@ void MainWindow::dumpTouchDevices()
{
QString message;
QDebug debug(&message);
- const QList<const QTouchDevice *> devices = QTouchDevice::devices();
+ const QList<const QPointingDevice *> devices = QPointingDevice::devices();
debug << devices.size() << "Device(s):\n";
for (int i = 0; i < devices.size(); ++i)
debug << "Device #" << i << devices.at(i) << '\n';
diff --git a/tests/manual/touchGraphicsItem/main.cpp b/tests/manual/touchGraphicsItem/main.cpp
index 7afadc7edd..2b18634cbd 100644
--- a/tests/manual/touchGraphicsItem/main.cpp
+++ b/tests/manual/touchGraphicsItem/main.cpp
@@ -106,26 +106,26 @@ int main(int argc, char **argv)
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(new QLabel("The blue ellipses should indicate touch point contact patches"));
qDebug() << "Touch devices:";
- for (const QTouchDevice *device : QTouchDevice::devices()) {
+ for (const QPointingDevice *device : QPointingDevice::devices()) {
QString result;
QTextStream str(&result);
- str << (device->type() == QTouchDevice::TouchScreen ? "TouchScreen" : "TouchPad")
+ str << (device->type() == QInputDevice::DeviceType::TouchScreen ? "TouchScreen" : "TouchPad")
<< " \"" << device->name() << "\", max " << device->maximumTouchPoints()
<< " touch points, capabilities:";
- const QTouchDevice::Capabilities capabilities = device->capabilities();
- if (capabilities & QTouchDevice::Position)
+ const QPointingDevice::Capabilities capabilities = device->capabilities();
+ if (capabilities & QPointingDevice::Capability::Position)
str << " Position";
- if (capabilities & QTouchDevice::Area)
+ if (capabilities & QPointingDevice::Capability::Area)
str << " Area";
- if (capabilities & QTouchDevice::Pressure)
+ if (capabilities & QPointingDevice::Capability::Pressure)
str << " Pressure";
- if (capabilities & QTouchDevice::Velocity)
+ if (capabilities & QPointingDevice::Velocity)
str << " Velocity";
- if (capabilities & QTouchDevice::RawPositions)
+ if (capabilities & QPointingDevice::RawPositions)
str << " RawPositions";
- if (capabilities & QTouchDevice::NormalizedPosition)
+ if (capabilities & QPointingDevice::Capability::NormalizedPosition)
str << " NormalizedPosition";
- if (capabilities & QTouchDevice::MouseEmulation)
+ if (capabilities & QInputDevice::DeviceType::MouseEmulation)
str << " MouseEmulation";
vbox->addWidget(new QLabel(result));
qDebug() << " " << result;