diff options
author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-03-03 12:27:25 +0100 |
---|---|---|
committer | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-03-10 10:04:01 +0100 |
commit | ba79f20f3170dd365345c3ba89efbbd754fe474d (patch) | |
tree | 032fda3e3596f77efb375018d168892028243cb0 /examples/quick/text/fonts | |
parent | 8ec8133aa2119bf311bf4f1bf6db25d6705204b7 (diff) |
Text example: adhere to guidelines
- mark readonly properties as readonly.
- Use qsTr() on user facing strings that would be sensible to localize.
- Removed unused lines of code.
- Separate lines with multiple bindings into multiple lines instead.
Pick-to: 6.5
Change-Id: I9664cc2291be2f642dc2d9d27b6c356880a491c7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/quick/text/fonts')
-rw-r--r-- | examples/quick/text/fonts/availableFonts.qml | 7 | ||||
-rw-r--r-- | examples/quick/text/fonts/banner.qml | 31 | ||||
-rw-r--r-- | examples/quick/text/fonts/fonts.qml | 51 | ||||
-rw-r--r-- | examples/quick/text/fonts/hello.qml | 29 |
4 files changed, 92 insertions, 26 deletions
diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml index 2564bb6447..7f4f938b48 100644 --- a/examples/quick/text/fonts/availableFonts.qml +++ b/examples/quick/text/fonts/availableFonts.qml @@ -4,7 +4,9 @@ import QtQuick Rectangle { - width: 320; height: 480; color: "steelblue" + width: 320 + height: 480 + color: "steelblue" ListView { anchors.fill: parent @@ -13,7 +15,8 @@ Rectangle { //! [model] delegate: Item { - height: 40; width: ListView.view.width + height: 40 + width: ListView.view.width required property string modelData Text { anchors.centerIn: parent diff --git a/examples/quick/text/fonts/banner.qml b/examples/quick/text/fonts/banner.qml index 2c0742018a..aae93baea2 100644 --- a/examples/quick/text/fonts/banner.qml +++ b/examples/quick/text/fonts/banner.qml @@ -8,17 +8,36 @@ Rectangle { property int pixelSize: screen.height * 1.25 property color textColor: "lightsteelblue" - property string text: "Hello world! " + readonly property string text: qsTr("Hello world! ") - width: 320; height: 480 + width: 320 + height: 480 color: "steelblue" Row { y: -screen.height / 4.5 - NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } - Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + NumberAnimation on x { + from: 0 + to: -text.width + duration: 6000 + loops: Animation.Infinite + } + Text { + id: text + font.pixelSize: screen.pixelSize + color: screen.textColor + text: screen.text + } + Text { + font.pixelSize: screen.pixelSize + color: screen.textColor + text: screen.text + } + Text { + font.pixelSize: screen.pixelSize + color: screen.textColor + text: screen.text + } } } diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml index 8e0f906493..84cb6baa20 100644 --- a/examples/quick/text/fonts/fonts.qml +++ b/examples/quick/text/fonts/fonts.qml @@ -5,20 +5,32 @@ import QtQuick Rectangle { id: root - property string myText: "The quick brown fox jumps over the lazy dog." + readonly property string myText: qsTr("The quick brown fox jumps over the lazy dog.") - width: 320; height: 480 + width: 320 + height: 480 color: "steelblue" //! [fontloaderlocal] - FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" } + FontLoader { + id: localFont + source: "content/fonts/tarzeau_ocr_a.ttf" + } //! [fontloaderlocal] //! [fontloaderremote] - FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + FontLoader { + id: webFont + source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" + } //! [fontloaderremote] Column { - anchors { fill: parent; leftMargin: 10; rightMargin: 10; topMargin: 10 } + anchors { + fill: parent + leftMargin: 10 + rightMargin: 10 + topMargin: 10 + } spacing: 15 Text { @@ -37,7 +49,11 @@ Rectangle { width: parent.width wrapMode: Text.WordWrap horizontalAlignment: Text.AlignHCenter - font { family: "Times"; pixelSize: 20; capitalization: Font.AllUppercase } + font { + family: "Times" + pixelSize: 20 + capitalization: Font.AllUppercase + } } Text { text: root.myText @@ -45,21 +61,35 @@ Rectangle { width: parent.width horizontalAlignment: Text.AlignRight wrapMode: Text.WordWrap - font { family: "Courier"; pixelSize: 20; weight: Font.Bold; capitalization: Font.AllLowercase } + font { + family: "Courier" + pixelSize: 20 + weight: Font.Bold + capitalization: Font.AllLowercase + } } Text { text: root.myText color: "lightsteelblue" width: parent.width wrapMode: Text.WordWrap - font { family: "Courier"; pixelSize: 20; italic: true; capitalization: Font.SmallCaps } + font { + family: "Courier" + pixelSize: 20 + italic: true + capitalization: Font.SmallCaps + } } Text { text: root.myText color: "lightsteelblue" width: parent.width wrapMode: Text.WordWrap - font { family: localFont.name; pixelSize: 20; capitalization: Font.Capitalize } + font { + family: localFont.name + pixelSize: 20 + capitalization: Font.Capitalize + } } Text { text: { @@ -70,7 +100,8 @@ Rectangle { color: "lightsteelblue" width: parent.width wrapMode: Text.WordWrap - font.family: webFont.name; font.pixelSize: 20 + font.family: webFont.name + font.pixelSize: 20 } } } diff --git a/examples/quick/text/fonts/hello.qml b/examples/quick/text/fonts/hello.qml index e0cdc26ea6..89760b0b4b 100644 --- a/examples/quick/text/fonts/hello.qml +++ b/examples/quick/text/fonts/hello.qml @@ -6,24 +6,31 @@ import QtQuick Rectangle { id: screen - width: 320; height: 480 + width: 320 + height: 480 color: "black" Item { id: container - x: screen.width / 2; y: screen.height / 2 + x: screen.width / 2 + y: screen.height / 2 Text { id: text anchors.centerIn: parent color: "white" - text: "Hello world!" + text: qsTr("Hello world!") font.pixelSize: 32 //! [letterspacing] SequentialAnimation on font.letterSpacing { - loops: Animation.Infinite; - NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 } + loops: Animation.Infinite + NumberAnimation { + from: 0 + to: 50 + easing.type: Easing.InQuad + duration: 3000 + } ScriptAction { script: { container.y = (screen.height / 4) + (Math.random() * screen.height / 2) @@ -34,9 +41,15 @@ Rectangle { //! [letterspacing] SequentialAnimation on opacity { - loops: Animation.Infinite; - NumberAnimation { from: 1; to: 0; duration: 2600 } - PauseAnimation { duration: 400 } + loops: Animation.Infinite + NumberAnimation { + from: 1 + to: 0 + duration: 2600 + } + PauseAnimation { + duration: 400 + } } } } |