From 32a11f3f6ce1867383cbbbbcce78b07121e0bd24 Mon Sep 17 00:00:00 2001 From: johnny9 <985648+johnny9@users.noreply.github.com> Date: Tue, 21 Feb 2023 22:10:28 -0500 Subject: [PATCH] qml: introduce CoreText control --- src/Makefile.qt.include | 1 + src/qml/bitcoin_qml.qrc | 1 + src/qml/components/NetworkIndicator.qml | 7 ++----- src/qml/controls/ContinueButton.qml | 11 +++-------- src/qml/controls/CoreText.qml | 18 ++++++++++++++++++ src/qml/controls/ExternalLink.qml | 5 ++--- src/qml/controls/NavButton.qml | 8 +++----- src/qml/controls/OutlineButton.qml | 10 +++------- src/qml/controls/TextButton.qml | 9 +++------ 9 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 src/qml/controls/CoreText.qml diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index ee7c15b6c7..4e58e3a917 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -345,6 +345,7 @@ QML_RES_QML = \ qml/components/StorageOptions.qml \ qml/components/StorageSettings.qml \ qml/controls/ContinueButton.qml \ + qml/controls/CoreText.qml \ qml/controls/ExternalLink.qml \ qml/controls/Header.qml \ qml/controls/InformationPage.qml \ diff --git a/src/qml/bitcoin_qml.qrc b/src/qml/bitcoin_qml.qrc index 614719159a..eaf7b08647 100644 --- a/src/qml/bitcoin_qml.qrc +++ b/src/qml/bitcoin_qml.qrc @@ -15,6 +15,7 @@ components/StorageOptions.qml components/StorageSettings.qml controls/ContinueButton.qml + controls/CoreText.qml controls/ExternalLink.qml controls/Header.qml controls/InformationPage.qml diff --git a/src/qml/components/NetworkIndicator.qml b/src/qml/components/NetworkIndicator.qml index 0f2fdac05d..0d41d712e2 100644 --- a/src/qml/components/NetworkIndicator.qml +++ b/src/qml/components/NetworkIndicator.qml @@ -13,17 +13,14 @@ Button { id: root property color bgColor property int textSize: 15 - font.family: "Inter" - font.styleName: "Regular" - font.pixelSize: root.textSize topPadding: 2 bottomPadding: 2 leftPadding: 7 rightPadding: 7 state: chainModel.currentNetworkName - contentItem: Text { + contentItem: CoreText { text: root.text - font: root.font + font.pixelSize: root.textSize color: Theme.color.white horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter diff --git a/src/qml/controls/ContinueButton.qml b/src/qml/controls/ContinueButton.qml index c63ef96099..cb43b9ff2f 100644 --- a/src/qml/controls/ContinueButton.qml +++ b/src/qml/controls/ContinueButton.qml @@ -7,16 +7,11 @@ import QtQuick.Controls 2.15 Button { id: root - font.family: "Inter" - font.styleName: "Semi Bold" - font.pixelSize: 18 hoverEnabled: true - contentItem: Text { + contentItem: CoreText { text: parent.text - font: parent.font - color: Theme.color.white - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + bold: true + font.pixelSize: 18 } background: Rectangle { id: bg diff --git a/src/qml/controls/CoreText.qml b/src/qml/controls/CoreText.qml new file mode 100644 index 0000000000..8e10272bbe --- /dev/null +++ b/src/qml/controls/CoreText.qml @@ -0,0 +1,18 @@ +// Copyright (c) 2023 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +Text { + property bool bold: false + property bool wrap: true + color: Theme.color.white + font.family: "Inter" + font.styleName: bold ? "Semi Bold" : "Regular" + font.pixelSize: 13 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: wrap ? Text.WordWrap : Text.NoWrap +} diff --git a/src/qml/controls/ExternalLink.qml b/src/qml/controls/ExternalLink.qml index a16acc3a8d..7cf80f3113 100644 --- a/src/qml/controls/ExternalLink.qml +++ b/src/qml/controls/ExternalLink.qml @@ -45,13 +45,12 @@ AbstractButton { Layout.fillWidth: true active: root.description.length > 0 visible: active - sourceComponent: Text { - font.family: "Inter" - font.styleName: "Regular" + sourceComponent: CoreText { font.pixelSize: root.descriptionSize color: root.textColor textFormat: Text.RichText text: root.description + wrap: false Behavior on color { ColorAnimation { duration: 150 } diff --git a/src/qml/controls/NavButton.qml b/src/qml/controls/NavButton.qml index 336e65a9d6..dde4acb32e 100644 --- a/src/qml/controls/NavButton.qml +++ b/src/qml/controls/NavButton.qml @@ -74,12 +74,10 @@ AbstractButton { bottomPadding: button_background.active ? 0 : 4 rightPadding: 0 leftPadding: button_background.active ? 0 : 20 - font.family: "Inter" - font.styleName: "Semi Bold" - font.pixelSize: root.textSize - contentItem: Text { + contentItem: CoreText { anchors.verticalCenter: parent.verticalCenter - font: container.font + bold: true + font.pixelSize: root.textSize color: Theme.color.neutral9 text: root.text } diff --git a/src/qml/controls/OutlineButton.qml b/src/qml/controls/OutlineButton.qml index 1d0e5d1512..927913f4e4 100644 --- a/src/qml/controls/OutlineButton.qml +++ b/src/qml/controls/OutlineButton.qml @@ -7,16 +7,12 @@ import QtQuick.Controls 2.15 Button { id: root - font.family: "Inter" - font.styleName: "Semi Bold" - font.pixelSize: 18 hoverEnabled: true - contentItem: Text { + contentItem: CoreText { text: parent.text - font: parent.font + bold: true + font.pixelSize: 18 color: Theme.color.neutral9 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter } background: Rectangle { id: bg diff --git a/src/qml/controls/TextButton.qml b/src/qml/controls/TextButton.qml index 87de3f476d..b1d17acba3 100644 --- a/src/qml/controls/TextButton.qml +++ b/src/qml/controls/TextButton.qml @@ -12,17 +12,14 @@ Button { property color bgColor: Theme.color.background property bool bold: true property bool rightalign: false - font.family: "Inter" - font.styleName: bold ? "Semi Bold" : "Regular" - font.pixelSize: root.textSize padding: 15 hoverEnabled: true - contentItem: Text { + contentItem: CoreText { text: root.text - font: root.font + bold: root.bold + font.pixelSize: root.textSize color: root.textColor horizontalAlignment: rightalign ? Text.AlignRight : Text.AlignHCenter - verticalAlignment: Text.AlignVCenter Behavior on color { ColorAnimation { duration: 150 } }