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

191 lines
5.5 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 ContainerProps 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
2023-06-01 11:25:33 +08:00
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
2024-12-31 04:16:52 +01:00
readonly property int pageSettingsServerProtocols: 0
readonly property int pageSettingsServerServices: 1
readonly property int pageSettingsServerData: 2
property var processedServer
Connections {
target: PageController
function onGoToPageSettingsServerServices() {
2024-12-31 04:16:52 +01:00
tabBar.setCurrentIndex(root.pageSettingsServerServices)
}
}
2026-05-28 10:57:08 +08:00
Connections {
target: ServersUiController
function onProcessedServerIdChanged() {
root.processedServer = proxyServersModel.get(0)
}
}
Connections {
target: ServersModel
2026-05-28 10:57:08 +08:00
function onModelReset() {
root.processedServer = proxyServersModel.get(0)
}
}
2023-06-01 11:25:33 +08:00
SortFilterProxyModel {
id: proxyServersModel
objectName: "proxyServersModel"
2023-06-01 11:25:33 +08:00
sourceModel: ServersModel
filters: [
ValueFilter {
2026-05-28 10:57:08 +08:00
roleName: "serverId"
value: ServersUiController.processedServerId
2023-06-01 11:25:33 +08:00
}
]
Component.onCompleted: {
root.processedServer = proxyServersModel.get(0)
}
2023-06-01 11:25:33 +08:00
}
ColumnLayout {
2024-12-31 04:16:52 +01:00
objectName: "mainLayout"
2023-06-01 11:25:33 +08:00
anchors.fill: parent
anchors.topMargin: 20 + PageController.safeAreaTopMargin
2023-06-01 11:25:33 +08:00
spacing: 4
2024-04-18 17:54:55 +04:00
BackButtonType {
id: backButton
2024-12-31 04:16:52 +01:00
objectName: "backButton"
}
2023-06-05 15:49:10 +08:00
2025-05-02 23:54:36 -07:00
HeaderTypeWithButton {
id: headerContent
2024-12-31 04:16:52 +01:00
objectName: "headerContent"
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-12-31 04:16:52 +01:00
Layout.bottomMargin: 10
2023-06-01 11:25:33 +08:00
actionButtonImage: "qrc:/images/controls/edit-3.svg"
2026-05-28 10:57:08 +08:00
headerText: root.processedServer != null ? root.processedServer.name : ""
descriptionText: {
2026-05-28 10:57:08 +08:00
if (root.processedServer == null) {
return ""
}
if (ServersUiController.isServerFromApi(ServersUiController.processedServerId)) {
return root.processedServer.serverDescription
2026-05-28 10:57:08 +08:00
} else if (ServersUiController.isProcessedServerHasWriteAccess()) {
return root.processedServer.credentialsLogin + " · " + root.processedServer.hostName
} else {
return root.processedServer.hostName
2023-06-05 15:49:10 +08:00
}
}
2023-06-05 15:49:10 +08:00
actionButtonFunction: function() {
serverNameEditDrawer.openTriggered()
}
}
RenameServerDrawer {
id: serverNameEditDrawer
parent: root
anchors.fill: parent
expandedHeight: root.height * 0.35
2026-05-28 10:57:08 +08:00
serverNameText: root.processedServer != null ? root.processedServer.name : ""
2023-06-01 11:25:33 +08:00
}
TabBar {
id: tabBar
Layout.fillWidth: true
2026-05-28 10:57:08 +08:00
currentIndex: (ServersUiController.isServerFromApi(ServersUiController.processedServerId)
&& !ServersUiController.serverHasInstalledContainers(ServersUiController.processedServerId)) ?
root.pageSettingsServerData : root.pageSettingsServerProtocols
2023-06-01 11:25:33 +08:00
background: Rectangle {
2024-07-07 13:42:38 +03:00
color: AmneziaStyle.color.transparent
2023-06-01 11:25:33 +08:00
}
2024-04-18 17:54:55 +04:00
2023-06-01 11:25:33 +08:00
TabButtonType {
2024-04-18 17:54:55 +04:00
id: protocolsTab
visible: protocolsPage.installedProtocolsCount
width: protocolsPage.installedProtocolsCount ? undefined : 0
2024-12-31 04:16:52 +01:00
isSelected: TabBar.tabBar.currentIndex === root.pageSettingsServerProtocols
2023-06-01 11:25:33 +08:00
text: qsTr("Protocols")
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
Keys.onReturnPressed: TabBar.tabBar.setCurrentIndex(root.pageSettingsServerProtocols)
Keys.onEnterPressed: TabBar.tabBar.setCurrentIndex(root.pageSettingsServerProtocols)
2023-06-01 11:25:33 +08:00
}
2023-06-01 11:25:33 +08:00
TabButtonType {
2024-04-18 17:54:55 +04:00
id: servicesTab
visible: servicesPage.installedServicesCount
width: servicesPage.installedServicesCount ? undefined : 0
2024-12-31 04:16:52 +01:00
isSelected: TabBar.tabBar.currentIndex === root.pageSettingsServerServices
2023-06-01 11:25:33 +08:00
text: qsTr("Services")
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
Keys.onReturnPressed: TabBar.tabBar.setCurrentIndex(root.pageSettingsServerServices)
Keys.onEnterPressed: TabBar.tabBar.setCurrentIndex(root.pageSettingsServerServices)
2023-06-01 11:25:33 +08:00
}
2023-06-01 11:25:33 +08:00
TabButtonType {
2024-04-18 17:54:55 +04:00
id: dataTab
isSelected: tabBar.currentIndex === root.pageSettingsServerData
2024-03-26 20:05:04 +02:00
text: qsTr("Management")
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
Keys.onReturnPressed: TabBar.tabBar.setCurrentIndex(root.pageSettingsServerData)
Keys.onEnterPressed: TabBar.tabBar.setCurrentIndex(root.pageSettingsServerData)
2023-06-01 11:25:33 +08:00
}
}
StackLayout {
id: nestedStackView
2024-12-31 04:16:52 +01:00
Layout.fillWidth: true
2023-06-01 11:25:33 +08:00
currentIndex: tabBar.currentIndex
2023-06-01 11:25:33 +08:00
PageSettingsServerProtocols {
id: protocolsPage
2023-06-01 11:25:33 +08:00
stackView: root.stackView
}
2023-06-01 11:25:33 +08:00
PageSettingsServerServices {
id: servicesPage
2023-06-01 11:25:33 +08:00
stackView: root.stackView
}
2023-06-01 11:25:33 +08:00
PageSettingsServerData {
2024-04-18 17:54:55 +04:00
id: dataPage
2023-06-01 11:25:33 +08:00
stackView: root.stackView
}
}
}
}