Skip to content

Commit e8a2bbc

Browse files
committed
qml: add interactive color states to peers table
Introduces color states for hover and and pressed to the peers in the peers table.
1 parent 6caffba commit e8a2bbc

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src/qml/pages/node/Peers.qml

+42-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import QtQuick 2.15
66
import QtQuick.Controls 2.15
77
import QtQuick.Layouts 1.15
8+
import org.bitcoincore.qt 1.0
89
import "../../controls"
910
import "../../components"
1011

@@ -122,14 +123,53 @@ Page {
122123
}
123124

124125
delegate: Item {
126+
id: delegate
125127
required property int nodeId;
126128
required property string address;
127129
required property string subversion;
128130
required property string direction;
129131
required property string connectionType;
130132
required property string network;
133+
property color stateColor;
131134
implicitHeight: 60
132135
implicitWidth: listView.width
136+
state: "FILLED"
137+
138+
states: [
139+
State {
140+
name: "FILLED"
141+
PropertyChanges { target: delegate; stateColor: Theme.color.neutral9 }
142+
},
143+
State {
144+
name: "HOVER"
145+
PropertyChanges { target: delegate; stateColor: Theme.color.orangeLight1 }
146+
},
147+
State {
148+
name: "ACTIVE"
149+
PropertyChanges { target: delegate; stateColor: Theme.color.orange }
150+
}
151+
]
152+
153+
MouseArea {
154+
anchors.fill: parent
155+
hoverEnabled: AppMode.isDesktop
156+
onEntered: {
157+
delegate.state = "HOVER"
158+
}
159+
onExited: {
160+
delegate.state = "FILLED"
161+
}
162+
onPressed: {
163+
delegate.state = "ACTIVE"
164+
}
165+
onReleased: {
166+
if (mouseArea.containsMouse) {
167+
delegate.state = "HOVER"
168+
} else {
169+
delegate.state = "FILLED"
170+
}
171+
}
172+
}
133173

134174
Connections {
135175
target: peerListModelProxy
@@ -190,7 +230,7 @@ Page {
190230
Layout.alignment: Qt.AlignLeft
191231
id: primary
192232
font.pixelSize: 18
193-
color: Theme.color.neutral9
233+
color: delegate.stateColor
194234
}
195235
CoreText {
196236
Layout.alignment: Qt.AlignLeft
@@ -205,7 +245,7 @@ Page {
205245
Layout.alignment: Qt.AlignRight
206246
id: secondary
207247
font.pixelSize: 18
208-
color: Theme.color.neutral9
248+
color: delegate.stateColor
209249
}
210250
CoreText {
211251
Layout.alignment: Qt.AlignRight

0 commit comments

Comments
 (0)