Skip to content

Commit aa35088

Browse files
committed
Merge #355: Icon control
000837b qml: use Icon control (João Barbosa) 8dfe391 qml: add Icon control (João Barbosa) Pull request description: `Button` control is used to show icons because it has support to colorize the image. `Button` is packed with more stuff like states, event handling, label... eventually a light component should be used instead. For now, abstract the usage of `Button` in the new `Icon` control and use it in trivial places. There are more places where `Icon` can be used but require more changes, so I'm leaving them for follow-ups. ACKs for top commit: jarolrod: ACK 000837b johnny9: ACK 000837b Tree-SHA512: 3211ed13a23e1ade93b74bbe25abcb9b82eee3ae66642688b47e49939af1132a6be18e40c3c4dcbd4a9928dd94abc3c8c1279e9a6117817a5ec3261207269849
2 parents ddbc0ea + 000837b commit aa35088

File tree

8 files changed

+55
-60
lines changed

8 files changed

+55
-60
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ QML_RES_QML = \
362362
qml/controls/ExternalLink.qml \
363363
qml/controls/FocusBorder.qml \
364364
qml/controls/Header.qml \
365+
qml/controls/Icon.qml \
365366
qml/controls/InformationPage.qml \
366367
qml/controls/NavButton.qml \
367368
qml/controls/PageIndicator.qml \

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<file>controls/ExternalLink.qml</file>
2424
<file>controls/FocusBorder.qml</file>
2525
<file>controls/Header.qml</file>
26+
<file>controls/Icon.qml</file>
2627
<file>controls/InformationPage.qml</file>
2728
<file>controls/NavButton.qml</file>
2829
<file>controls/PageIndicator.qml</file>

src/qml/components/BlockClock.qml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,13 @@ Item {
6767
}
6868
}
6969

70-
Button {
70+
Icon {
7171
id: bitcoinIcon
72-
background: null
73-
icon.source: "image://images/bitcoin-circle"
74-
icon.color: Theme.color.neutral9
75-
icon.width: Math.max(dial.width / 5, 1)
76-
icon.height: Math.max(dial.width / 5, 1)
72+
source: "image://images/bitcoin-circle"
73+
color: Theme.color.neutral9
74+
size: Math.max(dial.width / 5, 1)
7775
anchors.bottom: mainText.top
7876
anchors.horizontalCenter: root.horizontalCenter
79-
80-
Behavior on icon.color {
81-
ColorAnimation { duration: 150 }
82-
}
8377
}
8478

8579
Label {

src/qml/components/CaretRightButton.qml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,13 @@
44

55
import QtQuick 2.15
66
import QtQuick.Controls 2.15
7+
import "../controls"
78

8-
Button {
9+
Icon {
910
id: root
1011
required property color stateColor
11-
12-
leftPadding: 0
13-
topPadding: 0
14-
bottomPadding: 0
15-
icon.source: "image://images/caret-right"
16-
icon.color: root.stateColor
17-
icon.height: 18
18-
icon.width: 18
19-
background: null
20-
21-
Behavior on icon.color {
22-
ColorAnimation { duration: 150 }
23-
}
12+
enabled: true
13+
source: "image://images/caret-right"
14+
color: root.stateColor
15+
size: 18
2416
}

src/qml/components/ThemeSettings.qml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@ ColumnLayout {
1919
Setting {
2020
Layout.fillWidth: true
2121
header: qsTr("Light")
22-
actionItem: Button {
22+
actionItem: Icon {
2323
anchors.centerIn: parent
2424
visible: !Theme.dark
25-
icon.source: "image://images/check"
26-
icon.color: Theme.color.neutral9
27-
icon.height: 24
28-
icon.width: 24
29-
background: null
30-
31-
Behavior on icon.color {
32-
ColorAnimation { duration: 150 }
33-
}
25+
source: "image://images/check"
26+
color: Theme.color.neutral9
27+
size: 24
3428
}
3529
onClicked: {
3630
Theme.dark = false
@@ -40,18 +34,12 @@ ColumnLayout {
4034
Setting {
4135
Layout.fillWidth: true
4236
header: qsTr("Dark")
43-
actionItem: Button {
37+
actionItem: Icon {
4438
anchors.centerIn: parent
4539
visible: Theme.dark
46-
icon.source: "image://images/check"
47-
icon.color: Theme.color.neutral9
48-
icon.height: 24
49-
icon.width: 24
50-
background: null
51-
52-
Behavior on icon.color {
53-
ColorAnimation { duration: 150 }
54-
}
40+
source: "image://images/check"
41+
color: Theme.color.neutral9
42+
size: 24
5543
}
5644
onClicked: {
5745
Theme.dark = true;

src/qml/controls/Icon.qml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2023 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
8+
Button {
9+
id: root
10+
required property color color
11+
required property url source
12+
property int size: 32
13+
focusPolicy: Qt.NoFocus
14+
padding: 0
15+
icon.source: root.source
16+
icon.color: root.color
17+
icon.height: root.size
18+
icon.width: root.size
19+
enabled: false
20+
background: null
21+
22+
Behavior on icon.color {
23+
ColorAnimation {
24+
duration: 150
25+
}
26+
}
27+
}

src/qml/controls/OptionButton.qml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,12 @@ Button {
8484
Item {
8585
height: parent.height
8686
width: 40
87-
Button {
87+
Icon {
8888
anchors.centerIn: parent
8989
visible: button.checked
90-
icon.source: "image://images/check"
91-
icon.color: Theme.color.neutral9
92-
icon.height: 24
93-
icon.width: 24
94-
background: null
95-
96-
Behavior on icon.color {
97-
ColorAnimation { duration: 150 }
98-
}
90+
source: "image://images/check"
91+
color: Theme.color.neutral9
92+
size: 24
9993
}
10094
}
10195
}

src/qml/pages/node/Shutdown.qml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ Page {
1414
anchors.centerIn: parent
1515
width: parent.width
1616
spacing: 10
17-
Button {
17+
Icon {
1818
Layout.alignment: Qt.AlignCenter
1919
Layout.bottomMargin: 20
20-
background: null
21-
icon.source: "image://images/shutdown"
22-
icon.color: Theme.color.neutral9
23-
icon.width: 60
24-
icon.height: 60
20+
source: "image://images/shutdown"
21+
color: Theme.color.neutral9
22+
size: 60
2523
}
2624
Header {
2725
Layout.alignment: Qt.AlignCenter

0 commit comments

Comments
 (0)