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>
This commit is contained in:
parent
afbfdcff3b
commit
67c4017054
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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: "(" +
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue