summaryrefslogtreecommitdiffstats
path: root/tools/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qml')
-rw-r--r--tools/qml/deviceorientation.h1
-rw-r--r--tools/qml/qmlruntime.cpp45
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