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

390 lines
14 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import QtCore
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageType {
id: root
2023-07-25 16:56:10 +09:00
Connections {
target: ImportController
function onQrDecodingFinished() {
if (Qt.platform.os === "ios") {
PageController.closePage()
}
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
2023-07-25 16:56:10 +09:00
}
}
ListViewType {
2024-12-31 04:16:52 +01:00
id: listView
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
anchors.fill: parent
2024-12-31 04:16:52 +01:00
header: ColumnLayout {
width: listView.width
2024-04-18 17:54:55 +04:00
2025-05-02 23:54:36 -07:00
HeaderTypeWithButton {
2024-12-31 04:16:52 +01:00
id: moreButton
2024-12-31 04:16:52 +01:00
property bool isVisible: SettingsController.getInstallationUuid() !== "" || PageController.isStartPageVisible()
Layout.fillWidth: true
Layout.topMargin: 24 + PageController.safeAreaTopMargin
Layout.rightMargin: 16
Layout.leftMargin: 16
headerText: qsTr("Connection")
2024-09-09 20:53:44 +04:00
actionButtonImage: isVisible ? "qrc:/images/controls/more-vertical.svg" : ""
2024-09-09 20:53:44 +04:00
actionButtonFunction: function() {
2024-12-31 04:16:52 +01:00
moreActionsDrawer.openTriggered()
2024-09-09 20:53:44 +04:00
}
DrawerType2 {
id: moreActionsDrawer
parent: root
anchors.fill: parent
expandedHeight: root.height * 0.5
2024-09-09 20:53:44 +04:00
2024-12-31 04:16:52 +01:00
expandedStateContent: ColumnLayout {
2024-09-09 20:53:44 +04:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 0
2024-09-09 20:53:44 +04:00
2025-05-02 23:54:36 -07:00
BaseHeaderType {
2024-09-09 20:53:44 +04:00
Layout.fillWidth: true
Layout.topMargin: 32
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-09 20:53:44 +04:00
headerText: qsTr("Settings")
}
SwitcherType {
id: switcher
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-09 20:53:44 +04:00
text: qsTr("Enable logs")
visible: PageController.isStartPageVisible()
2024-09-09 20:53:44 +04:00
checked: SettingsController.isLoggingEnabled
2025-08-20 13:01:09 +08:00
onToggled: function() {
2024-09-09 20:53:44 +04:00
if (checked !== SettingsController.isLoggingEnabled) {
SettingsController.isLoggingEnabled = checked
}
}
}
LabelWithButtonType {
Layout.fillWidth: true
text: qsTr("Export client logs")
rightImageSource: "qrc:/images/controls/chevron-right.svg"
visible: PageController.isStartPageVisible()
clickedFunction: function() {
var fileName = ""
if (GC.isMobile()) {
fileName = "AmneziaVPN.log"
} else {
fileName = SystemController.getFileName(qsTr("Save"),
qsTr("Logs files (*.log)"),
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN",
true,
".log")
}
if (fileName !== "") {
PageController.showBusyIndicator(true)
SettingsController.exportLogsFile(fileName)
PageController.showBusyIndicator(false)
PageController.showNotificationMessage(qsTr("Logs file saved"))
}
}
}
2024-09-09 20:53:44 +04:00
LabelWithButtonType {
id: supportUuid
Layout.fillWidth: true
Layout.topMargin: 16
text: qsTr("Support tag")
descriptionText: SettingsController.getInstallationUuid()
descriptionOnTop: true
rightImageSource: "qrc:/images/controls/copy.svg"
rightImageColor: AmneziaStyle.color.paleGray
visible: SettingsController.getInstallationUuid() !== ""
clickedFunction: function() {
GC.copyToClipBoard(descriptionText)
PageController.showNotificationMessage(qsTr("Copied"))
if (!GC.isMobile()) {
this.rightButton.forceActiveFocus()
}
}
}
2024-09-09 20:53:44 +04:00
}
}
}
ParagraphTextType {
2024-12-31 04:16:52 +01:00
objectName: "insertKeyLabel"
Layout.fillWidth: true
Layout.topMargin: 32
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.bottomMargin: 24
text: qsTr("Insert the key, add a configuration file or scan the QR-code")
}
TextFieldWithHeaderType {
id: textKey
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
headerText: qsTr("Insert key")
buttonText: qsTr("Insert")
clickedFunc: function() {
textField.text = ""
textField.paste()
}
}
BasicButtonType {
id: continueButton
Layout.fillWidth: true
Layout.topMargin: 16
Layout.rightMargin: 16
Layout.leftMargin: 16
visible: textKey.textField.text !== ""
text: qsTr("Continue")
clickedFunc: function() {
if (ImportController.extractConfigFromData(textKey.textField.text)) {
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 32
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.bottomMargin: 24
color: AmneziaStyle.color.charcoalGray
text: qsTr("Other connection options")
}
2024-12-31 04:16:52 +01:00
}
model: variants
2024-12-31 04:16:52 +01:00
delegate: ColumnLayout {
width: listView.width
CardWithIconsType {
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.bottomMargin: 16
2024-12-31 04:16:52 +01:00
visible: isVisible
headerText: title
bodyText: description
2026-04-08 11:21:12 +07:00
showRecommendedBadge: featuredAmneziaConnection
recommendedText: featuredAmneziaConnection ? qsTr("Recommended") : ""
rightImageSource: "qrc:/images/controls/chevron-right.svg"
2024-12-31 04:16:52 +01:00
leftImageSource: imageSource
2024-12-31 04:16:52 +01:00
onClicked: { handler() }
Keys.onEnterPressed: this.clicked()
Keys.onReturnPressed: this.clicked()
}
2024-12-31 04:16:52 +01:00
}
footer: ColumnLayout {
width: listView.width
BasicButtonType {
id: siteLink2
Layout.topMargin: 24
Layout.bottomMargin: 16
Layout.alignment: Qt.AlignHCenter
implicitHeight: 32
2025-12-18 16:36:12 +02:00
visible: Qt.platform.os !== "ios" && !IsMacOsNeBuild
2025-01-26 14:14:39 +07:00
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.goldenApricot
text: qsTr("Site Amnezia")
rightImageSource: "qrc:/images/controls/external-link.svg"
clickedFunc: function() {
Qt.openUrlExternally(LanguageUiController.getCurrentSiteUrl())
}
}
}
2024-12-31 04:16:52 +01:00
}
2024-12-31 04:16:52 +01:00
property list<QtObject> variants: [
amneziaVpn,
selfHostVpn,
backupRestore,
fileOpen,
qrScan,
2025-12-18 16:36:12 +02:00
restorePurchases,
2024-12-31 04:16:52 +01:00
siteLink
]
QtObject {
id: amneziaVpn
property string title: qsTr("VPN by Amnezia")
2026-04-10 21:24:00 +07:00
property string description: qsTr("The easiest way to connect to the VPN")
2024-12-31 04:16:52 +01:00
property string imageSource: "qrc:/images/controls/amnezia.svg"
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: true
2024-12-31 04:16:52 +01:00
property bool isVisible: true
property var handler: function() {
PageController.showBusyIndicator(true)
var result = SubscriptionUiController.fillAvailableServices()
2024-12-31 04:16:52 +01:00
PageController.showBusyIndicator(false)
if (result) {
PageController.goToPage(PageEnum.PageSetupWizardApiServicesList)
}
2024-12-31 04:16:52 +01:00
}
}
2024-12-31 04:16:52 +01:00
QtObject {
id: selfHostVpn
2024-04-18 17:54:55 +04:00
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: false
2024-12-31 04:16:52 +01:00
property string title: qsTr("Self-hosted VPN")
property string description: qsTr("Configure Amnezia VPN on your own server")
property string imageSource: "qrc:/images/controls/server.svg"
property bool isVisible: true
property var handler: function() {
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
}
}
2024-12-31 04:16:52 +01:00
QtObject {
id: backupRestore
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: false
2024-12-31 04:16:52 +01:00
property string title: qsTr("Restore from backup")
property string description: qsTr("")
property string imageSource: "qrc:/images/controls/archive-restore.svg"
property bool isVisible: PageController.isStartPageVisible()
property var handler: function() {
var filePath = SystemController.getFileName(qsTr("Open backup file"),
qsTr("Backup files (*.backup)"))
if (filePath !== "") {
PageController.showBusyIndicator(true)
SettingsController.restoreAppConfig(filePath)
PageController.showBusyIndicator(false)
}
2024-12-31 04:16:52 +01:00
}
}
2024-12-31 04:16:52 +01:00
QtObject {
id: fileOpen
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: false
2024-12-31 04:16:52 +01:00
property string title: qsTr("File with connection settings")
property string description: qsTr("")
property string imageSource: "qrc:/images/controls/folder-search-2.svg"
property bool isVisible: true
property var handler: function() {
var nameFilter = "Config files (*.vpn *.ovpn *.conf *.json)"
2024-12-31 04:16:52 +01:00
var fileName = SystemController.getFileName(qsTr("Open config file"), nameFilter)
if (fileName !== "") {
if (ImportController.extractConfigFromFile(fileName)) {
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
2024-12-31 04:16:52 +01:00
}
}
2023-05-22 22:11:20 +08:00
2024-12-31 04:16:52 +01:00
QtObject {
id: qrScan
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: false
2024-12-31 04:16:52 +01:00
property string title: qsTr("QR code")
property string description: qsTr("")
property string imageSource: "qrc:/images/controls/scan-line.svg"
property bool isVisible: SettingsController.isCameraPresent()
property var handler: function() {
ImportController.startDecodingQr()
if (Qt.platform.os === "ios") {
PageController.goToPage(PageEnum.PageSetupWizardQrReader)
}
}
}
2024-04-18 17:54:55 +04:00
2025-12-18 16:36:12 +02:00
QtObject {
id: restorePurchases
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: false
2025-12-18 16:36:12 +02:00
property string title: qsTr("Restore purchases")
property string description: qsTr("")
property string imageSource: "qrc:/images/controls/refresh-cw.svg"
property bool isVisible: Qt.platform.os === "ios" || IsMacOsNeBuild
property var handler: function() {
PageController.showBusyIndicator(true)
SubscriptionUiController.restoreServiceFromAppStore()
2025-12-18 16:36:12 +02:00
PageController.showBusyIndicator(false)
}
}
2024-12-31 04:16:52 +01:00
QtObject {
id: siteLink
2026-04-08 11:21:12 +07:00
property bool featuredAmneziaConnection: false
2024-12-31 04:16:52 +01:00
property string title: qsTr("I have nothing")
property string description: qsTr("")
property string imageSource: "qrc:/images/controls/help-circle.svg"
2025-12-18 16:36:12 +02:00
property bool isVisible: PageController.isStartPageVisible() && Qt.platform.os !== "ios" && !IsMacOsNeBuild
2024-12-31 04:16:52 +01:00
property var handler: function() {
Qt.openUrlExternally(LanguageUiController.getCurrentSiteUrl())
}
}
}