aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-27 12:07:50 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-27 14:18:04 +0000
commit67c4017054baf394062ab4f869d9ca9d299d3354 (patch)
tree378d13bbc1abb7bde11dc1160d9f89130bc9a958 /examples
parentafbfdcff3b3cd14f16736b7c84e04fe9ad61ef8d (diff)
stocqt example: Choose font depending on platform.
The example used the font "Open Sans" which is only available on UNIX platforms and causes it to look baroque on WinRT. Add a settings file specifying the font and override via file selector. Change-Id: I1a9284d928ac57289d75b5fb9477849ac518787b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/demos/stocqt/content/+windows/Settings.qml46
-rw-r--r--examples/quick/demos/stocqt/content/Button.qml3
-rw-r--r--examples/quick/demos/stocqt/content/Settings.qml46
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml5
-rw-r--r--examples/quick/demos/stocqt/content/StockInfo.qml11
-rw-r--r--examples/quick/demos/stocqt/content/StockListView.qml11
-rw-r--r--examples/quick/demos/stocqt/content/StockSettingsPanel.qml9
-rw-r--r--examples/quick/demos/stocqt/content/qmldir10
-rw-r--r--examples/quick/demos/stocqt/stocqt.qrc3
9 files changed, 127 insertions, 17 deletions
diff --git a/examples/quick/demos/stocqt/content/+windows/Settings.qml b/examples/quick/demos/stocqt/content/+windows/Settings.qml
new file mode 100644
index 0000000000..1d4d7edcee
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/+windows/Settings.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+pragma Singleton
+import QtQml 2.0
+
+QtObject {
+ property string fontFamily: "Arial"
+}
diff --git a/examples/quick/demos/stocqt/content/Button.qml b/examples/quick/demos/stocqt/content/Button.qml
index e85a5d41c5..4ef86a2cc3 100644
--- a/examples/quick/demos/stocqt/content/Button.qml
+++ b/examples/quick/demos/stocqt/content/Button.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import "."
Rectangle {
id: button
@@ -54,7 +55,7 @@ Rectangle {
}
Text {
anchors.centerIn: parent
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 19
font.weight: Font.DemiBold
color: button.buttonEnabled ? "#000000" : "#14aaff"
diff --git a/examples/quick/demos/stocqt/content/Settings.qml b/examples/quick/demos/stocqt/content/Settings.qml
new file mode 100644
index 0000000000..39e1c4c241
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/Settings.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+pragma Singleton
+import QtQml 2.0
+
+QtObject {
+ property string fontFamily: "Open Sans"
+}
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
index bbe5b77d0c..147f513456 100644
--- a/examples/quick/demos/stocqt/content/StockChart.qml
+++ b/examples/quick/demos/stocqt/content/StockChart.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import "."
Rectangle {
id: chart
@@ -135,7 +136,7 @@ Rectangle {
Text {
id: fromDate
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 8
anchors.left: parent.left
anchors.bottom: parent.bottom
@@ -145,7 +146,7 @@ Rectangle {
Text {
id: toDate
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 8
anchors.right: parent.right
anchors.rightMargin: canvas.tickMargin
diff --git a/examples/quick/demos/stocqt/content/StockInfo.qml b/examples/quick/demos/stocqt/content/StockInfo.qml
index 50f6b9107e..3c5ee196f2 100644
--- a/examples/quick/demos/stocqt/content/StockInfo.qml
+++ b/examples/quick/demos/stocqt/content/StockInfo.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import "."
Rectangle {
id: root
@@ -60,7 +61,7 @@ Rectangle {
Text {
id: stockIdText
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 28
font.weight: Font.DemiBold
text: root.stock.stockId
@@ -69,7 +70,7 @@ Rectangle {
Text {
id: price
color: "#6d6d6d"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 28
font.weight: Font.DemiBold
text: parseFloat(Math.round(root.stock.stockPrice * 100) / 100).toFixed(2);
@@ -79,7 +80,7 @@ Rectangle {
Text {
id: stockNameText
color: "#0c0c0c"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 16
width: stockColumn.width
elide: Text.ElideRight
@@ -96,7 +97,7 @@ Rectangle {
id: priceChange
horizontalAlignment: Text.AlignRight
color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 18
text: parseFloat(Math.round(root.stock.stockPriceChanged * 100) / 100).toFixed(2);
}
@@ -105,7 +106,7 @@ Rectangle {
id: priceChangePercentage
horizontalAlignment: Text.AlignRight
color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 18
font.weight: Font.DemiBold
text: "(" +
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml
index 470531a21e..d1f735fde3 100644
--- a/examples/quick/demos/stocqt/content/StockListView.qml
+++ b/examples/quick/demos/stocqt/content/StockListView.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import "."
Rectangle {
id: root
@@ -144,7 +145,7 @@ Rectangle {
width: 125
height: 40
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 20
font.weight: Font.Bold
verticalAlignment: Text.AlignVCenter
@@ -160,7 +161,7 @@ Rectangle {
width: 190
height: 40
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 20
font.bold: true
horizontalAlignment: Text.AlignRight
@@ -178,7 +179,7 @@ Rectangle {
width: 135
height: 40
color: "#328930"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 20
font.bold: true
horizontalAlignment: Text.AlignRight
@@ -200,7 +201,7 @@ Rectangle {
width: 330
height: 30
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 16
font.bold: false
elide: Text.ElideRight
@@ -217,7 +218,7 @@ Rectangle {
width: 120
height: 30
color: "#328930"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 18
font.bold: false
horizontalAlignment: Text.AlignRight
diff --git a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
index 7d71355b31..0c34e453de 100644
--- a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
+++ b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import "."
Rectangle {
id: root
@@ -62,7 +63,7 @@ Rectangle {
anchors.left: root.left
anchors.top: root.top
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 19
text: "Open"
}
@@ -73,7 +74,7 @@ Rectangle {
anchors.top: openText.bottom
anchors.topMargin: 10
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 19
text: "Close"
}
@@ -84,7 +85,7 @@ Rectangle {
anchors.top: closeText.bottom
anchors.topMargin: 10
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 19
text: "High"
}
@@ -95,7 +96,7 @@ Rectangle {
anchors.top: highText.bottom
anchors.topMargin: 10
color: "#000000"
- font.family: "Open Sans"
+ font.family: Settings.fontFamily
font.pointSize: 19
text: "Low"
}
diff --git a/examples/quick/demos/stocqt/content/qmldir b/examples/quick/demos/stocqt/content/qmldir
new file mode 100644
index 0000000000..bcfa27b484
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/qmldir
@@ -0,0 +1,10 @@
+singleton Settings 1.0 Settings.qml
+Button 1.0 Button.qml
+CheckBox 1.0 CheckBox.qml
+StockChart 1.0 StockChart.qml
+StockInfo 1.0 StockInfo.qml
+StockListModel 1.0 StockListModel.qml
+StockListView 1.0 StockListView.qml
+StockModel 1.0 StockModel.qml
+StockSettingsPanel 1.0 StockSettingsPanel.qml
+StockView 1.0 StockView.qml
diff --git a/examples/quick/demos/stocqt/stocqt.qrc b/examples/quick/demos/stocqt/stocqt.qrc
index ee5dd0c24f..920e56d4d0 100644
--- a/examples/quick/demos/stocqt/stocqt.qrc
+++ b/examples/quick/demos/stocqt/stocqt.qrc
@@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/demos/stocqt">
<file>stocqt.qml</file>
+ <file>content/qmldir</file>
<file>content/Button.qml</file>
<file>content/CheckBox.qml</file>
<file>content/StockChart.qml</file>
@@ -13,5 +14,7 @@
<file>content/images/icon-left-arrow.png</file>
<file>content/StockSettingsPanel.qml</file>
<file>content/StockInfo.qml</file>
+ <file>content/Settings.qml</file>
+ <file>content/+windows/Settings.qml</file>
</qresource>
</RCC>