Skip to content

Commit 3c2d951

Browse files
committed
qml: improve peer delegate
1 parent bc6f872 commit 3c2d951

File tree

1 file changed

+56
-70
lines changed

1 file changed

+56
-70
lines changed

src/qml/pages/node/Peers.qml

Lines changed: 56 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -153,55 +153,22 @@ Page {
153153
}
154154
}
155155

156-
delegate: Item {
156+
delegate: ItemDelegate {
157157
id: delegate
158158
required property int nodeId;
159159
required property string address;
160160
required property string subversion;
161161
required property string direction;
162162
required property string connectionType;
163163
required property string network;
164-
property color stateColor;
165-
implicitHeight: 60
166-
implicitWidth: listView.width
167-
state: "FILLED"
168-
169-
states: [
170-
State {
171-
name: "FILLED"
172-
PropertyChanges { target: delegate; stateColor: Theme.color.neutral9 }
173-
},
174-
State {
175-
name: "HOVER"
176-
PropertyChanges { target: delegate; stateColor: Theme.color.orangeLight1 }
177-
},
178-
State {
179-
name: "ACTIVE"
180-
PropertyChanges { target: delegate; stateColor: Theme.color.orange }
181-
}
182-
]
183-
184-
MouseArea {
185-
anchors.fill: parent
186-
hoverEnabled: AppMode.isDesktop
187-
onEntered: {
188-
delegate.state = "HOVER"
189-
}
190-
onExited: {
191-
delegate.state = "FILLED"
192-
}
193-
onPressed: {
194-
delegate.state = "ACTIVE"
195-
}
196-
onReleased: {
197-
if (mouseArea.containsMouse) {
198-
delegate.state = "HOVER"
199-
} else {
200-
delegate.state = "FILLED"
201-
}
164+
readonly property color stateColor: {
165+
if (delegate.down) {
166+
return Theme.color.orange
167+
} else if (delegate.hovered) {
168+
return Theme.color.orangeLight1
202169
}
170+
return Theme.color.neutral9
203171
}
204-
205172
Connections {
206173
target: peerListModelProxy
207174
function onSortByChanged(roleName) {
@@ -254,41 +221,60 @@ Page {
254221
quaternary.text = subversion
255222
}
256223
}
257-
258-
ColumnLayout {
259-
anchors.left: parent.left
260-
CoreText {
261-
Layout.alignment: Qt.AlignLeft
262-
id: primary
263-
font.pixelSize: 18
264-
color: delegate.stateColor
265-
}
266-
CoreText {
267-
Layout.alignment: Qt.AlignLeft
268-
id: tertiary
269-
font.pixelSize: 15
270-
color: Theme.color.neutral7
224+
leftPadding: 0
225+
rightPadding: 0
226+
topPadding: 0
227+
bottomPadding: 14
228+
width: listView.width
229+
background: Item {
230+
Separator {
231+
anchors.bottom: parent.bottom
232+
width: parent.width
271233
}
272234
}
273-
ColumnLayout {
274-
anchors.right: parent.right
275-
CoreText {
276-
Layout.alignment: Qt.AlignRight
277-
id: secondary
278-
font.pixelSize: 18
279-
color: delegate.stateColor
235+
contentItem: RowLayout {
236+
spacing: 15
237+
ColumnLayout {
238+
Layout.fillWidth: true
239+
CoreText {
240+
Layout.alignment: Qt.AlignLeft
241+
Layout.fillWidth: true
242+
Layout.preferredWidth: 0
243+
id: primary
244+
font.pixelSize: 18
245+
color: delegate.stateColor
246+
elide: Text.ElideMiddle
247+
wrapMode: Text.NoWrap
248+
horizontalAlignment: Text.AlignLeft
249+
}
250+
CoreText {
251+
Layout.alignment: Qt.AlignLeft
252+
Layout.fillWidth: true
253+
Layout.preferredWidth: 0
254+
id: tertiary
255+
font.pixelSize: 15
256+
color: Theme.color.neutral7
257+
elide: Text.ElideMiddle
258+
wrapMode: Text.NoWrap
259+
horizontalAlignment: Text.AlignLeft
260+
}
280261
}
281-
CoreText {
282-
Layout.alignment: Qt.AlignRight
283-
id: quaternary
284-
font.pixelSize: 15
285-
color: Theme.color.neutral7
262+
ColumnLayout {
263+
Layout.fillWidth: false
264+
CoreText {
265+
Layout.alignment: Qt.AlignRight
266+
id: secondary
267+
font.pixelSize: 18
268+
color: delegate.stateColor
269+
}
270+
CoreText {
271+
Layout.alignment: Qt.AlignRight
272+
id: quaternary
273+
font.pixelSize: 15
274+
color: Theme.color.neutral7
275+
}
286276
}
287277
}
288-
Separator {
289-
anchors.bottom: parent.bottom
290-
width: parent.width
291-
}
292278
}
293279
}
294280
}

0 commit comments

Comments
 (0)