diff options
Diffstat (limited to 'demos/widgetsgallery/panningbenchmark.cpp')
-rw-r--r-- | demos/widgetsgallery/panningbenchmark.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/demos/widgetsgallery/panningbenchmark.cpp b/demos/widgetsgallery/panningbenchmark.cpp index aaf5ea89..cf3594f4 100644 --- a/demos/widgetsgallery/panningbenchmark.cpp +++ b/demos/widgetsgallery/panningbenchmark.cpp @@ -1,6 +1,7 @@ #include "panningbenchmark.h" #include "timedemo.h" +#include <MApplication> #include <MApplicationPage> #include <MPannableViewport> #include <MPhysics2DPanning> @@ -8,14 +9,18 @@ #include <QTimer> #include <qdebug.h> + namespace { const int updateInterval = 20; // ms const qreal ySpeed = .5; // pixel/ms } -PanningBenchmark::PanningBenchmark(MApplicationPage *applicationPage, Timedemo *timedemo) - : TimedemoBenchmark(applicationPage, timedemo) - , timingStarted(false) +PanningBenchmark::PanningBenchmark( + MApplicationPage * applicationPage, Timedemo * timedemo, M::OrientationAngle targetOrientationAngle) : + TimedemoBenchmark(applicationPage, timedemo), + timingStarted(false), + targetOrientationAngle(targetOrientationAngle) + { pannableViewport = 0; QList<QGraphicsItem *> childItems = applicationPage->childItems(); @@ -32,7 +37,7 @@ PanningBenchmark::PanningBenchmark(MApplicationPage *applicationPage, Timedemo * } QString PanningBenchmark::name() { - return "PanningBenchmark"; + return QString("PanningBenchmark (%1)").arg(QString::number(targetOrientationAngle)); } void PanningBenchmark::start() @@ -41,7 +46,7 @@ void PanningBenchmark::start() connect(applicationPage, SIGNAL(appeared()), this, SLOT(waitBeforePanning())); applicationPage->appear(); } else { - QTimer::singleShot(0, this, SLOT(panDown())); + waitBeforePanning(); } } @@ -49,7 +54,8 @@ void PanningBenchmark::start() // the widgets are not completely set up yet void PanningBenchmark::waitBeforePanning() { - QTimer::singleShot(500, this, SLOT(panDown())); + setAngle(); + QTimer::singleShot(2500, this, SLOT(panDown())); } void PanningBenchmark::panDown() @@ -77,8 +83,25 @@ void PanningBenchmark::terminateBenchmark() { timedemo->stopTiming(); pannableViewport->physics()->setPosition(formerPosition); + resetAngle(); qDebug() << "end" << pannableViewport->widget()->pos() << pannableViewport->physics()->range(); emit finished(); } + +void PanningBenchmark::setAngle() +{ + formerOrientationAngle = MApplication::activeWindow()->orientationAngle(); + MApplication::activeWindow()->setOrientationAngleLocked(false); + MApplication::activeWindow()->setOrientationAngle(targetOrientationAngle); + MApplication::activeWindow()->setOrientationAngleLocked(true); +} + +void PanningBenchmark::resetAngle() +{ + MApplication::activeWindow()->setOrientationAngleLocked(false); + MApplication::activeWindow()->setOrientationAngle(formerOrientationAngle); + MApplication::activeWindow()->setOrientationAngleLocked(true); +} + |