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

211 lines
6.6 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ContainerProps 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
DrawerType {
id: root
property alias headerText: header.headerText
property alias configContentHeaderText: configContentHeader.headerText
width: parent.width
height: parent.height * 0.9
Item {
anchors.fill: parent
FlickableType {
anchors.top: parent.top
anchors.bottom: parent.bottom
contentHeight: content.height + 32
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
anchors.leftMargin: 16
anchors.rightMargin: 16
Header2Type {
id: header
Layout.fillWidth: true
}
BasicButtonType {
Layout.fillWidth: true
Layout.topMargin: 16
text: qsTr("Save connection code")
onClicked: {
ExportController.saveFile()
}
}
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")
onClicked: {
configContent.selectAll()
configContent.copy()
configContent.select(0, 0)
}
}
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"
text: qsTr("Show content")
onClicked: {
configContentDrawer.visible = true
}
}
DrawerType {
id: configContentDrawer
width: parent.width
height: parent.height * 0.9
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.topMargin: 16
backButtonFunction: function() {
configContentDrawer.visible = false
}
}
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
ColumnLayout {
id: configContent
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
Header2Type {
id: configContentHeader
Layout.fillWidth: true
Layout.topMargin: 16
}
TextField {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
padding: 0
height: 24
color: "#D7D8DB"
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
text: ExportController.amneziaCode
wrapMode: Text.Wrap
readOnly: true
background: Rectangle {
color: "transparent"
}
}
}
}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: width
Layout.topMargin: 20
visible: ExportController.qrCodesCount > 0
color: "white"
Image {
anchors.fill: parent
smooth: false
source: ExportController.qrCodesCount ? ExportController.qrCodes[0] : ""
Timer {
property int index: 0
interval: 1000
running: ExportController.qrCodesCount > 0
repeat: true
onTriggered: {
index++
if (index >= ExportController.qrCodesCount) {
index = 0
}
parent.source = ExportController.qrCodes[index]
}
}
Behavior on source {
PropertyAnimation { duration: 200 }
}
}
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 24
Layout.bottomMargin: 32
horizontalAlignment: Text.AlignHCenter
text: qsTr("To read the QR code in the Amnezia app, select \"Add Server\" → \"I have connection details\"")
}
}
}
}
}