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 10, 2023
1 parent 6caffba commit 979a984
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 @@ -17,6 +18,15 @@ Page {
id: navbar
}

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

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

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

0 comments on commit 979a984

Please sign in to comment.