Adapted QQuickScreenAttached to orientation API changes in QScreen.
authorSamuel Rødal <samuel.rodal@nokia.com>
Tue, 24 Jan 2012 09:04:45 +0000 (10:04 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 24 Jan 2012 20:01:53 +0000 (21:01 +0100)
Change-Id: Ic2cb008b989780e297f03ddd5bdef466bb230c74
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
examples/declarative/calculator/calculator.qml
examples/declarative/window/screen/screenInfo.qml
src/quick/items/qquickscreen.cpp
src/quick/items/qquickscreen_p.h
tests/auto/qtquick2/qquickscreen/data/screen.qml
tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp

index cfec9c1..82fa1c1 100644 (file)
@@ -62,7 +62,7 @@ Rectangle {
 
     Item {
         id: main
-        state: "orientation " + Screen.currentOrientation
+        state: "orientation " + Screen.orientation
 
         property bool landscapeWindow: window.width > window.height 
         property real baseWidth: landscapeWindow ? window.height : window.width
index 53028a4..9a97276 100644 (file)
@@ -47,7 +47,7 @@ Item {
     height: 200
     Item {
         id: main
-        state: "orientation " + Window.Screen.currentOrientation
+        state: "orientation " + Window.Screen.orientation
 
         property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation
         property real baseWidth: landscapeWindow ? root.height : root.width
index dc9a3d3..3769f4e 100644 (file)
@@ -74,10 +74,10 @@ QT_BEGIN_NAMESPACE
     \qmlattachedproperty Qt::ScreenOrientation QtQuickWindow2::Screen::primaryOrientation
     \readonly
 
-    This contains the primary orientation of the screen. This can only change if the screen changes.
+    This contains the primary orientation of the screen.
 */
 /*!
-    \qmlattachedproperty Qt::ScreenOrientation QtQuickWindow2::Screen::currentOrientation
+    \qmlattachedproperty Qt::ScreenOrientation QtQuickWindow2::Screen::orientation
     \readonly
 
     This contains the current orientation of the screen.
@@ -119,20 +119,20 @@ int QQuickScreenAttached::height() const
 Qt::ScreenOrientation QQuickScreenAttached::primaryOrientation() const
 {
     if (!m_screen)
-        return Qt::UnknownOrientation;
+        return Qt::PrimaryOrientation;
     return m_screen->primaryOrientation();
 }
 
-Qt::ScreenOrientation QQuickScreenAttached::currentOrientation() const
+Qt::ScreenOrientation QQuickScreenAttached::orientation() const
 {
     if (!m_screen)
-        return Qt::UnknownOrientation;
-    return m_screen->currentOrientation();
+        return Qt::PrimaryOrientation;
+    return m_screen->orientation();
 }
 
 int QQuickScreenAttached::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
 {
-    return QScreen::angleBetween(a,b);
+    return m_screen->angleBetween(a,b);
 }
 
 void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemPrivate::initCanvas
@@ -147,8 +147,10 @@ void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemP
                     this, SIGNAL(widthChanged()));
             disconnect(oldScreen, SIGNAL(sizeChanged(QSize)),
                     this, SIGNAL(heightChanged()));
-            disconnect(oldScreen, SIGNAL(currentOrientationChanged(Qt::ScreenOrientation)),
-                    this, SIGNAL(currentOrientationChanged()));
+            disconnect(oldScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
+                    this, SIGNAL(orientationChanged()));
+            disconnect(oldScreen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
+                    this, SIGNAL(primaryOrientationChanged()));
         }
 
         if (!screen)
@@ -158,8 +160,9 @@ void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemP
             emit widthChanged();
             emit heightChanged();
         }
-        if (!oldScreen || screen->currentOrientation() != oldScreen->currentOrientation())
-            emit currentOrientationChanged();
+
+        if (!oldScreen || screen->orientation() != oldScreen->orientation())
+            emit orientationChanged();
         if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation())
             emit primaryOrientationChanged();
 
@@ -168,8 +171,10 @@ void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemP
                 this, SIGNAL(widthChanged()));
         connect(screen, SIGNAL(sizeChanged(QSize)),
                 this, SIGNAL(heightChanged()));
-        connect(screen, SIGNAL(currentOrientationChanged(Qt::ScreenOrientation)),
-                this, SIGNAL(currentOrientationChanged()));
+        connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
+                this, SIGNAL(orientationChanged()));
+        connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
+                this, SIGNAL(primaryOrientationChanged()));
     }
 }
 
index 5a67952..672607f 100644 (file)
@@ -63,7 +63,7 @@ class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QObject
     Q_PROPERTY(int width READ width NOTIFY widthChanged)
     Q_PROPERTY(int height READ height NOTIFY heightChanged)
     Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged)
-    Q_PROPERTY(Qt::ScreenOrientation currentOrientation READ currentOrientation NOTIFY currentOrientationChanged)
+    Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
 
 public:
     QQuickScreenAttached(QObject* attachee);
@@ -71,7 +71,7 @@ public:
     int width() const;
     int height() const;
     Qt::ScreenOrientation primaryOrientation() const;
-    Qt::ScreenOrientation currentOrientation() const;
+    Qt::ScreenOrientation orientation() const;
 
     Q_INVOKABLE int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b);
 
@@ -81,7 +81,7 @@ Q_SIGNALS:
     void widthChanged();
     void heightChanged();
     void primaryOrientationChanged();
-    void currentOrientationChanged();
+    void orientationChanged();
 
 private:
     QScreen* m_screen;
index 971975f..780b22f 100644 (file)
@@ -6,6 +6,6 @@ Item {
     height: 100
     property int w: Window.Screen.width
     property int h: Window.Screen.height
-    property int curOrientation: Window.Screen.currentOrientation
+    property int curOrientation: Window.Screen.orientation
     property int priOrientation: Window.Screen.primaryOrientation
 }
index 8e32284..fdb2730 100644 (file)
@@ -68,7 +68,7 @@ void tst_qquickscreen::basicProperties()
 
     QCOMPARE(screen->size().width(), root->property("w").toInt());
     QCOMPARE(screen->size().height(), root->property("h").toInt());
-    QCOMPARE(int(screen->currentOrientation()), root->property("curOrientation").toInt());
+    QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt());
     QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt());
 }