Skip to content

Commit 3be7fda

Browse files
committed
qml: Introduce TextButton color interaction states
1 parent 8658fe8 commit 3be7fda

File tree

3 files changed

+70
-8
lines changed

3 files changed

+70
-8
lines changed

src/qml/controls/TextButton.qml

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,74 @@ import QtQuick.Controls 2.15
88
Button {
99
id: root
1010
property int textSize: 18
11-
property string textColor: Theme.color.orange
11+
property color textColor
12+
property color bgColor
1213
property bool bold: true
1314
property bool rightalign: false
1415
font.family: "Inter"
1516
font.styleName: bold ? "Semi Bold" : "Regular"
1617
font.pixelSize: root.textSize
18+
padding: 15
19+
state: "DEFAULT"
1720
contentItem: Text {
1821
text: root.text
1922
font: root.font
2023
color: root.textColor
2124
horizontalAlignment: rightalign ? Text.AlignRight : Text.AlignHCenter
2225
verticalAlignment: Text.AlignVCenter
26+
Behavior on color {
27+
ColorAnimation { duration: 150 }
28+
}
29+
}
30+
background: Rectangle {
31+
id: bg
32+
color: root.bgColor
33+
radius: 5
34+
Behavior on color {
35+
ColorAnimation { duration: 150 }
36+
}
37+
}
38+
states: [
39+
State {
40+
name: "DEFAULT"
41+
PropertyChanges {
42+
target: root
43+
textColor: Theme.color.orange
44+
bgColor: Theme.color.background
45+
}
46+
},
47+
State {
48+
name: "HOVER"
49+
PropertyChanges {
50+
target: root
51+
textColor: Theme.color.orangeLight1
52+
bgColor: Theme.color.neutral2
53+
}
54+
},
55+
State {
56+
name: "PRESSED"
57+
PropertyChanges {
58+
target: root
59+
textColor: Theme.color.orangeLight2
60+
bgColor: Theme.color.neutral3
61+
}
62+
}
63+
]
64+
MouseArea {
65+
anchors.fill: parent
66+
hoverEnabled: true
67+
onEntered: {
68+
root.state = "HOVER"
69+
}
70+
onExited: {
71+
root.state = "DEFAULT"
72+
}
73+
onPressed: {
74+
root.state = "PRESSED"
75+
}
76+
onReleased: {
77+
root.state = "DEFAULT"
78+
root.clicked()
79+
}
2380
}
24-
background: null
2581
}

src/qml/pages/onboarding/OnboardingConnection.qml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ Page {
3434
headerText: qsTr("Starting initial download")
3535
headerMargin: 30
3636
description: qsTr("The application will connect to the Bitcoin network and start downloading and verifying transactions.\n\nThis may take several hours, or even days, based on your connection.")
37-
descriptionMargin: 20
37+
descriptionMargin: 10
3838
detailActive: true
39-
detailItem: TextButton {
40-
text: qsTr("Connection settings")
41-
onClicked: connections.incrementCurrentIndex()
39+
detailTopMargin: 10
40+
detailItem: RowLayout {
41+
TextButton {
42+
Layout.alignment: Qt.AlignCenter
43+
text: qsTr("Connection settings")
44+
onClicked: connections.incrementCurrentIndex()
45+
}
4246
}
4347
lastPage: true
4448
buttonText: qsTr("Next")
49+
buttonMargin: 20
4550
}
4651
SettingsConnection {
4752
navRightDetail: NavButton {

src/qml/pages/onboarding/OnboardingStorageAmount.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ Page {
3737
Layout.alignment: Qt.AlignCenter
3838
}
3939
TextButton {
40-
Layout.topMargin: 30
41-
Layout.fillWidth: true
40+
Layout.topMargin: 10
41+
Layout.alignment: Qt.AlignCenter
4242
text: qsTr("Detailed settings")
4343
onClicked: storages.incrementCurrentIndex()
4444
}
4545
}
4646
buttonText: qsTr("Next")
47+
buttonMargin: 20
4748
}
4849
SettingsStorage {
4950
navRightDetail: NavButton {

0 commit comments

Comments
 (0)