summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer/qmlviewer.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-12-01 03:30:13 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-12-01 03:30:13 (GMT)
commit5f9172a3db108a0cc4719fd75f7ffe3f256f1fcc (patch)
tree4ac8fecfc919d6d405d801a0a271aa0c54303531 /tools/qmlviewer/qmlviewer.cpp
parentc20ff1f36b8f5ba47e0358c4d63eed408c97b993 (diff)
downloadQt-5f9172a3db108a0cc4719fd75f7ffe3f256f1fcc.zip
Qt-5f9172a3db108a0cc4719fd75f7ffe3f256f1fcc.tar.gz
Qt-5f9172a3db108a0cc4719fd75f7ffe3f256f1fcc.tar.bz2
Add Screen element in QmlViewr Module including orientation property.
Add support for automatic Maemo rotation update.
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r--tools/qmlviewer/qmlviewer.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index a354653..8c50b09 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -74,6 +74,7 @@
#include <QNetworkProxyFactory>
#include <QKeyEvent>
#include "proxysettings.h"
+#include "deviceorientation.h"
#ifdef GL_SUPPORTED
#include <QGLWidget>
@@ -84,6 +85,43 @@
QT_BEGIN_NAMESPACE
+class Screen : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(Orientation orientation READ orientation NOTIFY orientationChanged)
+ Q_ENUMS(Orientation)
+
+public:
+ Screen(QObject *parent=0) : QObject(parent) {
+ m_screens.append(this);
+ connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()),
+ this, SIGNAL(orientationChanged()));
+ }
+ ~Screen() { m_screens.removeAll(this); }
+
+ enum Orientation { UnknownOrientation = DeviceOrientation::UnknownOrientation,
+ Portrait = DeviceOrientation::Portrait,
+ Landscape = DeviceOrientation::Landscape };
+ Orientation orientation() const { return Orientation(DeviceOrientation::instance()->orientation()); }
+ static void setOrientation(Orientation orient) {
+ if (orient != Orientation(DeviceOrientation::instance()->orientation())) {
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::Orientation(orient));
+ }
+ }
+
+signals:
+ void orientationChanged();
+
+private:
+ static QList<Screen*> m_screens;
+};
+
+QList<Screen*> Screen::m_screens;
+
+QML_DECLARE_TYPE(Screen)
+QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen)
+
class SizedMenuBar : public QMenuBar
{
Q_OBJECT
@@ -532,13 +570,13 @@ void QmlViewer::proxySettingsChanged()
void QmlViewer::setPortrait()
{
- canvas->rootContext()->setContextProperty("orientation", "Portrait");
+ Screen::setOrientation(Screen::Portrait);
portraitOrientation->setChecked(true);
}
void QmlViewer::setLandscape()
{
- canvas->rootContext()->setContextProperty("orientation", "Landscape");
+ Screen::setOrientation(Screen::Landscape);
landscapeOrientation->setChecked(true);
}