Compare commits

...

2 Commits

Author SHA1 Message Date
pokamest d8ee32d4b1 Merge branch 'dev' into feature/auto-scroll-for-server-selection-list 2024-02-26 22:18:15 +00:00
Shehab Ahmed f646b38ec9 added auto-scroll for server selection list 2024-02-21 03:44:37 +02:00
+91 -93
View File
@@ -18,6 +18,7 @@ import "../Components"
PageType { PageType {
id: root id: root
property var selectedServerIndex: ServersModel.getDefaultServerIndex()
Connections { Connections {
target: PageController target: PageController
@@ -75,7 +76,6 @@ PageType {
} }
} }
DrawerType2 { DrawerType2 {
id: drawer id: drawer
anchors.fill: parent anchors.fill: parent
@@ -162,7 +162,7 @@ PageType {
} }
} }
expandedContent: Item { expandedContent: Item {
id: serverMenuContainer id: serverMenuContainer
implicitHeight: root.height * 0.9 implicitHeight: root.height * 0.9
@@ -178,7 +178,6 @@ PageType {
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
Header1TextType { Header1TextType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 14 Layout.topMargin: 14
@@ -281,125 +280,124 @@ PageType {
anchors.left: parent.left anchors.left: parent.left
anchors.topMargin: 16 anchors.topMargin: 16
contentHeight: col.height + col.anchors.bottomMargin
implicitHeight: parent.height - serversMenuHeader.implicitHeight implicitHeight: parent.height - serversMenuHeader.implicitHeight
clip: true clip: true
interactive: true
ScrollBar.vertical: ScrollBar {
id: scrollBar
policy: serversContainer.height >= serversContainer.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn
}
Keys.onUpPressed: scrollBar.decrease() Keys.onUpPressed: scrollBar.decrease()
Keys.onDownPressed: scrollBar.increase() Keys.onDownPressed: scrollBar.increase()
Column { ButtonGroup {
id: col
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottomMargin: 32
spacing: 16
ButtonGroup {
id: serversRadioButtonGroup id: serversRadioButtonGroup
} }
ListView { ListView {
id: serversMenuContent id: serversMenuContent
width: parent.width width: parent.width
height: serversMenuContent.contentItem.height spacing: 16
model: ServersModel anchors.fill: parent
currentIndex: ServersModel.defaultIndex anchors.bottomMargin: 32
Connections { highlightFollowsCurrentItem: true
target: ServersModel highlightMoveDuration: 100
function onDefaultServerIndexChanged(serverIndex) {
serversMenuContent.currentIndex = serverIndex
}
}
clip: true model: ServersModel
interactive: false
delegate: Item { Component.onCompleted: currentIndex = selectedServerIndex //auto-scroll to the selected server
id: menuContentDelegate
property variant delegateData: model ScrollBar.vertical: ScrollBar {
id: scrollBar
active: true
policy: serversContainer.height >= serversMenuContent.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn
width: 12
}
implicitWidth: serversMenuContent.width Connections {
implicitHeight: serverRadioButtonContent.implicitHeight target: ServersModel
function onDefaultServerIndexChanged(serverIndex) {
serversMenuContent.currentIndex = serverIndex
}
}
ColumnLayout { clip: true
id: serverRadioButtonContent interactive: true
anchors.fill: parent delegate: Item {
anchors.rightMargin: 16 id: menuContentDelegate
anchors.leftMargin: 16
spacing: 0 property variant delegateData: model
RowLayout { implicitWidth: serversMenuContent.width
VerticalRadioButton { implicitHeight: serverRadioButtonContent.implicitHeight
id: serverRadioButton
Layout.fillWidth: true ColumnLayout {
id: serverRadioButtonContent
text: name anchors.fill: parent
descriptionText: serverDescription anchors.rightMargin: 16
anchors.leftMargin: 16
checked: index === serversMenuContent.currentIndex spacing: 0
checkable: !ConnectionController.isConnected
ButtonGroup.group: serversRadioButtonGroup RowLayout {
VerticalRadioButton {
id: serverRadioButton
onClicked: { Layout.fillWidth: true
if (ConnectionController.isConnected) {
PageController.showNotificationMessage(qsTr("Unable change server while there is an active connection"))
return
}
serversMenuContent.currentIndex = index text: name
descriptionText: serverDescription
ServersModel.defaultIndex = index checked: index === serversMenuContent.currentIndex
} checkable: !ConnectionController.isConnected
MouseArea { ButtonGroup.group: serversRadioButtonGroup
anchors.fill: serverRadioButton
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
ImageButtonType { onClicked: {
image: "qrc:/images/controls/settings.svg" if (ConnectionController.isConnected) {
imageColor: "#D7D8DB" PageController.showNotificationMessage(qsTr("Unable change server while there is an active connection"))
return
}
implicitWidth: 56 serversMenuContent.currentIndex = index
implicitHeight: 56
z: 1 ServersModel.defaultIndex = index
}
onClicked: function() { MouseArea {
ServersModel.processedIndex = index anchors.fill: serverRadioButton
PageController.goToPage(PageEnum.PageSettingsServerInfo) cursorShape: Qt.PointingHandCursor
drawer.close() enabled: false
} }
} }
}
DividerType { ImageButtonType {
Layout.fillWidth: true image: "qrc:/images/controls/settings.svg"
Layout.leftMargin: 0 imageColor: "#D7D8DB"
Layout.rightMargin: 0
} 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
}
}
}
}
}
}
}
}