Files
amnezia-client/client/ui/qml/Components/SettingsContainersListView.qml
T

133 lines
4.2 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 ContainerEnum 1.0
2023-07-14 13:14:50 +09:00
import ContainerProps 1.0
import "../Controls2"
import "../Controls2/TextTypes"
ListView {
id: root
2023-06-01 11:25:33 +08:00
width: parent.width
height: root.contentItem.height
clip: true
interactive: false
2024-04-18 17:54:55 +04:00
activeFocusOnTab: true
Keys.onTabPressed: {
if (currentIndex < this.count - 1) {
this.incrementCurrentIndex()
} else {
currentIndex = 0
lastItemTabClickedSignal()
}
}
onCurrentIndexChanged: {
if (visible) {
if (fl.contentHeight > fl.height) {
var item = this.currentItem
if (item.y < fl.height) {
fl.contentY = item.y
} else if (item.y + item.height > fl.contentY + fl.height) {
fl.contentY = item.y + item.height - fl.height
}
}
}
}
onVisibleChanged: {
if (visible) {
this.currentIndex = 0
}
}
delegate: Item {
2023-06-01 11:25:33 +08:00
implicitWidth: root.width
2023-08-16 22:45:05 +05:00
implicitHeight: delegateContent.implicitHeight
2024-04-18 17:54:55 +04:00
onActiveFocusChanged: {
if (activeFocus) {
containerRadioButton.rightButton.forceActiveFocus()
}
}
2023-08-16 22:45:05 +05:00
ColumnLayout {
id: delegateContent
2023-08-16 22:45:05 +05:00
anchors.fill: parent
2023-08-16 22:45:05 +05:00
LabelWithButtonType {
2024-04-18 17:54:55 +04:00
id: containerRadioButton
2023-08-16 22:45:05 +05:00
implicitWidth: parent.width
2023-08-16 22:45:05 +05:00
text: name
descriptionText: description
rightImageSource: isInstalled ? "qrc:/images/controls/chevron-right.svg" : "qrc:/images/controls/download.svg"
2023-08-16 22:45:05 +05:00
clickedFunction: function() {
if (isInstalled) {
var containerIndex = root.model.mapToSource(index)
ContainersModel.setProcessedContainerIndex(containerIndex)
2023-09-18 16:39:26 +05:00
if (serviceType !== ProtocolEnum.Other) {
if (config[ContainerProps.containerTypeToString(containerIndex)]["isThirdPartyConfig"]) {
ProtocolsModel.updateModel(config)
PageController.goToPage(PageEnum.PageProtocolRaw)
return
}
2023-08-16 22:45:05 +05:00
}
2023-08-16 22:45:05 +05:00
switch (containerIndex) {
case ContainerEnum.Ipsec: {
ProtocolsModel.updateModel(config)
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageProtocolRaw)
2023-08-16 22:45:05 +05:00
break
}
case ContainerEnum.Sftp: {
SftpConfigModel.updateModel(config)
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageServiceSftpSettings)
2023-08-16 22:45:05 +05:00
break
}
case ContainerEnum.TorWebSite: {
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageServiceTorWebsiteSettings)
2023-08-16 22:45:05 +05:00
break
}
2023-09-18 16:39:26 +05:00
case ContainerEnum.Dns: {
PageController.goToPage(PageEnum.PageServiceDnsSettings)
break
}
default: { // go to the settings page of the container with multiple protocols
ProtocolsModel.updateModel(config)
PageController.goToPage(PageEnum.PageSettingsServerProtocol)
2023-08-16 22:45:05 +05:00
}
}
2023-08-16 22:45:05 +05:00
} else {
ContainersModel.setProcessedContainerIndex(root.model.mapToSource(index))
2023-08-16 22:45:05 +05:00
InstallController.setShouldCreateServer(false)
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
}
}
2023-08-16 22:45:05 +05:00
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
2023-08-16 22:45:05 +05:00
DividerType {}
}
}
}