diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-04-13 07:42:17 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-04-14 05:10:42 (GMT) |
commit | 063a2d45de349b4bc9c7bb23197392a92159ddc9 (patch) | |
tree | 9ed8089996fb50b9894818993cd3a207ce7542df /tools/qml | |
parent | ffd45093795e9481505af0ae9bf5df7b6c704c72 (diff) | |
download | Qt-063a2d45de349b4bc9c7bb23197392a92159ddc9.zip Qt-063a2d45de349b4bc9c7bb23197392a92159ddc9.tar.gz Qt-063a2d45de349b4bc9c7bb23197392a92159ddc9.tar.bz2 |
Merged 'orientation' into 'runtime' context property in qmlruntime
Removed the 'Screen' element from DeclarativeViewer, as it was used only
for the orientation property. Now access the 'orientation' property like this:
'runtime.orientation' and the enum is accessed as 'Orientation.Landscape',
when using the qmlruntime.
Updated docs for qmlruntime.
Reviewed-by: Martin Jones
Diffstat (limited to 'tools/qml')
-rw-r--r-- | tools/qml/deviceorientation.h | 1 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 45 |
2 files changed, 15 insertions, 31 deletions
diff --git a/tools/qml/deviceorientation.h b/tools/qml/deviceorientation.h index c8125cd..d209005 100644 --- a/tools/qml/deviceorientation.h +++ b/tools/qml/deviceorientation.h @@ -50,6 +50,7 @@ class DeviceOrientationPrivate; class DeviceOrientation : public QObject { Q_OBJECT + Q_ENUMS(Orientation) public: enum Orientation { UnknownOrientation, Portrait, Landscape }; virtual Orientation orientation() const = 0; diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 40de100..df29294 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -112,32 +112,12 @@ 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) { - connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), - this, SIGNAL(orientationChanged())); - } - - enum Orientation { UnknownOrientation = DeviceOrientation::UnknownOrientation, - Portrait = DeviceOrientation::Portrait, - Landscape = DeviceOrientation::Landscape }; - Orientation orientation() const { return Orientation(DeviceOrientation::instance()->orientation()); } - -signals: - void orientationChanged(); -}; - class Runtime : public QObject { Q_OBJECT + Q_PROPERTY(bool isActiveWindow READ isActiveWindow NOTIFY isActiveWindowChanged) + Q_PROPERTY(DeviceOrientation::Orientation orientation READ orientation NOTIFY orientationChanged) public: static Runtime* instance() @@ -157,20 +137,22 @@ public: emit isActiveWindowChanged(); } -signals: + DeviceOrientation::Orientation orientation() const { return DeviceOrientation::instance()->orientation(); } + +Q_SIGNALS: void isActiveWindowChanged(); + void orientationChanged(); private: - Runtime(QObject *parent=0) : QObject(parent), activeWindow(false) {} + Runtime(QObject *parent=0) : QObject(parent), activeWindow(false) + { + connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), + this, SIGNAL(orientationChanged())); + } bool activeWindow; }; -QT_END_NAMESPACE - -QML_DECLARE_TYPE(Screen) - -QT_BEGIN_NAMESPACE class SizedMenuBar : public QMenuBar { @@ -1067,7 +1049,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) url = QUrl(file_or_url); setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(file_or_url)); - if (!m_script.isEmpty()) + if (!m_script.isEmpty()) tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas); delete canvas->rootObject(); @@ -1518,7 +1500,8 @@ void QDeclarativeViewer::setUseNativeFileBrowser(bool use) void QDeclarativeViewer::registerTypes() { - qmlRegisterType<Screen>("QDeclarativeViewer", 1, 0, "Screen"); + // registering only for exposing the DeviceOrientation::Orientation enum + qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation"); } QT_END_NAMESPACE |