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

254 lines
7.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 ProtocolEnum 1.0
import ContainerProps 1.0
import ProtocolProps 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
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
}
]
}
2024-04-18 17:54:55 +04:00
Item {
id: focusItem
KeyNavigation.tab: header
}
2023-06-01 11:25:33 +08:00
ColumnLayout {
anchors.fill: parent
spacing: 16
Repeater {
id: header
model: proxyServersModel
2024-04-18 17:54:55 +04:00
activeFocusOnTab: true
onFocusChanged: {
header.itemAt(0).focusItem.forceActiveFocus()
}
2023-06-05 15:49:10 +08:00
delegate: ColumnLayout {
2024-04-18 17:54:55 +04:00
property alias focusItem: backButton
2023-06-05 15:49:10 +08:00
id: content
2023-06-01 11:25:33 +08:00
Layout.topMargin: 20
2023-06-05 15:49:10 +08:00
BackButtonType {
2024-04-18 17:54:55 +04:00
id: backButton
KeyNavigation.tab: headerContent.actionButton
2023-06-05 15:49:10 +08:00
}
HeaderType {
2024-04-18 17:54:55 +04:00
id: headerContent
2023-06-05 15:49:10 +08:00
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
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: tabBar
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-04-18 17:54:55 +04:00
onClosed: {
if (!GC.isMobile()) {
headerContent.actionButton.forceActiveFocus()
}
}
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()
}
}
2024-04-18 17:54:55 +04:00
Item {
id: focusItem1
KeyNavigation.tab: serverName.textField
}
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")
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: focusItem1
clickedFunc: function() {
if (serverName.textFieldText === "") {
return
}
if (serverName.textFieldText !== name) {
name = serverName.textFieldText
}
2024-02-16 15:24:06 +05:00
serverNameEditDrawer.close()
}
}
2023-06-05 15:49:10 +08:00
}
2023-06-01 11:25:33 +08:00
}
}
}
TabBar {
id: tabBar
Layout.fillWidth: true
currentIndex: (ServersModel.getProcessedServerData("isServerFromApi")
&& !ServersModel.getProcessedServerData("hasInstalledContainers")) ? 2 : 0
2023-06-01 11:25:33 +08:00
background: Rectangle {
color: "transparent"
}
2024-04-18 17:54:55 +04:00
activeFocusOnTab: true
onFocusChanged: {
if (activeFocus) {
protocolsTab.forceActiveFocus()
}
}
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
2023-06-01 11:25:33 +08:00
isSelected: tabBar.currentIndex === 0
text: qsTr("Protocols")
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: servicesTab
Keys.onReturnPressed: tabBar.currentIndex = 0
Keys.onEnterPressed: tabBar.currentIndex = 0
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
2023-06-01 11:25:33 +08:00
isSelected: tabBar.currentIndex === 1
text: qsTr("Services")
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: dataTab
Keys.onReturnPressed: tabBar.currentIndex = 1
Keys.onEnterPressed: tabBar.currentIndex = 1
2023-06-01 11:25:33 +08:00
}
TabButtonType {
2024-04-18 17:54:55 +04:00
id: dataTab
2023-06-01 11:25:33 +08:00
isSelected: tabBar.currentIndex === 2
2024-03-26 20:05:04 +02:00
text: qsTr("Management")
2024-04-18 17:54:55 +04:00
Keys.onReturnPressed: tabBar.currentIndex = 2
Keys.onEnterPressed: tabBar.currentIndex = 2
KeyNavigation.tab: stackView.currentIndex === 0 ?
protocolsPage :
stackView.currentIndex === 1 ?
servicesPage :
dataPage
2023-06-01 11:25:33 +08:00
}
}
StackLayout {
2024-04-18 17:54:55 +04:00
id: stackView
2023-06-01 11:25:33 +08:00
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
2024-04-18 17:54:55 +04:00
onLastItemTabClickedSignal: lastItemTabClicked(focusItem)
2023-06-01 11:25:33 +08:00
}
PageSettingsServerServices {
id: servicesPage
2023-06-01 11:25:33 +08:00
stackView: root.stackView
2024-04-18 17:54:55 +04:00
onLastItemTabClickedSignal: lastItemTabClicked(focusItem)
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
2024-04-18 17:54:55 +04:00
onLastItemTabClickedSignal: lastItemTabClicked(focusItem)
2023-06-01 11:25:33 +08:00
}
}
2024-04-18 17:54:55 +04:00
2023-06-01 11:25:33 +08:00
}
}