aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-01-24 10:04:45 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-24 21:01:53 +0100
commitd2d53dffbc3ba52333e559e2c0391bd73e5b840c (patch)
treef156da156fe9d715e58ac5d8cc5e5cecfbb46a0a
parent40bbc9503b988412202836bc4d10a0a9f645a940 (diff)
Adapted QQuickScreenAttached to orientation API changes in QScreen.
Change-Id: Ic2cb008b989780e297f03ddd5bdef466bb230c74 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--examples/declarative/calculator/calculator.qml2
-rw-r--r--examples/declarative/window/screen/screenInfo.qml2
-rw-r--r--src/quick/items/qquickscreen.cpp31
-rw-r--r--src/quick/items/qquickscreen_p.h6
-rw-r--r--tests/auto/qtquick2/qquickscreen/data/screen.qml2
-rw-r--r--tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp2
6 files changed, 25 insertions, 20 deletions
diff --git a/examples/declarative/calculator/calculator.qml b/examples/declarative/calculator/calculator.qml
index cfec9c185f..82fa1c1a3e 100644
--- a/examples/declarative/calculator/calculator.qml
+++ b/examples/declarative/calculator/calculator.qml
@@ -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
diff --git a/examples/declarative/window/screen/screenInfo.qml b/examples/declarative/window/screen/screenInfo.qml
index 53028a41e6..9a9727693f 100644
--- a/examples/declarative/window/screen/screenInfo.qml
+++ b/examples/declarative/window/screen/screenInfo.qml
@@ -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
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index dc9a3d3630..3769f4e809 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -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()));
}
}
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index 5a6795217b..672607f7f5 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -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;
diff --git a/tests/auto/qtquick2/qquickscreen/data/screen.qml b/tests/auto/qtquick2/qquickscreen/data/screen.qml
index 971975f892..780b22f23d 100644
--- a/tests/auto/qtquick2/qquickscreen/data/screen.qml
+++ b/tests/auto/qtquick2/qquickscreen/data/screen.qml
@@ -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
}
diff --git a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
index 8e3228475d..fdb27302ae 100644
--- a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
+++ b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
@@ -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());
}