diff options
author | Armin Berres <armin.berres@basyskom.de> | 2010-04-19 18:02:48 +0200 |
---|---|---|
committer | Sergiy Dubovik <sergiy.dubovik@nokia.com> | 2010-04-23 09:29:04 +0300 |
commit | 6aa99a265167cc8005afaae5958e87f1a494163e (patch) | |
tree | e9157d3881d42e7ba166e8e2400efd86198aab6d /demos/widgetsgallery/panningbenchmark.cpp | |
parent | c75928dbede91639e7382fdb468cf4170aebaf7f (diff) |
Changes: panning in portrait mode for the timedemo
RevBy: TrustMe
Detail: This patch is based on work by Hans Sandvall. So credits go to him.
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); +} + |