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

303 lines
12 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ContainerProps 1.0
import ProtocolProps 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
filters: [
ValueFilter {
2023-06-13 20:03:20 +09:00
roleName: "isCurrentlyProcessed"
value: true
}
]
}
FlickableType {
anchors.fill: parent
contentHeight: content.height
Column {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
ListView {
id: processedContainerListView
width: parent.width
height: contentItem.height
currentIndex: -1
clip: true
interactive: false
model: proxyContainersModel
delegate: Item {
implicitWidth: processedContainerListView.width
implicitHeight: (delegateContent.implicitHeight > root.height) ? delegateContent.implicitHeight : root.height
property alias port:port
ColumnLayout {
id: delegateContent
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
2024-04-18 17:54:55 +04:00
Item {
id: focusItem
KeyNavigation.tab: backButton
}
2023-06-05 15:49:10 +08:00
BackButtonType {
2023-06-05 22:40:35 +08:00
id: backButton
2023-06-05 15:49:10 +08:00
Layout.topMargin: 20
Layout.rightMargin: -16
Layout.leftMargin: -16
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: showDetailsButton
2023-06-05 15:49:10 +08:00
}
HeaderType {
id: header
Layout.fillWidth: true
2023-10-06 15:29:15 +08:00
headerText: qsTr("Installing %1").arg(name)
2023-08-20 13:36:54 +05:00
descriptionText: description
}
BasicButtonType {
id: showDetailsButton
Layout.topMargin: 16
Layout.leftMargin: -8
implicitHeight: 32
2024-07-07 13:42:38 +03:00
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.goldenApricot
text: qsTr("More detailed")
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: transportProtoSelector
clickedFunc: function() {
showDetailsDrawer.open()
}
}
2024-02-16 15:24:06 +05:00
DrawerType2 {
id: showDetailsDrawer
2024-02-16 15:24:06 +05:00
parent: root
2024-04-18 17:54:55 +04:00
onClosed: {
if (!GC.isMobile()) {
defaultActiveFocusItem.forceActiveFocus()
}
}
2024-02-16 15:24:06 +05:00
anchors.fill: parent
expandedHeight: parent.height * 0.9
expandedContent: Item {
2024-04-18 17:54:55 +04:00
Connections {
target: showDetailsDrawer
enabled: !GC.isMobile()
function onOpened() {
focusItem2.forceActiveFocus()
}
}
2024-02-16 15:24:06 +05:00
implicitHeight: showDetailsDrawer.expandedHeight
2024-04-18 17:54:55 +04:00
Item {
id: focusItem2
KeyNavigation.tab: showDetailsBackButton
onFocusChanged: {
if (focusItem2.activeFocus) {
fl.contentY = 0
}
}
}
2024-02-16 15:24:06 +05:00
BackButtonType {
id: showDetailsBackButton
2024-02-16 15:24:06 +05:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: showDetailsCloseButton
2024-02-16 15:24:06 +05:00
backButtonFunction: function() {
showDetailsDrawer.close()
}
}
2024-02-16 15:24:06 +05:00
FlickableType {
2024-04-18 17:54:55 +04:00
id: fl
2024-02-16 15:24:06 +05:00
anchors.top: showDetailsBackButton.bottom
anchors.left: parent.left
anchors.right: parent.right
2024-02-16 15:24:06 +05:00
anchors.bottom: parent.bottom
contentHeight: {
var emptySpaceHeight = parent.height - showDetailsBackButton.implicitHeight - showDetailsBackButton.anchors.topMargin
return (showDetailsDrawerContent.height > emptySpaceHeight) ?
showDetailsDrawerContent.height : emptySpaceHeight
}
2024-02-16 15:24:06 +05:00
ColumnLayout {
id: showDetailsDrawerContent
2024-02-16 15:24:06 +05:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
2024-02-16 15:24:06 +05:00
Header2Type {
id: showDetailsDrawerHeader
Layout.fillWidth: true
Layout.topMargin: 16
2024-02-16 15:24:06 +05:00
headerText: name
}
2024-02-16 15:24:06 +05:00
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
2023-10-14 18:21:49 +05:00
2024-02-16 15:24:06 +05:00
text: detailedDescription
textFormat: Text.MarkdownText
}
Rectangle {
Layout.fillHeight: true
2024-07-07 13:42:38 +03:00
color: AmneziaStyle.color.transparent
2024-02-16 15:24:06 +05:00
}
2024-02-16 15:24:06 +05:00
BasicButtonType {
2024-04-18 17:54:55 +04:00
id: showDetailsCloseButton
2024-02-16 15:24:06 +05:00
Layout.fillWidth: true
Layout.bottomMargin: 32
2024-04-18 17:54:55 +04:00
parentFlickable: fl
2024-02-16 15:24:06 +05:00
text: qsTr("Close")
2024-04-18 17:54:55 +04:00
Keys.onTabPressed: lastItemTabClicked(focusItem2)
clickedFunc: function() {
2024-02-16 15:24:06 +05:00
showDetailsDrawer.close()
}
}
}
}
}
}
ParagraphTextType {
id: transportProtoHeader
Layout.topMargin: 16
2023-07-24 16:33:58 +09:00
text: qsTr("Network protocol")
}
TransportProtoSelector {
id: transportProtoSelector
Layout.fillWidth: true
rootWidth: root.width
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: (port.visible && port.enabled) ? port.textField : installButton
}
TextFieldWithHeaderType {
id: port
Layout.fillWidth: true
2023-06-05 22:40:35 +08:00
Layout.topMargin: 16
2023-07-24 16:33:58 +09:00
headerText: qsTr("Port")
textField.maximumLength: 5
textField.validator: IntValidator { bottom: 1; top: 65535 }
KeyNavigation.tab: installButton
}
Rectangle {
Layout.fillHeight: true
2024-07-07 13:42:38 +03:00
color: AmneziaStyle.color.transparent
}
BasicButtonType {
id: installButton
Layout.fillWidth: true
Layout.bottomMargin: 32
2023-07-24 16:33:58 +09:00
text: qsTr("Install")
2024-04-18 17:54:55 +04:00
Keys.onTabPressed: lastItemTabClicked(focusItem)
clickedFunc: function() {
2024-06-28 22:47:22 +03:00
if (!port.textField.acceptableInput &&
2024-08-23 06:23:19 -07:00
ContainerProps.containerTypeToString(dockerContainer) !== "torwebsite" &&
ContainerProps.containerTypeToString(dockerContainer) !== "ikev2") {
2024-06-10 18:35:24 +07:00
port.errorText = qsTr("The port must be in the range of 1 to 65535")
return
}
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.install(dockerContainer, port.textFieldText, transportProtoSelector.currentIndex)
}
}
Component.onCompleted: {
var defaultContainerProto = ContainerProps.defaultProtocol(dockerContainer)
if (ProtocolProps.defaultPort(defaultContainerProto) < 0) {
port.visible = false
} else {
2023-10-20 02:25:40 +01:00
port.textFieldText = ProtocolProps.getPortForInstall(defaultContainerProto)
}
transportProtoSelector.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto)
port.enabled = ProtocolProps.defaultPortChangeable(defaultContainerProto)
var protocolSelectorVisible = ProtocolProps.defaultTransportProtoChangeable(defaultContainerProto)
transportProtoSelector.visible = protocolSelectorVisible
transportProtoHeader.visible = protocolSelectorVisible
2024-04-18 17:54:55 +04:00
if (port.visible && port.enabled)
defaultActiveFocusItem = port.textField
else
defaultActiveFocusItem = focusItem
}
}
}
}
}
}
}