From afcb1f7b9289b9b1f23491073ef84d0f7f353abc Mon Sep 17 00:00:00 2001 From: jarolrod Date: Thu, 9 Nov 2023 19:38:06 -0600 Subject: [PATCH] qml: remember user's peer sort preference 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`. --- src/qml/pages/node/Peers.qml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qml/pages/node/Peers.qml b/src/qml/pages/node/Peers.qml index bd666f0d5f..bc77d871e7 100644 --- a/src/qml/pages/node/Peers.qml +++ b/src/qml/pages/node/Peers.qml @@ -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" @@ -27,6 +28,15 @@ Page { } } + Settings { + id: settings + property string peerListSortBy: "nodeId" + } + + Component.onCompleted: { + peerListModelProxy.sortBy = settings.peerListSortBy + } + ListView { id: listView clip: true @@ -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" } } }