aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2013-02-21 09:16:56 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-04 19:26:27 +0200
commit1d594c4e10caa9258f00bb7bcf61c307d027633b (patch)
treea470ec4d74f243ef9c63242d67c8f59acfc09b9f /examples/quick
parent4730e5d9b3574019f67ba29283308d5020385b59 (diff)
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 <richard.gustavsen@digia.com>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/window/screen/screenInfo.qml69
1 files changed, 35 insertions, 34 deletions
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 + ")" }
}
}