aboutsummaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorArmin Berres <armin.berres@basyskom.de>2010-04-19 18:02:48 +0200
committerSergiy Dubovik <sergiy.dubovik@nokia.com>2010-04-23 09:29:04 +0300
commit6aa99a265167cc8005afaae5958e87f1a494163e (patch)
treee9157d3881d42e7ba166e8e2400efd86198aab6d /demos
parentc75928dbede91639e7382fdb468cf4170aebaf7f (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')
-rw-r--r--demos/widgetsgallery/panningbenchmark.cpp35
-rw-r--r--demos/widgetsgallery/panningbenchmark.h11
-rw-r--r--demos/widgetsgallery/timedemopage.cpp3
3 files changed, 42 insertions, 7 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);
+}
+
diff --git a/demos/widgetsgallery/panningbenchmark.h b/demos/widgetsgallery/panningbenchmark.h
index c2ecdefb..f94517f5 100644
--- a/demos/widgetsgallery/panningbenchmark.h
+++ b/demos/widgetsgallery/panningbenchmark.h
@@ -4,6 +4,8 @@
#include "timedemobenchmark.h"
#include <MPannableViewport>
+#include <MNamespace>
+
#include <QTime>
/**
@@ -14,7 +16,7 @@ class PanningBenchmark : public TimedemoBenchmark
{
Q_OBJECT
public:
- PanningBenchmark(MApplicationPage *applicationPage, Timedemo *timedemo);
+ PanningBenchmark(MApplicationPage *applicationPage, Timedemo *timedemo, M::OrientationAngle targetOrientationAngle = M::Angle0);
QString name();
void start();
@@ -24,6 +26,9 @@ private slots:
void panDown();
void terminateBenchmark();
+ void setAngle();
+ void resetAngle();
+
private:
MPannableViewport *pannableViewport;
@@ -33,6 +38,10 @@ private:
QTime timer;
+private:
+ M::OrientationAngle targetOrientationAngle;
+ M::OrientationAngle formerOrientationAngle;
+
};
#endif // PANNINGBENCHMARK_H
diff --git a/demos/widgetsgallery/timedemopage.cpp b/demos/widgetsgallery/timedemopage.cpp
index defe5424..22b9fc3e 100644
--- a/demos/widgetsgallery/timedemopage.cpp
+++ b/demos/widgetsgallery/timedemopage.cpp
@@ -21,6 +21,9 @@ void TimedemoPage::createBenchmarks(Timedemo *timedemo)
benchmark = QSharedPointer<TimedemoBenchmark>(new StaticPageBenchmark(this, timedemo, M::Angle90));
m_benchmarks.append(benchmark);
+
+ benchmark = QSharedPointer<TimedemoBenchmark>(new PanningBenchmark(this, timedemo, M::Angle90));
+ m_benchmarks.append(benchmark);
}
QVector<QSharedPointer<TimedemoBenchmark> > TimedemoPage::benchmarks()