From 2bd516d07b7ffa6054e7f11fbea9e9905d7c0785 Mon Sep 17 00:00:00 2001 From: jarolrod Date: Wed, 1 Feb 2023 02:07:55 -0500 Subject: [PATCH 1/2] qml: add CaretRightButton component This encapsulates a commonly used button into a reusable component. --- src/Makefile.qt.include | 1 + src/qml/bitcoin_qml.qrc | 1 + src/qml/components/CaretRightButton.qml | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/qml/components/CaretRightButton.qml diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index f08aa2d6df..2f5994b3c5 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -330,6 +330,7 @@ QML_RES_QML = \ qml/components/AboutOptions.qml \ qml/components/BlockClock.qml \ qml/components/BlockCounter.qml \ + qml/components/CaretRightButton.qml \ qml/components/ConnectionOptions.qml \ qml/components/ConnectionSettings.qml \ qml/components/DeveloperOptions.qml \ diff --git a/src/qml/bitcoin_qml.qrc b/src/qml/bitcoin_qml.qrc index 3b0b990284..11b01dbf19 100644 --- a/src/qml/bitcoin_qml.qrc +++ b/src/qml/bitcoin_qml.qrc @@ -3,6 +3,7 @@ components/AboutOptions.qml components/BlockClock.qml components/BlockCounter.qml + components/CaretRightButton.qml components/ConnectionOptions.qml components/ConnectionSettings.qml components/DeveloperOptions.qml diff --git a/src/qml/components/CaretRightButton.qml b/src/qml/components/CaretRightButton.qml new file mode 100644 index 0000000000..9d113195ae --- /dev/null +++ b/src/qml/components/CaretRightButton.qml @@ -0,0 +1,20 @@ +// 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 + +Button { + id: root + required property color stateColor + icon.source: "image://images/caret-right" + icon.color: root.stateColor + icon.height: 18 + icon.width: 18 + background: null + + Behavior on icon.color { + ColorAnimation { duration: 150 } + } +} From 624d985542c0983e8e0e33baa1bf47b137373d82 Mon Sep 17 00:00:00 2001 From: jarolrod Date: Wed, 1 Feb 2023 02:08:16 -0500 Subject: [PATCH 2/2] qml: use CaretRightButton, bind to Setting state color --- src/qml/components/AboutOptions.qml | 9 +++----- src/qml/components/ConnectionSettings.qml | 9 +++----- src/qml/pages/node/NodeSettings.qml | 27 ++++++++--------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/qml/components/AboutOptions.qml b/src/qml/components/AboutOptions.qml index d7eda1235f..d14d91dde9 100644 --- a/src/qml/components/AboutOptions.qml +++ b/src/qml/components/AboutOptions.qml @@ -58,15 +58,12 @@ ColumnLayout { onClicked: loadedItem.clicked() } Setting { + id: gotoDeveloper Layout.fillWidth: true header: qsTr("Developer options") description: qsTr("Only use these if you have development experience") - actionItem: Button { - icon.source: "image://images/caret-right" - icon.color: Theme.color.neutral9 - icon.height: 18 - icon.width: 18 - background: null + actionItem: CaretRightButton{ + stateColor: gotoDeveloper.stateColor onClicked: { aboutSwipe.incrementCurrentIndex() } diff --git a/src/qml/components/ConnectionSettings.qml b/src/qml/components/ConnectionSettings.qml index d2897c3cf4..5a49cc933c 100644 --- a/src/qml/components/ConnectionSettings.qml +++ b/src/qml/components/ConnectionSettings.qml @@ -59,15 +59,12 @@ ColumnLayout { } } Setting { + id: gotoProxy last: true Layout.fillWidth: true header: qsTr("Proxy settings") - actionItem: Button { - icon.source: "image://images/caret-right" - icon.color: Theme.color.neutral9 - icon.height: 18 - icon.width: 18 - background: null + actionItem: CaretRightButton { + stateColor: gotoProxy.stateColor } } } diff --git a/src/qml/pages/node/NodeSettings.qml b/src/qml/pages/node/NodeSettings.qml index 84dd9fbe55..621fade517 100644 --- a/src/qml/pages/node/NodeSettings.qml +++ b/src/qml/pages/node/NodeSettings.qml @@ -47,14 +47,11 @@ Item { onClicked: loadedItem.toggled() } Setting { + id: gotoAbout Layout.fillWidth: true header: qsTr("About") - actionItem: Button { - icon.source: "image://images/caret-right" - icon.color: Theme.color.neutral9 - icon.height: 18 - icon.width: 18 - background: null + actionItem: CaretRightButton { + stateColor: gotoAbout.stateColor onClicked: { nodeSettingsView.push(about_page) } @@ -62,14 +59,11 @@ Item { onClicked: loadedItem.clicked() } Setting { + id: gotoStorage Layout.fillWidth: true header: qsTr("Storage") - actionItem: Button { - icon.source: "image://images/caret-right" - icon.color: Theme.color.neutral9 - icon.height: 18 - icon.width: 18 - background: null + actionItem: CaretRightButton { + stateColor: gotoStorage.stateColor onClicked: { nodeSettingsView.push(storage_page) } @@ -77,14 +71,11 @@ Item { onClicked: loadedItem.clicked() } Setting { + id: gotoConnection Layout.fillWidth: true header: qsTr("Connection") - actionItem: Button { - icon.source: "image://images/caret-right" - icon.color: Theme.color.neutral9 - icon.height: 18 - icon.width: 18 - background: null + actionItem: CaretRightButton { + stateColor: gotoConnection.stateColor onClicked: { nodeSettingsView.push(connection_page) }