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

256 lines
8.6 KiB
QML
Raw Normal View History

2023-06-13 20:03:20 +09:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
2023-08-30 15:10:44 +05:00
import QtCore
2023-06-13 20:03:20 +09:00
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ContainerProps 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
2023-09-02 17:04:35 -04:00
import "../Config"
import "../Components"
2023-06-13 20:03:20 +09:00
DrawerType {
id: root
property alias headerText: header.headerText
property alias configContentHeaderText: configContentHeader.headerText
2023-07-04 09:58:19 +09:00
property alias contentVisible: content.visible
2023-06-13 20:03:20 +09:00
2023-08-22 14:37:29 +05:00
property string configExtension: ".vpn"
property string configCaption: qsTr("Save AmneziaVPN config")
property string configFileName: "amnezia_config.vpn"
2023-06-13 20:03:20 +09:00
width: parent.width
height: parent.height * 0.9
2023-08-22 14:37:29 +05:00
onClosed: {
configExtension = ".vpn"
configCaption = qsTr("Save AmneziaVPN config")
configFileName = "amnezia_config"
2023-08-22 14:37:29 +05:00
}
Item {
2023-06-13 20:03:20 +09:00
anchors.fill: parent
2023-07-04 09:58:19 +09:00
Header2Type {
id: header
2023-06-13 20:03:20 +09:00
anchors.top: parent.top
2023-07-04 09:58:19 +09:00
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.leftMargin: 16
anchors.rightMargin: 16
}
FlickableType {
anchors.top: header.bottom
2023-06-13 20:03:20 +09:00
anchors.bottom: parent.bottom
contentHeight: content.height + 32
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 16
2023-07-25 16:56:10 +09:00
text: qsTr("Share")
imageSource: "qrc:/images/controls/share-2.svg"
2023-06-13 20:03:20 +09:00
2023-09-01 17:29:48 +03:00
onClicked: {
var fileName = ""
2023-09-02 17:04:35 -04:00
if (GC.isMobile()) {
fileName = configFileName + configExtension
2023-09-01 17:29:48 +03:00
} else {
fileName = SystemController.getFileName(configCaption,
qsTr("Config files (*" + configExtension + ")"),
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/" + configFileName,
true,
configExtension)
2023-09-01 17:29:48 +03:00
}
if (fileName !== "") {
PageController.showBusyIndicator(true)
ExportController.exportConfig(fileName)
PageController.showBusyIndicator(false)
2023-08-30 15:10:44 +05:00
}
2023-06-13 20:03:20 +09:00
}
}
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 8
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 1
text: qsTr("Copy")
imageSource: "qrc:/images/controls/copy.svg"
2023-06-13 20:03:20 +09:00
onClicked: {
configText.selectAll()
configText.copy()
configText.select(0, 0)
PageController.showNotificationMessage(qsTr("Copied"))
2023-06-13 20:03:20 +09:00
}
}
BasicButtonType {
Layout.fillWidth: true
2023-10-03 23:28:44 +05:00
Layout.topMargin: 24
2023-06-13 20:03:20 +09:00
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 1
2023-06-13 20:03:20 +09:00
2023-10-03 23:28:44 +05:00
text: qsTr("Show connection settings")
2023-06-13 20:03:20 +09:00
onClicked: {
configContentDrawer.visible = true
2023-06-13 20:03:20 +09:00
}
}
DrawerType {
id: configContentDrawer
2023-06-13 20:03:20 +09:00
width: parent.width
height: parent.height * 0.9
2023-06-13 20:03:20 +09:00
BackButtonType {
id: backButton
2023-06-13 20:03:20 +09:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
2023-06-13 20:03:20 +09:00
backButtonFunction: function() {
configContentDrawer.visible = false
}
}
2023-06-13 20:03:20 +09:00
FlickableType {
anchors.top: backButton.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentHeight: configContent.implicitHeight + configContent.anchors.topMargin + configContent.anchors.bottomMargin
2023-06-13 20:03:20 +09:00
ColumnLayout {
id: configContent
2023-06-13 20:03:20 +09:00
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
2023-06-13 20:03:20 +09:00
Header2Type {
id: configContentHeader
Layout.fillWidth: true
Layout.topMargin: 16
}
2023-06-13 20:03:20 +09:00
TextField {
id: configText
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
padding: 0
leftPadding: 0
height: 24
2023-06-13 20:03:20 +09:00
readOnly: true
color: "#D7D8DB"
2023-08-26 10:08:50 +03:00
selectionColor: "#633303"
selectedTextColor: "#D7D8DB"
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
2023-07-14 13:14:50 +09:00
text: ExportController.config
wrapMode: Text.Wrap
background: Rectangle {
color: "transparent"
}
}
2023-06-13 20:03:20 +09:00
}
}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: width
Layout.topMargin: 20
visible: ExportController.qrCodesCount > 0
2023-06-13 20:03:20 +09:00
color: "white"
Image {
anchors.fill: parent
smooth: false
source: ExportController.qrCodesCount ? ExportController.qrCodes[0] : ""
2023-06-13 20:03:20 +09:00
Timer {
property int index: 0
2023-06-13 20:03:20 +09:00
interval: 1000
running: ExportController.qrCodesCount > 0
2023-06-13 20:03:20 +09:00
repeat: true
onTriggered: {
if (ExportController.qrCodesCount > 0) {
index++
if (index >= ExportController.qrCodesCount) {
index = 0
}
parent.source = ExportController.qrCodes[index]
2023-06-13 20:03:20 +09:00
}
}
}
Behavior on source {
PropertyAnimation { duration: 200 }
}
}
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 24
Layout.bottomMargin: 32
visible: ExportController.qrCodesCount > 0
2023-06-13 20:03:20 +09:00
horizontalAlignment: Text.AlignHCenter
text: qsTr("To read the QR code in the Amnezia app, select \"Add server\" → \"I have data to connect\" → \"QR code, key or settings file\"")
2023-06-13 20:03:20 +09:00
}
}
}
}
}