From 1d594c4e10caa9258f00bb7bcf61c307d027633b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 21 Feb 2013 09:16:56 +0100 Subject: Add new Item.Screen properties to screenInfo example Also removed the rotation animation which doesn't seem useful. (On most platforms the content will auto-rotate anyway.) Change-Id: Ia6ca1046fc2162a13be5c26cbf5d2b698ffa2367 Reviewed-by: Richard Moe Gustavsen --- examples/quick/window/screen/screenInfo.qml | 69 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'examples/quick') diff --git a/examples/quick/window/screen/screenInfo.qml b/examples/quick/window/screen/screenInfo.qml index 8f60d83933..33fbc5d88e 100644 --- a/examples/quick/window/screen/screenInfo.qml +++ b/examples/quick/window/screen/screenInfo.qml @@ -38,53 +38,54 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window +import QtQuick 2.1 +import QtQuick.Window 2.1 Item { id: root width: 400 height: 200 - Item { - id: main - state: "orientation " + Window.Screen.orientation - property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation - property real baseWidth: landscapeWindow ? root.height : root.width - property real baseHeight: landscapeWindow ? root.width : root.height - property real rotationDelta: landscapeWindow ? -90 : 0 + function orientationToString(o) { + switch (o) { + case Qt.PrimaryOrientation: + return "primary"; + case Qt.PortraitOrientation: + return "portrait"; + case Qt.LandscapeOrientation: + return "landscape"; + case Qt.InvertedPortraitOrientation: + return "inverted portrait"; + case Qt.InvertedLandscapeOrientation: + return "inverted landscape"; + } + return "unknown"; + } - rotation: rotationDelta - width: main.baseWidth - height: main.baseHeight + Grid { anchors.centerIn: parent + columns: 2 + spacing: 8 Text { - text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation - anchors.centerIn:parent + text: "Screen \"" + Screen.name + "\":" + font.bold: true } + Item { width: 1; height: 1 } // spacer + Text { text: "dimensions" } + Text { text: Screen.width + "x" + Screen.height } - states: [ - State { - name: "orientation " + Qt.LandscapeOrientation - PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - }, - State { - name: "orientation " + Qt.InvertedPortraitOrientation - PropertyChanges { target: main; rotation: 180 + rotationDelta; } - }, - State { - name: "orientation " + Qt.InvertedLandscapeOrientation - PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - } - ] + Text { text: "logical pixel density" } + Text { text: Screen.logicalPixelDensity.toFixed(2) + " dots/mm" } - transitions: Transition { - SequentialAnimation { - RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } - NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } - } - } + Text { text: "available virtual desktop" } + Text { text: Screen.desktopAvailableWidth + "x" + Screen.desktopAvailableHeight } + + Text { text: "orientation" } + Text { text: orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" } + + Text { text: "primary orientation" } + Text { text: orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" } } } -- cgit v1.2.3