Files
amnezia-client/client/ui/qml/Pages/Share/PageShareProtoAmnezia.qml
T

146 lines
4.7 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2021-11-08 15:18:52 +03:00
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageShareProtocolBase {
id: root
protocol: ProtocolEnum.Any
2021-11-13 16:09:08 +03:00
2021-11-08 15:18:52 +03:00
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("Share for Amnezia")
}
2022-12-24 16:41:53 +00:00
FlickableType {
2021-11-13 16:09:08 +03:00
id: fl
2021-11-08 15:18:52 +03:00
anchors.top: caption.bottom
2021-11-13 16:09:08 +03:00
contentHeight: content.height + 20
2021-11-08 15:18:52 +03:00
2021-12-20 02:29:23 +03:00
Behavior on contentY{
NumberAnimation {
duration: 300
easing.type: Easing.InOutCubic
}
}
2021-11-13 16:09:08 +03:00
ColumnLayout {
id: content
enabled: logic.pageEnabled
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 15
2021-11-08 15:18:52 +03:00
2021-11-13 16:09:08 +03:00
Text {
id: lb_desc
Layout.fillWidth: true
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
color: "#181922"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
text: ShareConnectionLogic.shareFullAccess
? qsTr("Anyone who logs in with this code will have the same permissions to use VPN and YOUR SERVER as you. \n
This code includes your server credentials!\n
Provide this code only to TRUSTED users.")
: qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \n
2021-11-13 17:20:23 +03:00
This code does not include server credentials.\n
New encryption keys pair will be generated.")
2021-11-13 16:09:08 +03:00
}
ShareConnectionButtonType {
Layout.topMargin: 20
Layout.fillWidth: true
Layout.preferredHeight: 40
text: ShareConnectionLogic.shareFullAccess
? showConfigText
: (genConfigProcess ? generatingConfigText : generateConfigText)
onClicked: {
enabled = false
genConfigProcess = true
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
enabled = true
genConfigProcess = false
2021-12-20 02:29:23 +03:00
fl.contentY = tfShareCode.mapToItem(fl.contentItem, 0, 0).y
2021-11-13 16:09:08 +03:00
}
}
TextAreaType {
id: tfShareCode
Layout.topMargin: 20
Layout.bottomMargin: 20
Layout.preferredHeight: 200
Layout.fillWidth: true
textArea.readOnly: true
textArea.wrapMode: TextEdit.WrapAnywhere
textArea.verticalAlignment: Text.AlignTop
textArea.text: ShareConnectionLogic.textEditShareAmneziaCodeText
visible: tfShareCode.textArea.length > 0
}
ShareConnectionButtonCopyType {
Layout.bottomMargin: 10
Layout.fillWidth: true
Layout.preferredHeight: 40
2021-11-15 18:17:28 +03:00
copyText: tfShareCode.textArea.text
2021-11-13 16:09:08 +03:00
}
ShareConnectionButtonType {
Layout.bottomMargin: 10
Layout.fillWidth: true
Layout.preferredHeight: 40
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
2021-11-13 16:09:08 +03:00
enabled: tfShareCode.textArea.length > 0
visible: tfShareCode.textArea.length > 0
onClicked: {
UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "amnezia_config.vpn", "*.vpn", tfShareCode.textArea.text)
2021-11-13 16:09:08 +03:00
}
}
Image {
2021-12-20 02:29:23 +03:00
id: image_share_code
2021-11-13 16:09:08 +03:00
Layout.topMargin: 20
Layout.fillWidth: true
Layout.preferredHeight: width
smooth: false
2021-12-20 02:29:23 +03:00
Timer {
property int idx: 0
interval: 1000
running: root.pageActive && ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0
repeat: true
onTriggered: {
idx++
if (idx >= ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength) {
idx = 0
}
image_share_code.source = ShareConnectionLogic.shareAmneziaQrCodeTextSeries[idx]
}
}
visible: ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0
2021-11-13 17:20:23 +03:00
}
LabelType {
2021-11-19 23:04:35 +03:00
Layout.fillWidth: true
2021-12-20 02:29:23 +03:00
text: qsTr("Scan QR code using AmneziaVPN mobile")
2021-11-13 16:09:08 +03:00
}
2021-11-08 15:18:52 +03:00
}
}
}