From 67c4017054baf394062ab4f869d9ca9d299d3354 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Jan 2016 12:07:50 +0100 Subject: 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 --- .../demos/stocqt/content/+windows/Settings.qml | 46 ++++++++++++++++++++++ examples/quick/demos/stocqt/content/Button.qml | 3 +- examples/quick/demos/stocqt/content/Settings.qml | 46 ++++++++++++++++++++++ examples/quick/demos/stocqt/content/StockChart.qml | 5 ++- examples/quick/demos/stocqt/content/StockInfo.qml | 11 +++--- .../quick/demos/stocqt/content/StockListView.qml | 11 +++--- .../demos/stocqt/content/StockSettingsPanel.qml | 9 +++-- examples/quick/demos/stocqt/content/qmldir | 10 +++++ examples/quick/demos/stocqt/stocqt.qrc | 3 ++ 9 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 examples/quick/demos/stocqt/content/+windows/Settings.qml create mode 100644 examples/quick/demos/stocqt/content/Settings.qml create mode 100644 examples/quick/demos/stocqt/content/qmldir 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 @@ stocqt.qml + content/qmldir content/Button.qml content/CheckBox.qml content/StockChart.qml @@ -13,5 +14,7 @@ content/images/icon-left-arrow.png content/StockSettingsPanel.qml content/StockInfo.qml + content/Settings.qml + content/+windows/Settings.qml -- cgit v1.2.1