Files
amnezia-client/client/ui/qml/Pages2/PageSettingsServersList.qml
T

144 lines
4.0 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
import ContainerProps 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
2024-04-18 17:54:55 +04:00
defaultActiveFocusItem: focusItem
Item {
id: focusItem
KeyNavigation.tab: backButton
}
2023-06-05 15:49:10 +08:00
ColumnLayout {
id: header
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
2023-06-05 15:49:10 +08:00
BackButtonType {
2024-04-18 17:54:55 +04:00
id: backButton
KeyNavigation.tab: servers
2023-06-05 15:49:10 +08:00
}
HeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2023-06-05 15:49:10 +08:00
2023-07-24 16:33:58 +09:00
headerText: qsTr("Servers")
}
}
FlickableType {
2024-04-18 17:54:55 +04:00
id: fl
anchors.top: header.bottom
anchors.topMargin: 16
contentHeight: col.implicitHeight
Column {
id: col
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
ListView {
id: servers
width: parent.width
height: servers.contentItem.height
model: ServersModel
clip: true
interactive: false
2024-04-18 17:54:55 +04:00
activeFocusOnTab: true
focus: true
Keys.onTabPressed: {
if (currentIndex < servers.count - 1) {
servers.incrementCurrentIndex()
} else {
servers.currentIndex = 0
focusItem.forceActiveFocus()
root.lastItemTabClicked()
}
fl.ensureVisible(this.currentItem)
}
onVisibleChanged: {
if (visible) {
currentIndex = 0
}
}
delegate: Item {
implicitWidth: servers.width
implicitHeight: delegateContent.implicitHeight
2024-04-18 17:54:55 +04:00
onFocusChanged: {
if (focus) {
server.rightButton.forceActiveFocus()
}
}
ColumnLayout {
id: delegateContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
LabelWithButtonType {
id: server
Layout.fillWidth: true
text: name
2024-04-18 17:54:55 +04:00
parentFlickable: fl
descriptionText: {
var servicesNameString = ""
var servicesName = ServersModel.getAllInstalledServicesName(index)
for (var i = 0; i < servicesName.length; i++) {
servicesNameString += servicesName[i] + " · "
}
if (ServersModel.isServerFromApi(index)) {
return servicesNameString + serverDescription
} else {
return servicesNameString + hostName
}
}
rightImageSource: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
2024-02-19 19:54:15 +05:00
ServersModel.processedIndex = index
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSettingsServerInfo)
}
}
DividerType {}
}
}
}
}
}
}