Skip to content

Commit

Permalink
qml: remember user's peer sort preference
Browse files Browse the repository at this point in the history
This sets the sort preference for the peers table in qsettings so that
it can be remembered. Also addresses an issue where the `id`
toggle button is always checked when you go back to the table even
though the table is not sorted by `id`.
  • Loading branch information
jarolrod committed Nov 14, 2023
1 parent 46e93de commit afcb1f7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/qml/pages/node/Peers.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import Qt.labs.settings 1.0
import "../../controls"
import "../../components"

Expand All @@ -27,6 +28,15 @@ Page {
}
}

Settings {
id: settings
property string peerListSortBy: "nodeId"
}

Component.onCompleted: {
peerListModelProxy.sortBy = settings.peerListSortBy
}

ListView {
id: listView
clip: true
Expand Down Expand Up @@ -63,44 +73,55 @@ Page {
ToggleButton {
text: qsTr("ID")
autoExclusive: true
checked: true
checked: settings.peerListSortBy === "nodeId"
onClicked: {
peerListModelProxy.sortBy = "nodeId"
settings.peerListSortBy = "nodeId"
}
}
ToggleButton {
text: qsTr("Direction")
autoExclusive: true
checked: settings.peerListSortBy === "direction"
onClicked: {
peerListModelProxy.sortBy = "direction"
settings.peerListSortBy = "direction"
}
}
ToggleButton {
text: qsTr("User Agent")
autoExclusive: true
checked: settings.peerListSortBy === "subversion"
onClicked: {
peerListModelProxy.sortBy = "subversion"
settings.peerListSortBy = "subversion"
}
}
ToggleButton {
text: qsTr("Type")
autoExclusive: true
checked: settings.peerListSortBy === "connectionType"
onClicked: {
peerListModelProxy.sortBy = "connectionType"
settings.peerListSortBy = "connectionType"
}
}
ToggleButton {
text: qsTr("Ip")
autoExclusive: true
checked: settings.peerListSortBy === "address"
onClicked: {
peerListModelProxy.sortBy = "address"
settings.peerListSortBy = "address"
}
}
ToggleButton {
text: qsTr("Network")
autoExclusive: true
checked: settings.peerListSortBy === "network"
onClicked: {
peerListModelProxy.sortBy = "network"
settings.peerListSortBy = "network"
}
}
}
Expand Down

0 comments on commit afcb1f7

Please sign in to comment.