Skip to content

Commit

Permalink
Update righttoleft examples to new form factor
Browse files Browse the repository at this point in the history
Change-Id: I2591f45a91da8bad90c5f3b9c963199c57bcf74d
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
  • Loading branch information
Alan Alpert authored and Qt by Nokia committed Mar 9, 2012
1 parent 4b56661 commit 576fb7a
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 181 deletions.
30 changes: 20 additions & 10 deletions examples/quick/righttoleft/layoutdirection/layoutdirection.qml
Expand Up @@ -46,14 +46,18 @@ Rectangle {
property int direction: Qt.application.layoutDirection
LayoutMirroring.enabled: mirror
LayoutMirroring.childrenInherit: true
width: column.width + 80
height: column.height + 40
width: 320
height: 480
Column {
id: column
width: 190
id: columnA
spacing: 10
anchors.centerIn: parent
x: 10
y: 10
width: 140

Item {
id: rowCell
}
Text {
text: "Row"
anchors.horizontalCenter: parent.horizontalCenter
Expand All @@ -68,7 +72,7 @@ Rectangle {
}
}
Repeater {
model: 4
model: 3
Loader {
property int value: index
sourceComponent: positionerDelegate
Expand All @@ -83,14 +87,14 @@ Rectangle {

Grid {
layoutDirection: root.direction
spacing: 10; columns: 4
spacing: 10; columns: 3
move: Transition {
NumberAnimation {
properties: "x"
}
}
Repeater {
model: 11
model: 8
Loader {
property int value: index
sourceComponent: positionerDelegate
Expand All @@ -112,13 +116,19 @@ Rectangle {
}
}
Repeater {
model: 10
model: 8
Loader {
property int value: index
sourceComponent: positionerDelegate
}
}
}
}
Column {
id: columnB
spacing: 10
x: 160
y: 10

Text {
text: "ListView"
Expand All @@ -142,7 +152,7 @@ Rectangle {

GridView {
clip: true
width: 200; height: 160
width: 150; height: 160
cellWidth: 50; cellHeight: 50
layoutDirection: root.direction
model: 48
Expand Down
172 changes: 31 additions & 141 deletions examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml
Expand Up @@ -45,71 +45,14 @@ Rectangle {
property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft
LayoutMirroring.enabled: mirror
LayoutMirroring.childrenInherit: true
width: 400
height: 875
width: 320
height: 480
color: "lightsteelblue"

Column {
spacing: 10
anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 }

Text {
text: "Positioners"
anchors.left: parent.left
}

Column {
id: positioners
spacing: 5
anchors.left: parent.left
Row {
id: row
spacing: 4
property string text: "THISISROW"
anchors.left: parent.left
Repeater {
model: parent.text.length
delegate: positionerDelegate
}
}
Flow {
id: flow
spacing: 4
width: 90
property string text: "THISISFLOW"
anchors.left: parent.left
Repeater {
model: parent.text.length
delegate: positionerDelegate
}
}
Grid {
id: grid
spacing: 4
columns: 6
property string text: "THISISGRID"
anchors.left: parent.left
Repeater {
model: parent.text.length
delegate: positionerDelegate
}
}
Component {
id: positionerDelegate
Text {
color: "white"
font.pixelSize: 20
text: parent.text[index]
Rectangle {
z: -1
opacity: 0.7
color: "black"
anchors.fill: parent
}
}
}
}

Text {
text: "Text alignment"
anchors.left: parent.left
Expand Down Expand Up @@ -150,62 +93,6 @@ Rectangle {
}
}

Text {
text: "Model views"
anchors.left: parent.left
}

Column {
id: views
spacing: 10
anchors.left: parent.left
ListView {
id: listView
z: -1
clip: true
model: text.length
width: 360; height: 45
orientation: Qt.Horizontal
property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW"
delegate: Rectangle {
color: "black"
width: 45; height: 45
Rectangle {
anchors { fill: parent; margins: 1 }
color: "red"
}
Text {
text: listView.text[index]
font.pixelSize: 30
anchors.centerIn: parent
}
}
}
GridView {
id: gridView
z: -1
clip: true
model: text.length
width: 180; height: 90
cellWidth: 45; cellHeight: 45
property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW"
anchors.left: parent.left
delegate: Rectangle {
color: "black"
width: 45; height: 45
Rectangle {
anchors { fill: parent; margins: 1 }
color: "red"
}
Text {
anchors.centerIn: parent
font.pixelSize: 30
text: gridView.text[index]
}
}
}
}

Text {
text: "Item x"
anchors.left: parent.left
Expand Down Expand Up @@ -279,33 +166,36 @@ Rectangle {
}
}
}
Rectangle {
id: mirrorButton
color: mouseArea2.pressed ? "black" : "gray"
height: 50; width: parent.width
anchors.left: parent.left
Column {
anchors.centerIn: parent
Text {
text: root.mirror ? "Mirrored" : "Not mirrored"
color: "white"
font.pixelSize: 16
anchors.horizontalCenter: parent.horizontalCenter
}
Text {
text: "(click here to toggle)"
color: "white"
font.pixelSize: 10
font.italic: true
anchors.horizontalCenter: parent.horizontalCenter
}
}

Rectangle {
id: mirrorButton
color: mouseArea2.pressed ? "black" : "gray"
height: 50; width: 160
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 10
Column {
anchors.centerIn: parent
Text {
text: root.mirror ? "Mirrored" : "Not mirrored"
color: "white"
font.pixelSize: 16
anchors.horizontalCenter: parent.horizontalCenter
}
MouseArea {
id: mouseArea2
anchors.fill: parent
onClicked: {
root.mirror = !root.mirror;
}
Text {
text: "(click here to toggle)"
color: "white"
font.pixelSize: 10
font.italic: true
anchors.horizontalCenter: parent.horizontalCenter
}
}
MouseArea {
id: mouseArea2
anchors.fill: parent
onClicked: {
root.mirror = !root.mirror;
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions examples/quick/righttoleft/main.cpp
@@ -0,0 +1,41 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "../../shared/shared.h"
DECLARATIVE_EXAMPLE_MAIN(righttoleft)
10 changes: 10 additions & 0 deletions examples/quick/righttoleft/righttoleft.pro
@@ -0,0 +1,10 @@
TEMPLATE = app

QT += quick declarative
SOURCES += main.cpp

target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/righttoleft
qml.files = righttoleft.qml layoutdirection layoutmirroring textalignment
qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/righttoleft
INSTALLS += target qml

0 comments on commit 576fb7a

Please sign in to comment.