2023-06-05 15:49:10 +08:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Dialogs
|
|
|
|
|
|
|
|
|
|
import PageEnum 1.0
|
2024-07-07 13:42:38 +03:00
|
|
|
import Style 1.0
|
2023-06-05 15:49:10 +08:00
|
|
|
|
|
|
|
|
import "./"
|
|
|
|
|
import "../Controls2"
|
|
|
|
|
import "../Controls2/TextTypes"
|
|
|
|
|
import "../Config"
|
|
|
|
|
|
|
|
|
|
PageType {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property bool showContent: false
|
|
|
|
|
|
2024-04-18 17:54:55 +04:00
|
|
|
BackButtonType {
|
|
|
|
|
id: backButton
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2026-04-30 14:53:03 +08:00
|
|
|
anchors.topMargin: 20 + PageController.safeAreaTopMargin
|
2025-08-06 04:35:51 +02:00
|
|
|
|
|
|
|
|
onActiveFocusChanged: {
|
|
|
|
|
if(backButton.enabled && backButton.activeFocus) {
|
|
|
|
|
listView.positionViewAtBeginning()
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-18 17:54:55 +04:00
|
|
|
}
|
|
|
|
|
|
2025-12-02 05:13:26 +02:00
|
|
|
Connections {
|
|
|
|
|
target: PageController
|
|
|
|
|
|
|
|
|
|
function onClosePage() {
|
|
|
|
|
ImportController.clearConfigFileName()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
Connections {
|
|
|
|
|
target: ImportController
|
|
|
|
|
|
2024-10-13 15:14:43 +04:00
|
|
|
function onImportErrorOccurred(error, goToPageHome) {
|
2025-10-09 23:22:58 +08:00
|
|
|
PageController.showBusyIndicator(false)
|
2024-02-09 23:23:26 +05:00
|
|
|
if (goToPageHome) {
|
|
|
|
|
PageController.goToStartPage()
|
|
|
|
|
} else {
|
|
|
|
|
PageController.closePage()
|
|
|
|
|
}
|
2023-06-05 15:49:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onImportFinished() {
|
2025-10-09 23:22:58 +08:00
|
|
|
PageController.showBusyIndicator(false)
|
2024-08-20 16:54:05 +07:00
|
|
|
PageController.goToPageHome()
|
2023-06-05 15:49:10 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-06 04:35:51 +02:00
|
|
|
ListViewType {
|
|
|
|
|
id: listView
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
anchors.top: backButton.bottom
|
2023-06-20 10:25:24 +09:00
|
|
|
anchors.bottom: parent.bottom
|
2025-08-06 04:35:51 +02:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: parent.left
|
2023-06-05 15:49:10 +08:00
|
|
|
|
2025-08-06 04:35:51 +02:00
|
|
|
header: ColumnLayout {
|
|
|
|
|
width: listView.width
|
2023-06-05 15:49:10 +08:00
|
|
|
|
2025-05-02 23:54:36 -07:00
|
|
|
BaseHeaderType {
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
headerText: qsTr("New connection")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.topMargin: 32
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
|
|
visible: fileName.text !== ""
|
|
|
|
|
|
|
|
|
|
Image {
|
2024-03-26 20:05:04 +02:00
|
|
|
source: "qrc:/images/controls/file-check-2.svg"
|
2023-06-05 15:49:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Header2TextType {
|
|
|
|
|
id: fileName
|
|
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
text: ImportController.getConfigFileName()
|
2023-08-16 12:11:34 +05:00
|
|
|
wrapMode: Text.Wrap
|
2023-06-05 15:49:10 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicButtonType {
|
2024-04-18 17:54:55 +04:00
|
|
|
id: showContentButton
|
2023-08-01 11:06:46 +09:00
|
|
|
Layout.topMargin: 16
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
|
2023-08-01 11:06:46 +09:00
|
|
|
implicitHeight: 32
|
|
|
|
|
|
2024-07-07 13:42:38 +03:00
|
|
|
defaultColor: AmneziaStyle.color.transparent
|
2024-08-20 16:54:05 +07:00
|
|
|
hoveredColor: AmneziaStyle.color.translucentWhite
|
|
|
|
|
pressedColor: AmneziaStyle.color.sheerWhite
|
|
|
|
|
disabledColor: AmneziaStyle.color.mutedGray
|
|
|
|
|
textColor: AmneziaStyle.color.goldenApricot
|
2023-06-05 15:49:10 +08:00
|
|
|
|
|
|
|
|
text: showContent ? qsTr("Collapse content") : qsTr("Show content")
|
2024-12-31 04:16:52 +01:00
|
|
|
|
2024-02-17 23:09:05 +02:00
|
|
|
clickedFunc: function() {
|
2023-06-05 15:49:10 +08:00
|
|
|
showContent = !showContent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 00:23:15 +07:00
|
|
|
CheckBoxType {
|
|
|
|
|
id: cloakingCheckBox
|
2025-08-06 04:35:51 +02:00
|
|
|
objectName: "cloakingCheckBox"
|
2024-04-19 00:23:15 +07:00
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
visible: ImportController.isNativeWireGuardConfig
|
2024-04-19 00:23:15 +07:00
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
|
2024-04-19 00:23:15 +07:00
|
|
|
text: qsTr("Enable WireGuard obfuscation. It may be useful if WireGuard is blocked on your provider.")
|
|
|
|
|
}
|
2025-08-06 04:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model: 1 // fake model to force the ListView to be created without a model
|
|
|
|
|
|
|
|
|
|
delegate: ColumnLayout { // TODO(CyAn84): add DelegateChooser after have migrated to 6.9
|
|
|
|
|
width: listView.width
|
2024-04-19 00:23:15 +07:00
|
|
|
|
2024-04-21 17:58:57 +05:00
|
|
|
WarningType {
|
|
|
|
|
Layout.fillWidth: true
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.topMargin: 16
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
2024-04-21 17:58:57 +05:00
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
textString: ImportController.maliciousWarningText
|
2024-04-21 17:58:57 +05:00
|
|
|
textFormat: Qt.RichText
|
|
|
|
|
visible: textString !== ""
|
|
|
|
|
|
|
|
|
|
iconPath: "qrc:/images/controls/alert-circle.svg"
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
textColor: AmneziaStyle.color.vibrantRed
|
|
|
|
|
imageColor: AmneziaStyle.color.vibrantRed
|
2024-04-21 17:58:57 +05:00
|
|
|
}
|
|
|
|
|
|
2024-03-26 20:05:04 +02:00
|
|
|
WarningType {
|
|
|
|
|
Layout.fillWidth: true
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.topMargin: 16
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
2024-03-26 20:05:04 +02:00
|
|
|
|
|
|
|
|
textString: qsTr("Use connection codes only from sources you trust. Codes from public sources may have been created to intercept your data.")
|
|
|
|
|
|
|
|
|
|
iconPath: "qrc:/images/controls/alert-circle.svg"
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
Rectangle {
|
|
|
|
|
Layout.fillWidth: true
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.topMargin: 16
|
2024-05-03 03:12:22 +03:00
|
|
|
Layout.bottomMargin: 48
|
2025-08-06 04:35:51 +02:00
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
Layout.leftMargin: 16
|
2023-06-05 15:49:10 +08:00
|
|
|
|
|
|
|
|
implicitHeight: configContent.implicitHeight
|
|
|
|
|
|
|
|
|
|
radius: 10
|
2024-08-20 16:54:05 +07:00
|
|
|
color: AmneziaStyle.color.onyxBlack
|
2023-06-05 15:49:10 +08:00
|
|
|
|
|
|
|
|
visible: showContent
|
|
|
|
|
|
|
|
|
|
ParagraphTextType {
|
|
|
|
|
id: configContent
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.margins: 16
|
|
|
|
|
|
2024-04-21 17:58:57 +05:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
text: ImportController.getConfig()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-06 04:35:51 +02:00
|
|
|
footer: ColumnLayout {
|
|
|
|
|
width: listView.width
|
2024-05-03 03:12:22 +03:00
|
|
|
|
2025-08-06 04:35:51 +02:00
|
|
|
BasicButtonType {
|
|
|
|
|
id: connectButton
|
|
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.topMargin: 16
|
|
|
|
|
Layout.bottomMargin: 32
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
|
|
|
|
|
text: qsTr("Connect")
|
|
|
|
|
clickedFunc: function() {
|
|
|
|
|
const headerItem = listView.headerItem;
|
|
|
|
|
if (!headerItem) {
|
|
|
|
|
console.error("Header item not found in ListView")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cloakingCheckBoxItem = listView.findChildWithObjectName(headerItem.children, "cloakingCheckBox");
|
|
|
|
|
if (!cloakingCheckBoxItem) {
|
|
|
|
|
console.error("cloakingCheckBox not found")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cloakingCheckBoxItem.checked) {
|
|
|
|
|
ImportController.processNativeWireGuardConfig()
|
|
|
|
|
}
|
2025-10-09 23:22:58 +08:00
|
|
|
PageController.showBusyIndicator(true)
|
2025-08-06 04:35:51 +02:00
|
|
|
ImportController.importConfig()
|
2024-04-19 00:23:15 +07:00
|
|
|
}
|
2023-06-05 15:49:10 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|