Files
amnezia-client/client/ui/qml/Pages/PageNewServerProtocols.qml
T

155 lines
4.2 KiB
QML
Raw Normal View History

2021-07-28 16:13:29 +07:00
import QtQuick 2.12
import QtQuick.Controls 2.12
2021-09-10 22:19:00 +03:00
import QtQuick.Layouts 1.3
2021-09-20 21:51:28 +03:00
import ContainerProps 1.0
import ProtocolProps 1.0
2021-09-14 00:39:07 +03:00
import PageEnum 1.0
2021-07-28 16:13:29 +07:00
import "./"
2021-08-19 01:27:22 +03:00
import "../Controls"
import "../Config"
2021-09-08 21:24:09 +03:00
import "InstallSettings"
2021-07-28 16:13:29 +07:00
2021-09-14 00:39:07 +03:00
PageBase {
2021-07-28 16:13:29 +07:00
id: root
2021-09-14 00:39:07 +03:00
page: PageEnum.NewServerProtocols
logic: NewServerProtocolsLogic
2021-09-20 21:51:28 +03:00
onActivated: {
container_selector.selectedIndex = -1
UiLogic.containersModel.setSelectedServerIndex(-1)
}
2021-09-08 15:09:16 +03:00
BackButton {
2021-07-28 16:13:29 +07:00
id: back
}
2021-09-08 21:24:09 +03:00
Caption {
id: caption
2021-07-28 16:13:29 +07:00
text: qsTr("Select VPN protocols")
}
BlueButtonType {
2021-09-08 21:24:09 +03:00
id: pushButtonConfigure
2021-09-10 22:19:00 +03:00
enabled: container_selector.selectedIndex > 0
2021-07-28 16:13:29 +07:00
anchors.horizontalCenter: parent.horizontalCenter
2021-09-08 21:24:09 +03:00
y: parent.height - 60
width: parent.width - 40
2021-07-28 16:13:29 +07:00
height: 40
text: qsTr("Setup server")
onClicked: {
2021-09-20 21:51:28 +03:00
let cont = container_selector.selectedIndex
let tp = ProtocolProps.transportProtoFromString(cb_port_proto.currentText)
let port = tf_port_num.text
NewServerProtocolsLogic.onPushButtonConfigureClicked(cont, port, tp)
2021-07-28 16:13:29 +07:00
}
}
2021-09-08 21:24:09 +03:00
2021-09-10 22:19:00 +03:00
BlueButtonType {
2021-09-09 20:15:44 +03:00
id: pb_add_container
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: caption.bottom
anchors.topMargin: 10
2021-09-08 21:24:09 +03:00
2021-09-09 20:15:44 +03:00
width: parent.width - 40
height: 40
2021-09-10 22:19:00 +03:00
text: qsTr("Select protocol container")
font.pixelSize: 16
onClicked: container_selector.visible ? container_selector.close() : container_selector.open()
2021-09-08 21:24:09 +03:00
2021-09-09 20:15:44 +03:00
}
2021-09-08 21:24:09 +03:00
2021-09-09 20:15:44 +03:00
SelectContainer {
2021-09-10 22:19:00 +03:00
id: container_selector
2022-02-04 17:49:48 +03:00
onAboutToHide: {
pageLoader.focus = true
}
2021-09-20 21:51:28 +03:00
onContainerSelected: {
var containerProto = ContainerProps.defaultProtocol(c_index)
tf_port_num.text = ProtocolProps.defaultPort(containerProto)
cb_port_proto.currentIndex = ProtocolProps.defaultTransportProto(containerProto)
tf_port_num.enabled = ProtocolProps.defaultPortChangeable(containerProto)
cb_port_proto.enabled = ProtocolProps.defaultTransportProtoChangeable(containerProto)
}
2021-09-09 20:15:44 +03:00
}
2021-09-08 21:24:09 +03:00
2021-09-10 22:19:00 +03:00
Column {
id: c1
visible: container_selector.selectedIndex > 0
width: parent.width
anchors.top: pb_add_container.bottom
anchors.topMargin: 10
Caption {
font.pixelSize: 22
text: UiLogic.containerName(container_selector.selectedIndex)
}
Text {
width: parent.width
anchors.topMargin: 10
padding: 10
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
color: "#181922"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
text: UiLogic.containerDesc(container_selector.selectedIndex)
}
}
2021-09-09 20:15:44 +03:00
Rectangle {
id: frame_settings
2021-09-10 22:19:00 +03:00
visible: container_selector.selectedIndex > 0
2021-09-09 20:15:44 +03:00
width: parent.width
2021-09-10 22:19:00 +03:00
anchors.top: c1.bottom
2021-09-08 21:24:09 +03:00
anchors.topMargin: 10
2021-09-09 20:15:44 +03:00
border.width: 1
border.color: "lightgray"
anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter
radius: 2
Grid {
2021-09-10 22:19:00 +03:00
id: grid
visible: container_selector.selectedIndex > 0
2021-09-09 20:15:44 +03:00
anchors.fill: parent
columns: 2
horizontalItemAlignment: Grid.AlignHCenter
verticalItemAlignment: Grid.AlignVCenter
topPadding: 5
leftPadding: 10
spacing: 5
2021-09-08 21:24:09 +03:00
2021-09-09 20:15:44 +03:00
LabelType {
width: 130
2021-09-20 21:51:28 +03:00
text: qsTr("Port")
2021-09-09 20:15:44 +03:00
}
TextFieldType {
2021-09-20 21:51:28 +03:00
id: tf_port_num
2021-09-09 20:15:44 +03:00
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
}
LabelType {
width: 130
2021-09-20 21:51:28 +03:00
text: qsTr("Network Protocol")
2021-09-09 20:15:44 +03:00
}
ComboBoxType {
2021-09-20 21:51:28 +03:00
id: cb_port_proto
2021-09-09 20:15:44 +03:00
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
model: [
qsTr("udp"),
qsTr("tcp"),
]
2021-07-28 16:13:29 +07:00
}
2021-09-09 20:15:44 +03:00
}
}
2021-07-28 16:13:29 +07:00
}