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

190 lines
5.4 KiB
QML
Raw Normal View History

2023-06-01 11:25:33 +08:00
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 ProtocolProps 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
Connections {
target: PageController
function onGoToPageSettingsServerServices() {
tabBar.currentIndex = 1
}
}
2023-06-01 11:25:33 +08:00
SortFilterProxyModel {
id: proxyServersModel
sourceModel: ServersModel
filters: [
ValueFilter {
roleName: "isCurrentlyProcessed"
value: true
}
]
}
ColumnLayout {
anchors.fill: parent
spacing: 16
Repeater {
id: header
model: proxyServersModel
2023-06-05 15:49:10 +08:00
delegate: ColumnLayout {
id: content
2023-06-01 11:25:33 +08:00
Layout.topMargin: 20
2023-06-05 15:49:10 +08:00
BackButtonType {
}
HeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2023-06-01 11:25:33 +08:00
2023-06-05 15:49:10 +08:00
actionButtonImage: "qrc:/images/controls/edit-3.svg"
2023-06-01 11:25:33 +08:00
2023-06-05 15:49:10 +08:00
headerText: name
descriptionText: {
2024-02-19 19:54:15 +05:00
if (ServersModel.isProcessedServerHasWriteAccess()) {
return credentialsLogin + " · " + hostName
} else {
return hostName
}
}
2023-06-01 11:25:33 +08:00
2023-06-05 15:49:10 +08:00
actionButtonFunction: function() {
2024-02-16 15:24:06 +05:00
serverNameEditDrawer.open()
}
}
2024-02-16 15:24:06 +05:00
DrawerType2 {
id: serverNameEditDrawer
2024-02-16 15:24:06 +05:00
parent: root
2024-02-16 15:24:06 +05:00
anchors.fill: parent
expandedHeight: root.height * 0.35
2024-02-16 15:24:06 +05:00
expandedContent: ColumnLayout {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2024-02-16 15:24:06 +05:00
anchors.topMargin: 32
anchors.leftMargin: 16
anchors.rightMargin: 16
2024-02-16 15:24:06 +05:00
Connections {
target: serverNameEditDrawer
enabled: !GC.isMobile()
2024-02-16 15:24:06 +05:00
function onOpened() {
serverName.textField.forceActiveFocus()
}
}
TextFieldWithHeaderType {
id: serverName
Layout.fillWidth: true
headerText: qsTr("Server name")
textFieldText: name
textField.maximumLength: 30
checkEmptyText: true
KeyNavigation.tab: saveButton
}
BasicButtonType {
id: saveButton
Layout.fillWidth: true
text: qsTr("Save")
clickedFunc: function() {
if (serverName.textFieldText === "") {
return
}
if (serverName.textFieldText !== name) {
name = serverName.textFieldText
}
2024-02-16 15:24:06 +05:00
serverNameEditDrawer.close()
}
}
Component.onCompleted: {
2024-03-04 02:28:10 +03:00
if (header.itemAt(0) && !GC.isMobile()) {
defaultActiveFocusItem = serverName.textField
}
}
2023-06-05 15:49:10 +08:00
}
2023-06-01 11:25:33 +08:00
}
}
}
TabBar {
id: tabBar
Layout.fillWidth: true
background: Rectangle {
color: "transparent"
}
TabButtonType {
visible: protocolsPage.installedProtocolsCount
width: protocolsPage.installedProtocolsCount ? undefined : 0
2023-06-01 11:25:33 +08:00
isSelected: tabBar.currentIndex === 0
text: qsTr("Protocols")
}
TabButtonType {
visible: servicesPage.installedServicesCount
width: servicesPage.installedServicesCount ? undefined : 0
2023-06-01 11:25:33 +08:00
isSelected: tabBar.currentIndex === 1
text: qsTr("Services")
}
TabButtonType {
isSelected: tabBar.currentIndex === 2
2024-03-26 20:05:04 +02:00
text: qsTr("Management")
2023-06-01 11:25:33 +08:00
}
}
StackLayout {
Layout.preferredWidth: root.width
Layout.preferredHeight: root.height - tabBar.implicitHeight - header.implicitHeight
currentIndex: tabBar.currentIndex
PageSettingsServerProtocols {
id: protocolsPage
2023-06-01 11:25:33 +08:00
stackView: root.stackView
}
PageSettingsServerServices {
id: servicesPage
2023-06-01 11:25:33 +08:00
stackView: root.stackView
}
PageSettingsServerData {
stackView: root.stackView
}
}
}
}