aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/text/fonts/availableFonts.qml4
-rw-r--r--examples/quick/text/fonts/banner.qml2
-rw-r--r--examples/quick/text/fonts/fonts.qml30
-rw-r--r--examples/quick/text/fonts/hello.qml6
-rw-r--r--examples/quick/text/imgtag/TextWithImage.qml6
-rw-r--r--examples/quick/text/imgtag/imgtag.qml10
-rw-r--r--examples/quick/text/main.cpp41
-rw-r--r--examples/quick/text/styledtext-layout.qml48
-rw-r--r--examples/quick/text/text.pro10
-rw-r--r--examples/quick/text/text.qml14
10 files changed, 96 insertions, 75 deletions
diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml
index 0b87259556..63a74d269b 100644
--- a/examples/quick/text/fonts/availableFonts.qml
+++ b/examples/quick/text/fonts/availableFonts.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
Rectangle {
- width: 480; height: 640; color: "steelblue"
+ width: 320; height: 480; color: "steelblue"
ListView {
anchors.fill: parent; model: Qt.fontFamilies()
@@ -50,7 +50,7 @@ Rectangle {
height: 40; width: ListView.view.width
Text {
anchors.centerIn: parent
- text: modelData; font.family: modelData; font.pixelSize: 24; color: "white"
+ text: modelData; font.family: modelData; font.pixelSize: 20; color: "white"
}
}
}
diff --git a/examples/quick/text/fonts/banner.qml b/examples/quick/text/fonts/banner.qml
index 6c9aa25fa1..7f690c24c3 100644
--- a/examples/quick/text/fonts/banner.qml
+++ b/examples/quick/text/fonts/banner.qml
@@ -47,7 +47,7 @@ Rectangle {
property color textColor: "lightsteelblue"
property string text: "Hello world! "
- width: 640; height: 320
+ width: 320; height: 480
color: "steelblue"
Row {
diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml
index 78cef25eae..f0e9b60bc5 100644
--- a/examples/quick/text/fonts/fonts.qml
+++ b/examples/quick/text/fonts/fonts.qml
@@ -43,7 +43,7 @@ import QtQuick 2.0
Rectangle {
property string myText: "The quick brown fox jumps over the lazy dog."
- width: 800; height: 480
+ width: 320; height: 480
color: "steelblue"
FontLoader { id: fixedFont; name: "Courier" }
@@ -51,43 +51,45 @@ Rectangle {
FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
Column {
- anchors { fill: parent; leftMargin: 10; rightMargin: 10 }
+ anchors { fill: parent; leftMargin: 10; rightMargin: 10; topMargin: 10 }
spacing: 15
Text {
text: myText
color: "lightsteelblue"
width: parent.width
- elide: Text.ElideRight
- font.family: "Times"; font.pointSize: 42
+ wrapMode: Text.WordWrap
+ font.family: "Times"; font.pixelSize: 20
}
Text {
text: myText
color: "lightsteelblue"
width: parent.width
- elide: Text.ElideLeft
- font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase }
+ wrapMode: Text.WordWrap
+ horizontalAlignment: Text.AlignHCenter
+ font { family: "Times"; pixelSize: 20; capitalization: Font.AllUppercase }
}
Text {
text: myText
color: "lightsteelblue"
width: parent.width
- elide: Text.ElideMiddle
- font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase }
+ horizontalAlignment: Text.AlignRight
+ wrapMode: Text.WordWrap
+ font { family: fixedFont.name; pixelSize: 20; weight: Font.Bold; capitalization: Font.AllLowercase }
}
Text {
text: myText
color: "lightsteelblue"
width: parent.width
- elide: Text.ElideRight
- font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps }
+ wrapMode: Text.WordWrap
+ font { family: fixedFont.name; pixelSize: 20; italic: true; capitalization: Font.SmallCaps }
}
Text {
text: myText
color: "lightsteelblue"
width: parent.width
- elide: Text.ElideLeft
- font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize }
+ wrapMode: Text.WordWrap
+ font { family: localFont.name; pixelSize: 20; capitalization: Font.Capitalize }
}
Text {
text: {
@@ -97,8 +99,8 @@ Rectangle {
}
color: "lightsteelblue"
width: parent.width
- elide: Text.ElideMiddle
- font.family: webFont.name; font.pointSize: 42
+ wrapMode: Text.WordWrap
+ font.family: webFont.name; font.pixelSize: 20
}
}
}
diff --git a/examples/quick/text/fonts/hello.qml b/examples/quick/text/fonts/hello.qml
index d9479fb208..8920329ddb 100644
--- a/examples/quick/text/fonts/hello.qml
+++ b/examples/quick/text/fonts/hello.qml
@@ -43,7 +43,7 @@ import QtQuick 2.0
Rectangle {
id: screen
- width: 800; height: 480
+ width: 320; height: 480
color: "black"
Item {
@@ -55,12 +55,12 @@ Rectangle {
anchors.centerIn: parent
color: "white"
text: "Hello world!"
- font.pixelSize: 60
+ font.pixelSize: 32
smooth: true
SequentialAnimation on font.letterSpacing {
loops: Animation.Infinite;
- NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 }
+ NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 }
ScriptAction {
script: {
container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
diff --git a/examples/quick/text/imgtag/TextWithImage.qml b/examples/quick/text/imgtag/TextWithImage.qml
index bc09aa2a52..5e6fba5df4 100644
--- a/examples/quick/text/imgtag/TextWithImage.qml
+++ b/examples/quick/text/imgtag/TextWithImage.qml
@@ -46,10 +46,4 @@ Text {
wrapMode: Text.WordWrap
textFormat: Text.StyledText
horizontalAlignment: main.hAlign
-
- Rectangle {
- border.color: "#efefef"
- color: "transparent"
- anchors.fill: parent
- }
}
diff --git a/examples/quick/text/imgtag/imgtag.qml b/examples/quick/text/imgtag/imgtag.qml
index 9d181af2cb..a28a4911c4 100644
--- a/examples/quick/text/imgtag/imgtag.qml
+++ b/examples/quick/text/imgtag/imgtag.qml
@@ -44,6 +44,7 @@ Rectangle {
id: main
width: 320; height: 480
focus: true
+ color: "#dedede"
property var hAlign: Text.AlignLeft
@@ -62,18 +63,13 @@ Rectangle {
text: "This is a <b>happy</b> face<img src=\"images/face-smile.png\">"
}
TextWithImage {
- text: "This is a <b>very<img src=\"images/face-smile-big.png\" align=\"middle\"/>happy</b> face aligned in the middle."
- }
- TextWithImage {
- elide: Text.ElideRight
- maximumLineCount: 2
- text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis<img src=\"images/face-sad.png\" align=\"top\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis."
+ text: "This is a <b>very<img src=\"images/face-smile-big.png\" align=\"middle\"/>happy</b> face vertically aligned in the middle."
}
TextWithImage {
text: "This is a tiny<img src=\"images/face-smile.png\" width=\"15\" height=\"15\">happy face."
}
TextWithImage {
- text: "This is a starfish<img src=\"images/starfish_2.png\" width=\"50\" height=\"50\" align=\"top\">aligned to the top and another one<img src=\"images/heart200.png\" width=\"50\" height=\"50\">aligned to the bottom."
+ text: "This is a<img src=\"images/starfish_2.png\" width=\"50\" height=\"50\" align=\"top\">aligned to the top and a<img src=\"images/heart200.png\" width=\"50\" height=\"50\">aligned to the bottom."
}
TextWithImage {
text: "Qt logos<img src=\"images/qtlogo.png\" width=\"55\" height=\"60\" align=\"middle\"><img src=\"images/qtlogo.png\" width=\"37\" height=\"40\" align=\"middle\"><img src=\"images/qtlogo.png\" width=\"18\" height=\"20\" align=\"middle\">aligned in the middle with different sizes."
diff --git a/examples/quick/text/main.cpp b/examples/quick/text/main.cpp
new file mode 100644
index 0000000000..0c896d9ab7
--- /dev/null
+++ b/examples/quick/text/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(text)
diff --git a/examples/quick/text/styledtext-layout.qml b/examples/quick/text/styledtext-layout.qml
index 4571330568..cb5e1ad277 100644
--- a/examples/quick/text/styledtext-layout.qml
+++ b/examples/quick/text/styledtext-layout.qml
@@ -46,12 +46,7 @@ Rectangle {
focus: true
property real offset: 0
- property real margin: 10
-
- Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft
- Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter
- Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight
- Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify
+ property real margin: 8
Text {
id: myText
@@ -59,47 +54,18 @@ Rectangle {
anchors.margins: 10
wrapMode: Text.WordWrap
font.family: "Times New Roman"
- font.pixelSize: 13
+ font.pixelSize: 14
textFormat: Text.StyledText
horizontalAlignment: Text.AlignJustify
- text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis <a href=\"www.nokia.com\">www.nokia.com</a>.<br/>Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.<br><ul type=\"bullet\"><li>Coffee<ol type=\"a\"><li>Espresso<li><b>Cappuccino</b><li><i>Flat White</i><li>Latte</ol><li>Juice<ol type=\"1\"><li>Orange</li><li>Apple</li><li>Pineapple</li><li>Tomato</li></ol></li></ul><p><font color=\"#434343\"><i>Proin consectetur <b>sapien</b> in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit."
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui <a href=\"www.nokia.com\">www.nokia.com</a>.<br/>Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Nunc blandit condimentum odio vel egestas.<br><ul type=\"bullet\"><li>Coffee<ol type=\"a\"><li>Espresso<li>Cappuccino<li>Latte</ol><li>Juice<ol type=\"1\"><li>Orange</li><li>Apple</li><li>Pineapple</li><li>Tomato</li></ol></li></ul><p><font color=\"#434343\"><i>Proin consectetur <b>sapien</b> in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci."
onLineLaidOut: {
- line.width = width / 2 - (2 * margin)
- if (line.number === 30) {
- main.offset = line.y
- }
- if (line.number >= 30) {
- line.x = width / 2 + margin
- line.y -= main.offset
- }
- if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) {
- if (line.number < 30)
- line.width = Math.min((rect.x - line.x), line.width)
- else {
- line.x = Math.max((rect.x + rect.width), width / 2 + margin)
- line.width = Math.min((width - margin - line.x), line.width)
- }
- }
- }
-
- Item {
- id: rect
- x: 28; y: 20
- width: 60; height: 60
+ line.width = width / 2 - (margin)
- Rectangle {
- anchors { fill: parent; leftMargin: 2; rightMargin: 2 }
- color: "lightsteelblue"; opacity: 0.3
- }
-
- MouseArea {
- anchors.fill: parent
- drag.target: rect
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1
- onPositionChanged: myText.doLayout()
+ if (line.y + line.height >= height) {
+ line.y -= height - margin
+ line.x = width / 2 + margin
}
}
}
diff --git a/examples/quick/text/text.pro b/examples/quick/text/text.pro
new file mode 100644
index 0000000000..ecd0762eda
--- /dev/null
+++ b/examples/quick/text/text.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick declarative
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/text
+qml.files = fonts imgtag styledtext-layout.qml text.qml textselection
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/text
+INSTALLS += target qml
+
diff --git a/examples/quick/text/text.qml b/examples/quick/text/text.qml
index 9bfd290059..e9c40773c9 100644
--- a/examples/quick/text/text.qml
+++ b/examples/quick/text/text.qml
@@ -40,10 +40,20 @@
import QtQuick 2.0
import "../../shared"
+/*!
+ \title QML Examples - Text
+ \example declarative/text
+ \brief This is a collection of QML examples
+ \image qml-text-example.png
+
+ This is a collection of small QML examples relating to text. Each example is
+ a small QML file, usually containing or emphasizing a particular element or
+ feature. You can run and observe the behavior of each example.
+*/
Item {
height: 480
- width: 480
+ width: 320
LauncherList {
id: ll
anchors.fill: parent
@@ -52,6 +62,8 @@ Item {
addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml"));
addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml"));
addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml"));
+ addExample("Img tag", "Embedding images into text", Qt.resolvedUrl("imgtag/imgtag.qml"));
+ addExample("Text Layout", "Flowing text around items", Qt.resolvedUrl("styledtext-layout.qml"));
}
}
}