From fa64c8d68d32c57e23f1d4fdf7724fd9c0333c31 Mon Sep 17 00:00:00 2001 From: Cyril Anisimov Date: Fri, 20 Dec 2024 02:05:28 +0100 Subject: [PATCH] fix focus movement in `ServersListView` --- client/ui/qml/Components/ServersListView.qml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/client/ui/qml/Components/ServersListView.qml b/client/ui/qml/Components/ServersListView.qml index 1711a458..8eccb324 100644 --- a/client/ui/qml/Components/ServersListView.qml +++ b/client/ui/qml/Components/ServersListView.qml @@ -18,6 +18,8 @@ import "../Config" ListView { id: root + property int selectedIndex: ServersModel.defaultIndex + anchors.top: serversMenuHeader.bottom anchors.right: parent.right anchors.left: parent.left @@ -25,7 +27,6 @@ ListView { anchors.topMargin: 16 model: ServersModel - currentIndex: ServersModel.defaultIndex ScrollBar.vertical: ScrollBarType { id: scrollBar @@ -38,11 +39,12 @@ ListView { Connections { target: ServersModel function onDefaultServerIndexChanged(serverIndex) { - root.currentIndex = serverIndex + root.selectedIndex = serverIndex } } clip: true + reuseItems: true delegate: Item { id: menuContentDelegate @@ -68,16 +70,17 @@ ListView { objectName: "serverRadioButtonRowLayout" Layout.fillWidth: true + VerticalRadioButton { id: serverRadioButton objectName: "serverRadioButton" Layout.fillWidth: true - focus: true + text: name descriptionText: serverDescription - checked: index === root.currentIndex + checked: index === root.selectedIndex checkable: !ConnectionController.isConnected ButtonGroup.group: serversRadioButtonGroup @@ -88,17 +91,11 @@ ListView { return } - root.currentIndex = index + root.selectedIndex = index ServersModel.defaultIndex = index } - MouseArea { - anchors.fill: serverRadioButton - cursorShape: Qt.PointingHandCursor - enabled: false - } - Keys.onEnterPressed: serverRadioButton.clicked() Keys.onReturnPressed: serverRadioButton.clicked() }