summaryrefslogtreecommitdiff
path: root/tests/manual/qtabletevent
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-09-25 14:02:04 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-09-25 14:02:04 +0200
commita1ad9a74ebb3c556c5f70f7e03be68b09598ac53 (patch)
tree615a96db418219a57a745a5899e39a9ac90744ec /tests/manual/qtabletevent
parent6d78b7a0c46ea04f4bb771d960e2f7dff1362341 (diff)
parent462f355e4fb16cc7a1838fa2dda0f763eee58c84 (diff)
downloadqtbase-a1ad9a74ebb3c556c5f70f7e03be68b09598ac53.tar.gz
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/io/io.pri src/corelib/io/qdatastream.cpp src/corelib/io/qdatastream.h src/network/socket/qabstractsocket.cpp src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h src/widgets/styles/qgtkstyle.cpp tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro tests/auto/dbus/qdbusconnection/qdbusconnection.pro tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp Change-Id: I347549a024eb5bfa986699e0a11f96cc55c797a7
Diffstat (limited to 'tests/manual/qtabletevent')
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.cpp3
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.h1
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp24
3 files changed, 27 insertions, 1 deletions
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
index e35cee65e8..2462bb3701 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
@@ -73,6 +73,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mRot = event->rotation();
mButton = event->button();
mButtons = event->buttons();
+ mTimestamp = event->timestamp();
if (isVisible())
update();
break;
@@ -84,6 +85,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mType = event->type();
mPos = event->pos();
mGPos = event->globalPos();
+ mTimestamp = event->timestamp();
}
default:
break;
@@ -122,6 +124,7 @@ void TabletWidget::paintEvent(QPaintEvent *)
eventInfo << QString("Global position: %1 %2").arg(QString::number(mGPos.x()), QString::number(mGPos.y()));
eventInfo << QString("Local position: %1 %2").arg(QString::number(mPos.x()), QString::number(mPos.y()));
+ eventInfo << QString("Timestamp: %1").arg(QString::number(mTimestamp));
if (mType == QEvent::TabletEnterProximity || mType == QEvent::TabletLeaveProximity
|| mType == QEvent::TabletMove || mType == QEvent::TabletPress
|| mType == QEvent::TabletRelease) {
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h
index 2861eb4814..95631be57b 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.h
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.h
@@ -65,6 +65,7 @@ private:
qreal mPress, mTangential, mRot;
qint64 mUnique;
bool mMouseToo;
+ ulong mTimestamp;
};
#endif // TABLETWIDGET_H
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index c8353a40c0..a6fddd4b18 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -39,6 +39,7 @@
#include <QMenuBar>
#include <QMenu>
#include <QAction>
+#include <QStatusBar>
#include <QVector>
#include <QPainter>
#include <QCursor>
@@ -72,6 +73,9 @@ public:
public slots:
void clearPoints() { m_points.clear(); update(); }
+signals:
+ void stats(QString s);
+
protected:
void mouseDoubleClickEvent(QMouseEvent *event) { outputMouseEvent(event); }
void mouseMoveEvent(QMouseEvent *event) { outputMouseEvent(event); }
@@ -81,6 +85,7 @@ protected:
void tabletEvent(QTabletEvent *);
void paintEvent(QPaintEvent *);
+ void timerEvent(QTimerEvent *);
private:
void outputMouseEvent(QMouseEvent *event);
@@ -89,13 +94,19 @@ private:
bool m_lastIsTabletMove;
Qt::MouseButton m_lastButton;
QVector<TabletPoint> m_points;
+ int m_tabletMoveCount;
+ int m_paintEventCount;
};
EventReportWidget::EventReportWidget()
: m_lastIsMouseMove(false)
, m_lastIsTabletMove(false)
, m_lastButton(Qt::NoButton)
-{ }
+ , m_tabletMoveCount(0)
+ , m_paintEventCount(0)
+{
+ startTimer(1000);
+}
void EventReportWidget::paintEvent(QPaintEvent *)
{
@@ -145,6 +156,7 @@ void EventReportWidget::paintEvent(QPaintEvent *)
}
}
}
+ ++m_paintEventCount;
}
void EventReportWidget::tabletEvent(QTabletEvent *event)
@@ -154,11 +166,13 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
switch (event->type()) {
case QEvent::TabletEnterProximity:
case QEvent::TabletLeaveProximity:
+ qDebug() << "proximity" << event;
break;
case QEvent::TabletMove:
m_points.push_back(TabletPoint(event->pos(), TabletMove, m_lastButton, event->pointerType(), event->pressure(), event->rotation()));
update();
isMove = true;
+ ++m_tabletMoveCount;
break;
case QEvent::TabletPress:
m_points.push_back(TabletPoint(event->pos(), TabletButtonPress, event->button(), event->pointerType(), event->rotation()));
@@ -194,6 +208,13 @@ void EventReportWidget::outputMouseEvent(QMouseEvent *event)
qDebug() << event;
}
+void EventReportWidget::timerEvent(QTimerEvent *)
+{
+ emit stats(QString("%1 moves/sec, %2 frames/sec").arg(m_tabletMoveCount).arg(m_paintEventCount));
+ m_tabletMoveCount = 0;
+ m_paintEventCount = 0;
+}
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
@@ -203,6 +224,7 @@ int main(int argc, char *argv[])
widget->setMinimumSize(640, 480);
QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
QObject::connect(fileMenu->addAction("Clear"), SIGNAL(triggered()), widget, SLOT(clearPoints()));
+ QObject::connect(widget, SIGNAL(stats(QString)), mainWindow.statusBar(), SLOT(showMessage(QString)));
QAction *quitAction = fileMenu->addAction("Quit");
QObject::connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);