From 63ff83ae514b57258d27f3b401093328cf10fbb0 Mon Sep 17 00:00:00 2001 From: artoka Date: Thu, 17 Nov 2011 15:49:56 +0100 Subject: RightToLeft Examples Modifications righttoleft/ layoutdirection, layoutmirroring and textalignment example modifications Modified examples to use centralized qmlapplicationviewer, removed duplicate files and modified project files according to the changes. Merge-request: 2719 Reviewed-by: Casper van Donderen --- .../layoutdirection/layoutdirection.desktop | 11 + .../layoutdirection/layoutdirection.pro | 37 ++ .../layoutdirection/layoutdirection.qml | 256 ------------- .../layoutdirection/layoutdirection.qmlproject | 6 +- .../layoutdirection/layoutdirection.svg | 93 +++++ .../layoutdirection/layoutdirection64.png | Bin 0 -> 3400 bytes .../layoutdirection/layoutdirection80.png | Bin 0 -> 4945 bytes .../layoutdirection_harmattan.desktop | 11 + .../righttoleft/layoutdirection/main.cpp | 54 +++ .../qml/layoutdirection/layoutdirection.qml | 256 +++++++++++++ .../layoutmirroring/layoutmirroring.desktop | 11 + .../layoutmirroring/layoutmirroring.pro | 37 ++ .../layoutmirroring/layoutmirroring.qml | 313 --------------- .../layoutmirroring/layoutmirroring.qmlproject | 6 +- .../layoutmirroring/layoutmirroring.svg | 93 +++++ .../layoutmirroring/layoutmirroring64.png | Bin 0 -> 3400 bytes .../layoutmirroring/layoutmirroring80.png | Bin 0 -> 4945 bytes .../layoutmirroring_harmattan.desktop | 11 + .../righttoleft/layoutmirroring/main.cpp | 54 +++ .../qml/layoutmirroring/layoutmirroring.qml | 313 +++++++++++++++ .../declarative/righttoleft/textalignment/main.cpp | 54 +++ .../qml/textalignment/textalignment.qml | 426 +++++++++++++++++++++ .../textalignment/textalignment.desktop | 11 + .../righttoleft/textalignment/textalignment.pro | 37 ++ .../righttoleft/textalignment/textalignment.qml | 426 --------------------- .../textalignment/textalignment.qmlproject | 6 +- .../righttoleft/textalignment/textalignment.svg | 93 +++++ .../righttoleft/textalignment/textalignment64.png | Bin 0 -> 3400 bytes .../righttoleft/textalignment/textalignment80.png | Bin 0 -> 4945 bytes .../textalignment/textalignment_harmattan.desktop | 11 + 30 files changed, 1622 insertions(+), 1004 deletions(-) create mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.desktop create mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.pro delete mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.qml create mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.svg create mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection64.png create mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection80.png create mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection_harmattan.desktop create mode 100644 examples/declarative/righttoleft/layoutdirection/main.cpp create mode 100644 examples/declarative/righttoleft/layoutdirection/qml/layoutdirection/layoutdirection.qml create mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.desktop create mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.pro delete mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml create mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.svg create mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring64.png create mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring80.png create mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring_harmattan.desktop create mode 100644 examples/declarative/righttoleft/layoutmirroring/main.cpp create mode 100644 examples/declarative/righttoleft/layoutmirroring/qml/layoutmirroring/layoutmirroring.qml create mode 100644 examples/declarative/righttoleft/textalignment/main.cpp create mode 100644 examples/declarative/righttoleft/textalignment/qml/textalignment/textalignment.qml create mode 100644 examples/declarative/righttoleft/textalignment/textalignment.desktop create mode 100644 examples/declarative/righttoleft/textalignment/textalignment.pro delete mode 100644 examples/declarative/righttoleft/textalignment/textalignment.qml create mode 100644 examples/declarative/righttoleft/textalignment/textalignment.svg create mode 100644 examples/declarative/righttoleft/textalignment/textalignment64.png create mode 100644 examples/declarative/righttoleft/textalignment/textalignment80.png create mode 100644 examples/declarative/righttoleft/textalignment/textalignment_harmattan.desktop diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.desktop b/examples/declarative/righttoleft/layoutdirection/layoutdirection.desktop new file mode 100644 index 0000000..36ca6ea --- /dev/null +++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=layoutdirection +Exec=/opt/layoutdirection/bin/layoutdirection +Icon=layoutdirection64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.pro b/examples/declarative/righttoleft/layoutdirection/layoutdirection.pro new file mode 100644 index 0000000..a7f11d8 --- /dev/null +++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection.pro @@ -0,0 +1,37 @@ +# Add more folders to ship with the application, here +folder_01.source = qml/layoutdirection +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE12C9D9E + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(../../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml deleted file mode 100644 index fa343b9..0000000 --- a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - id: root - property bool mirror - property int direction: Qt.application.layoutDirection - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: column.width + 80 - height: column.height + 40 - Column { - id: column - width: 190 - spacing: 10 - anchors.centerIn: parent - - Text { - text: "Row" - anchors.horizontalCenter: parent.horizontalCenter - } - - Row { - layoutDirection: root.direction - spacing: 10 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 4 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Grid" - anchors.horizontalCenter: parent.horizontalCenter - } - - Grid { - layoutDirection: root.direction - spacing: 10; columns: 4 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 11 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Flow" - anchors.horizontalCenter: parent.horizontalCenter - } - - Flow { - layoutDirection: root.direction - spacing: 10; width: parent.width - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 10 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "ListView" - anchors.horizontalCenter: parent.horizontalCenter - } - - ListView { - id: listView - clip: true - width: parent.width; height: 40 - layoutDirection: root.direction - orientation: Qt.Horizontal - model: 48 - delegate: viewDelegate - } - - Text { - text: "GridView" - anchors.horizontalCenter: parent.horizontalCenter - } - - GridView { - clip: true - width: 200; height: 160 - cellWidth: 50; cellHeight: 50 - layoutDirection: root.direction - model: 48 - delegate: viewDelegate - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.direction ? "Right to left" : "Left to right" - 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 - } - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - if (root.direction == Qt.LeftToRight) { - root.direction = Qt.RightToLeft; - } else { - root.direction = Qt.LeftToRight; - } - } - } - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - 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 - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } - - Component { - id: positionerDelegate - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) - Text { - text: parent.parent.value+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - Component { - id: viewDelegate - Item { - function effectiveLayoutDirection() { - if (LayoutMirroring.enabled) - if (listView.layoutDirection == Qt.LeftToRight) - return Qt.RightToLeft; - else - return Qt.LeftToRight; - else - return listView.layoutDirection; - } - - width: (effectiveLayoutDirection() == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.5+(48 - index)*Math.random()/48, - 0.3+index*Math.random()/48, - 0.3*Math.random(), - 1.0) - Text { - text: index+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject index e526217..59456b0 100644 --- a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject +++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject @@ -5,13 +5,13 @@ import QmlProject 1.0 Project { /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { - directory: "." + directory: "qml/layoutdirection" } JavaScriptFiles { - directory: "." + directory: "qml/layoutdirection" } ImageFiles { - directory: "." + directory: "qml/layoutdirection" } /* List of plugin directories passed to QML runtime */ // importPaths: [ " ../exampleplugin " ] diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.svg b/examples/declarative/righttoleft/layoutdirection/layoutdirection.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection64.png b/examples/declarative/righttoleft/layoutdirection/layoutdirection64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/declarative/righttoleft/layoutdirection/layoutdirection64.png differ diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection80.png b/examples/declarative/righttoleft/layoutdirection/layoutdirection80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/declarative/righttoleft/layoutdirection/layoutdirection80.png differ diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection_harmattan.desktop b/examples/declarative/righttoleft/layoutdirection/layoutdirection_harmattan.desktop new file mode 100644 index 0000000..ef5691e --- /dev/null +++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection_harmattan.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=layoutdirection +Exec=/usr/bin/single-instance /opt/layoutdirection/bin/layoutdirection +Icon=/usr/share/icons/hicolor/80x80/apps/layoutdirection80.png +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/righttoleft/layoutdirection/main.cpp b/examples/declarative/righttoleft/layoutdirection/main.cpp new file mode 100644 index 0000000..79d1457 --- /dev/null +++ b/examples/declarative/righttoleft/layoutdirection/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +#include "qmlapplicationviewer.h" + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/layoutdirection/layoutdirection.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/declarative/righttoleft/layoutdirection/qml/layoutdirection/layoutdirection.qml b/examples/declarative/righttoleft/layoutdirection/qml/layoutdirection/layoutdirection.qml new file mode 100644 index 0000000..fa343b9 --- /dev/null +++ b/examples/declarative/righttoleft/layoutdirection/qml/layoutdirection/layoutdirection.qml @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import QtQuick 1.1 + +Rectangle { + id: root + property bool mirror + property int direction: Qt.application.layoutDirection + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: column.width + 80 + height: column.height + 40 + Column { + id: column + width: 190 + spacing: 10 + anchors.centerIn: parent + + Text { + text: "Row" + anchors.horizontalCenter: parent.horizontalCenter + } + + Row { + layoutDirection: root.direction + spacing: 10 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 4 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Grid" + anchors.horizontalCenter: parent.horizontalCenter + } + + Grid { + layoutDirection: root.direction + spacing: 10; columns: 4 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 11 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Flow" + anchors.horizontalCenter: parent.horizontalCenter + } + + Flow { + layoutDirection: root.direction + spacing: 10; width: parent.width + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 10 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "ListView" + anchors.horizontalCenter: parent.horizontalCenter + } + + ListView { + id: listView + clip: true + width: parent.width; height: 40 + layoutDirection: root.direction + orientation: Qt.Horizontal + model: 48 + delegate: viewDelegate + } + + Text { + text: "GridView" + anchors.horizontalCenter: parent.horizontalCenter + } + + GridView { + clip: true + width: 200; height: 160 + cellWidth: 50; cellHeight: 50 + layoutDirection: root.direction + model: 48 + delegate: viewDelegate + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.direction ? "Right to left" : "Left to right" + 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 + } + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + if (root.direction == Qt.LeftToRight) { + root.direction = Qt.RightToLeft; + } else { + root.direction = Qt.LeftToRight; + } + } + } + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + 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 + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } + + Component { + id: positionerDelegate + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) + Text { + text: parent.parent.value+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + Component { + id: viewDelegate + Item { + function effectiveLayoutDirection() { + if (LayoutMirroring.enabled) + if (listView.layoutDirection == Qt.LeftToRight) + return Qt.RightToLeft; + else + return Qt.LeftToRight; + else + return listView.layoutDirection; + } + + width: (effectiveLayoutDirection() == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.5+(48 - index)*Math.random()/48, + 0.3+index*Math.random()/48, + 0.3*Math.random(), + 1.0) + Text { + text: index+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + } +} + diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.desktop b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.desktop new file mode 100644 index 0000000..974bd80 --- /dev/null +++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=layoutmirroring +Exec=/opt/layoutmirroring/bin/layoutmirroring +Icon=layoutmirroring64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.pro b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.pro new file mode 100644 index 0000000..ab52726 --- /dev/null +++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.pro @@ -0,0 +1,37 @@ +# Add more folders to ship with the application, here +folder_01.source = qml/layoutmirroring +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE2EC19CA + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(../../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml deleted file mode 100644 index b4065ba..0000000 --- a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - id: root - property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: 400 - height: 875 - 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 - } - - Rectangle { - id: textStrings - width: 148 - height: 85 - color: "white" - anchors.left: parent.left - Column { - spacing: 5 - width: parent.width - anchors { fill: parent; margins: 5 } - Text { - id: englishText - width: parent.width - text: "English text" - } - Text { - id: arabicText - width: parent.width - text: "النص العربي" - } - Text { - id: leftAlignedText - width: parent.width - text: "Text aligned to left" - horizontalAlignment: Text.AlignLeft - } - Text { - id: rightAlignedText - width: parent.width - text: "Text aligned to right" - horizontalAlignment: Text.AlignRight - } - } - } - - 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 - } - Rectangle { - id: items - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 275; height: 95 - anchors.left: parent.left - Rectangle { - y: 5; x: 5 - width: 130; height: 40 - Text { - text: "Item with x: 5\n(not mirrored)" - anchors.centerIn: parent - } - } - Rectangle { - color: Qt.rgba(0.7, 0.7, 0.7) - y: 50; x: mirror(5) - width: 130; height: 40 - function mirror(value) { - return LayoutMirroring.enabled ? (parent.width - width - value) : value; - } - Text { - text: "Item with x: " + parent.x + "\n(manually mirrored)" - anchors.centerIn: parent - } - } - } - Text { - text: "Item anchors" - anchors.left: parent.left - } - - Rectangle { - id: anchoredItems - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 270; height: 170 - anchors.left: parent.left - Rectangle { - id: blackRectangle - color: "black" - width: 180; height: 90 - anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } - Text { - text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." - color: "white" - anchors.centerIn: parent - } - } - Rectangle { - id: whiteRectangle - color: "white" - width: 120; height: 70 - anchors { left: parent.left; bottom: parent.bottom } - Text { - text: "Left side anchored\nto the left side\nof the parent." - color: "black" - anchors.centerIn: parent - } - } - Rectangle { - id: grayRectangle - color: Qt.rgba(0.7, 0.7, 0.7) - width: 140; height: 90 - anchors { right: parent.right; bottom: parent.bottom } - Text { - text: "Right side anchored\nto the right side\nof the parent." - anchors.centerIn: parent - } - } - } - 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 - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject index e526217..53bc7f7 100644 --- a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject +++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject @@ -5,13 +5,13 @@ import QmlProject 1.0 Project { /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { - directory: "." + directory: "qml/layoutmirroring" } JavaScriptFiles { - directory: "." + directory: "qml/layoutmirroring" } ImageFiles { - directory: "." + directory: "qml/layoutmirroring" } /* List of plugin directories passed to QML runtime */ // importPaths: [ " ../exampleplugin " ] diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.svg b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring64.png b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring64.png differ diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring80.png b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring80.png differ diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring_harmattan.desktop b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring_harmattan.desktop new file mode 100644 index 0000000..384ef0f --- /dev/null +++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring_harmattan.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=layoutmirroring +Exec=/usr/bin/single-instance /opt/layoutmirroring/bin/layoutmirroring +Icon=/usr/share/icons/hicolor/80x80/apps/layoutmirroring80.png +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/righttoleft/layoutmirroring/main.cpp b/examples/declarative/righttoleft/layoutmirroring/main.cpp new file mode 100644 index 0000000..2c0639e --- /dev/null +++ b/examples/declarative/righttoleft/layoutmirroring/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +#include "qmlapplicationviewer.h" + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/layoutmirroring/layoutmirroring.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/declarative/righttoleft/layoutmirroring/qml/layoutmirroring/layoutmirroring.qml b/examples/declarative/righttoleft/layoutmirroring/qml/layoutmirroring/layoutmirroring.qml new file mode 100644 index 0000000..b4065ba --- /dev/null +++ b/examples/declarative/righttoleft/layoutmirroring/qml/layoutmirroring/layoutmirroring.qml @@ -0,0 +1,313 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import QtQuick 1.1 + +Rectangle { + id: root + property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: 400 + height: 875 + 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 + } + + Rectangle { + id: textStrings + width: 148 + height: 85 + color: "white" + anchors.left: parent.left + Column { + spacing: 5 + width: parent.width + anchors { fill: parent; margins: 5 } + Text { + id: englishText + width: parent.width + text: "English text" + } + Text { + id: arabicText + width: parent.width + text: "النص العربي" + } + Text { + id: leftAlignedText + width: parent.width + text: "Text aligned to left" + horizontalAlignment: Text.AlignLeft + } + Text { + id: rightAlignedText + width: parent.width + text: "Text aligned to right" + horizontalAlignment: Text.AlignRight + } + } + } + + 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 + } + Rectangle { + id: items + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 275; height: 95 + anchors.left: parent.left + Rectangle { + y: 5; x: 5 + width: 130; height: 40 + Text { + text: "Item with x: 5\n(not mirrored)" + anchors.centerIn: parent + } + } + Rectangle { + color: Qt.rgba(0.7, 0.7, 0.7) + y: 50; x: mirror(5) + width: 130; height: 40 + function mirror(value) { + return LayoutMirroring.enabled ? (parent.width - width - value) : value; + } + Text { + text: "Item with x: " + parent.x + "\n(manually mirrored)" + anchors.centerIn: parent + } + } + } + Text { + text: "Item anchors" + anchors.left: parent.left + } + + Rectangle { + id: anchoredItems + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 270; height: 170 + anchors.left: parent.left + Rectangle { + id: blackRectangle + color: "black" + width: 180; height: 90 + anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } + Text { + text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." + color: "white" + anchors.centerIn: parent + } + } + Rectangle { + id: whiteRectangle + color: "white" + width: 120; height: 70 + anchors { left: parent.left; bottom: parent.bottom } + Text { + text: "Left side anchored\nto the left side\nof the parent." + color: "black" + anchors.centerIn: parent + } + } + Rectangle { + id: grayRectangle + color: Qt.rgba(0.7, 0.7, 0.7) + width: 140; height: 90 + anchors { right: parent.right; bottom: parent.bottom } + Text { + text: "Right side anchored\nto the right side\nof the parent." + anchors.centerIn: parent + } + } + } + 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 + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } +} + diff --git a/examples/declarative/righttoleft/textalignment/main.cpp b/examples/declarative/righttoleft/textalignment/main.cpp new file mode 100644 index 0000000..d7a6def --- /dev/null +++ b/examples/declarative/righttoleft/textalignment/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +#include "qmlapplicationviewer.h" + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/textalignment/textalignment.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/declarative/righttoleft/textalignment/qml/textalignment/textalignment.qml b/examples/declarative/righttoleft/textalignment/qml/textalignment/textalignment.qml new file mode 100644 index 0000000..afd2d68 --- /dev/null +++ b/examples/declarative/righttoleft/textalignment/qml/textalignment/textalignment.qml @@ -0,0 +1,426 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +import QtQuick 1.1 + +Rectangle { + id: root + color: "white" + width: containerColumn.width + height: containerColumn.height + containerColumn.anchors.topMargin + + property bool mirror: false + property variant horizontalAlignment: undefined + + property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] + property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] + property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] + property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] + + function shortText(horizontalAlignment) { + + // all the different QML editors have + // the same alignment values + switch (horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + default: + return "Error"; + } + } + Column { + id: containerColumn + spacing: 10 + width: editorTypeRow.width + anchors { top: parent.top; topMargin: 5 } + Row { + id: editorTypeRow + Repeater { + model: editorType.length + Item { + width: editorColumn.width + height: editorColumn.height + Column { + id: editorColumn + spacing: 5 + width: textColumn.width+10 + Text { + text: root.editorType[index] + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Column { + id: textColumn + spacing: 5 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: textComponents.length + delegate: textComponents[index] + } + } + } + } + } + } + Column { + spacing: 2 + width: parent.width + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "lightgray" + 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 + } + } + MouseArea { + id: mouseArea + property int index: 0 + anchors.fill: parent + onClicked: root.mirror = !root.mirror + } + } + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: { + if (root.horizontalAlignment == undefined) + return "Implict alignment"; + switch (root.horizontalAlignment) { + case Text.AlignLeft: + return "Left alignment"; + case Text.AlignRight: + return "Right alignment"; + case Text.AlignHCenter: + return "Center alignment"; + case Text.AlignJustify: + return "Justify alignment"; + } + } + 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 + } + } + MouseArea { + id: mouseArea2 + property int index: 0 + anchors.fill: parent + onClicked: { + if (index < 0) { + root.horizontalAlignment = undefined; + } else { + root.horizontalAlignment = Math.pow(2, index); + } + index = (index + 2) % 5 - 1; + } + } + } + } + } + + Component { + id: plainTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: styledTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + style: Text.Sunken + styleColor: "white" + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: richTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicRichTextComponent + Text { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) + Rectangle { + z: -1 + color: parent.backgroundColor + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: plainTextEdit + TextEdit { + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicTextEdit + TextEdit { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: textInput + Item { + width: 180 + height: textInput.text.length > 20 ? 3*textInput.height : textInput.height + TextInput { + id: textInput + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.6, 0.4, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + } +} + diff --git a/examples/declarative/righttoleft/textalignment/textalignment.desktop b/examples/declarative/righttoleft/textalignment/textalignment.desktop new file mode 100644 index 0000000..7e932e7 --- /dev/null +++ b/examples/declarative/righttoleft/textalignment/textalignment.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=textalignment +Exec=/opt/textalignment/bin/textalignment +Icon=textalignment64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/righttoleft/textalignment/textalignment.pro b/examples/declarative/righttoleft/textalignment/textalignment.pro new file mode 100644 index 0000000..2db41ec --- /dev/null +++ b/examples/declarative/righttoleft/textalignment/textalignment.pro @@ -0,0 +1,37 @@ +# Add more folders to ship with the application, here +folder_01.source = qml/textalignment +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE061C700 + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(../../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qml b/examples/declarative/righttoleft/textalignment/textalignment.qml deleted file mode 100644 index afd2d68..0000000 --- a/examples/declarative/righttoleft/textalignment/textalignment.qml +++ /dev/null @@ -1,426 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - id: root - color: "white" - width: containerColumn.width - height: containerColumn.height + containerColumn.anchors.topMargin - - property bool mirror: false - property variant horizontalAlignment: undefined - - property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] - property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] - property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] - property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] - - function shortText(horizontalAlignment) { - - // all the different QML editors have - // the same alignment values - switch (horizontalAlignment) { - case Text.AlignLeft: - return "L"; - case Text.AlignRight: - return "R"; - case Text.AlignHCenter: - return "C"; - case Text.AlignJustify: - return "J"; - default: - return "Error"; - } - } - Column { - id: containerColumn - spacing: 10 - width: editorTypeRow.width - anchors { top: parent.top; topMargin: 5 } - Row { - id: editorTypeRow - Repeater { - model: editorType.length - Item { - width: editorColumn.width - height: editorColumn.height - Column { - id: editorColumn - spacing: 5 - width: textColumn.width+10 - Text { - text: root.editorType[index] - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Column { - id: textColumn - spacing: 5 - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: textComponents.length - delegate: textComponents[index] - } - } - } - } - } - } - Column { - spacing: 2 - width: parent.width - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "lightgray" - 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 - } - } - MouseArea { - id: mouseArea - property int index: 0 - anchors.fill: parent - onClicked: root.mirror = !root.mirror - } - } - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: { - if (root.horizontalAlignment == undefined) - return "Implict alignment"; - switch (root.horizontalAlignment) { - case Text.AlignLeft: - return "Left alignment"; - case Text.AlignRight: - return "Right alignment"; - case Text.AlignHCenter: - return "Center alignment"; - case Text.AlignJustify: - return "Justify alignment"; - } - } - 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 - } - } - MouseArea { - id: mouseArea2 - property int index: 0 - anchors.fill: parent - onClicked: { - if (index < 0) { - root.horizontalAlignment = undefined; - } else { - root.horizontalAlignment = Math.pow(2, index); - } - index = (index + 2) % 5 - 1; - } - } - } - } - } - - Component { - id: plainTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: styledTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - style: Text.Sunken - styleColor: "white" - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: richTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicRichTextComponent - Text { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) - Rectangle { - z: -1 - color: parent.backgroundColor - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: plainTextEdit - TextEdit { - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicTextEdit - TextEdit { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: textInput - Item { - width: 180 - height: textInput.text.length > 20 ? 3*textInput.height : textInput.height - TextInput { - id: textInput - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.6, 0.4, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject b/examples/declarative/righttoleft/textalignment/textalignment.qmlproject index e526217..498e35c 100644 --- a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject +++ b/examples/declarative/righttoleft/textalignment/textalignment.qmlproject @@ -5,13 +5,13 @@ import QmlProject 1.0 Project { /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { - directory: "." + directory: "qml/textalignment" } JavaScriptFiles { - directory: "." + directory: "qml/textalignment" } ImageFiles { - directory: "." + directory: "qml/textalignment" } /* List of plugin directories passed to QML runtime */ // importPaths: [ " ../exampleplugin " ] diff --git a/examples/declarative/righttoleft/textalignment/textalignment.svg b/examples/declarative/righttoleft/textalignment/textalignment.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/examples/declarative/righttoleft/textalignment/textalignment.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/righttoleft/textalignment/textalignment64.png b/examples/declarative/righttoleft/textalignment/textalignment64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/declarative/righttoleft/textalignment/textalignment64.png differ diff --git a/examples/declarative/righttoleft/textalignment/textalignment80.png b/examples/declarative/righttoleft/textalignment/textalignment80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/declarative/righttoleft/textalignment/textalignment80.png differ diff --git a/examples/declarative/righttoleft/textalignment/textalignment_harmattan.desktop b/examples/declarative/righttoleft/textalignment/textalignment_harmattan.desktop new file mode 100644 index 0000000..6efad80 --- /dev/null +++ b/examples/declarative/righttoleft/textalignment/textalignment_harmattan.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=textalignment +Exec=/usr/bin/single-instance /opt/textalignment/bin/textalignment +Icon=/usr/share/icons/hicolor/80x80/apps/textalignment80.png +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable -- cgit v0.12