From 5206665fa09656ce98f2cdbba7306f60996a03f8 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Mon, 25 Mar 2024 22:30:44 +0500 Subject: [PATCH] fixed recursive rearrange on PageHome --- .../ui/qml/Controls2/VerticalRadioButton.qml | 8 +- client/ui/qml/Pages2/PageHome.qml | 186 ++++++++---------- 2 files changed, 88 insertions(+), 106 deletions(-) diff --git a/client/ui/qml/Controls2/VerticalRadioButton.qml b/client/ui/qml/Controls2/VerticalRadioButton.qml index dd9a5590..ed7ed143 100644 --- a/client/ui/qml/Controls2/VerticalRadioButton.qml +++ b/client/ui/qml/Controls2/VerticalRadioButton.qml @@ -89,12 +89,12 @@ RadioButton { } contentItem: Item { - implicitWidth: content.implicitWidth - implicitHeight: content.implicitHeight - - anchors.fill: parent + anchors.left: parent.left + anchors.right: parent.right anchors.leftMargin: 8 + background.width + implicitHeight: content.implicitHeight + ColumnLayout { id: content diff --git a/client/ui/qml/Pages2/PageHome.qml b/client/ui/qml/Pages2/PageHome.qml index 17132fa2..2aab0fe0 100644 --- a/client/ui/qml/Pages2/PageHome.qml +++ b/client/ui/qml/Pages2/PageHome.qml @@ -299,129 +299,111 @@ PageType { } } - Flickable { - id: serversContainer + + ButtonGroup { + id: serversRadioButtonGroup + } + + ListView { + id: serversMenuContent anchors.top: serversMenuHeader.bottom anchors.right: parent.right anchors.left: parent.left + anchors.bottom: parent.bottom anchors.topMargin: 16 - contentHeight: col.height + col.anchors.bottomMargin - implicitHeight: parent.height - serversMenuHeader.implicitHeight - clip: true + model: ServersModel + currentIndex: ServersModel.defaultIndex ScrollBar.vertical: ScrollBar { id: scrollBar - policy: serversContainer.height >= serversContainer.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn + policy: serversMenuContent.height >= serversMenuContent.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn } Keys.onUpPressed: scrollBar.decrease() Keys.onDownPressed: scrollBar.increase() - Column { - id: col - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.bottomMargin: 32 - - spacing: 16 - - ButtonGroup { - id: serversRadioButtonGroup + Connections { + target: ServersModel + function onDefaultServerIndexChanged(serverIndex) { + serversMenuContent.currentIndex = serverIndex } + } - ListView { - id: serversMenuContent - width: parent.width - height: serversMenuContent.contentItem.height + clip: true - model: ServersModel - currentIndex: ServersModel.defaultIndex + delegate: Item { + id: menuContentDelegate - Connections { - target: ServersModel - function onDefaultServerIndexChanged(serverIndex) { - serversMenuContent.currentIndex = serverIndex + property variant delegateData: model + + implicitWidth: serversMenuContent.width + implicitHeight: serverRadioButtonContent.implicitHeight + + ColumnLayout { + id: serverRadioButtonContent + + anchors.fill: parent + anchors.rightMargin: 16 + anchors.leftMargin: 16 + + spacing: 0 + + RowLayout { + Layout.fillWidth: true + VerticalRadioButton { + id: serverRadioButton + + Layout.fillWidth: true + + text: name + descriptionText: serverDescription + + checked: index === serversMenuContent.currentIndex + checkable: !ConnectionController.isConnected + + ButtonGroup.group: serversRadioButtonGroup + + onClicked: { + if (ConnectionController.isConnected) { + PageController.showNotificationMessage(qsTr("Unable change server while there is an active connection")) + return + } + + serversMenuContent.currentIndex = index + + ServersModel.defaultIndex = index + } + + MouseArea { + anchors.fill: serverRadioButton + cursorShape: Qt.PointingHandCursor + enabled: false + } + } + + ImageButtonType { + image: "qrc:/images/controls/settings.svg" + imageColor: "#D7D8DB" + + implicitWidth: 56 + implicitHeight: 56 + + z: 1 + + onClicked: function() { + ServersModel.processedIndex = index + PageController.goToPage(PageEnum.PageSettingsServerInfo) + drawer.close() + } } } - clip: true - interactive: false - - delegate: Item { - id: menuContentDelegate - - property variant delegateData: model - - implicitWidth: serversMenuContent.width - implicitHeight: serverRadioButtonContent.implicitHeight - - ColumnLayout { - id: serverRadioButtonContent - - anchors.fill: parent - anchors.rightMargin: 16 - anchors.leftMargin: 16 - - spacing: 0 - - RowLayout { - VerticalRadioButton { - id: serverRadioButton - - Layout.fillWidth: true - - text: name - descriptionText: serverDescription - - checked: index === serversMenuContent.currentIndex - checkable: !ConnectionController.isConnected - - ButtonGroup.group: serversRadioButtonGroup - - onClicked: { - if (ConnectionController.isConnected) { - PageController.showNotificationMessage(qsTr("Unable change server while there is an active connection")) - return - } - - serversMenuContent.currentIndex = index - - ServersModel.defaultIndex = index - } - - MouseArea { - anchors.fill: serverRadioButton - cursorShape: Qt.PointingHandCursor - enabled: false - } - } - - ImageButtonType { - image: "qrc:/images/controls/settings.svg" - imageColor: "#D7D8DB" - - implicitWidth: 56 - implicitHeight: 56 - - z: 1 - - onClicked: function() { - ServersModel.processedIndex = index - PageController.goToPage(PageEnum.PageSettingsServerInfo) - drawer.close() - } - } - } - - DividerType { - Layout.fillWidth: true - Layout.leftMargin: 0 - Layout.rightMargin: 0 - } - } + DividerType { + Layout.fillWidth: true + Layout.leftMargin: 0 + Layout.rightMargin: 0 } } }