2025-11-17 19:20:27 +04:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Dialogs
|
|
|
|
|
|
|
|
|
|
import PageEnum 1.0
|
|
|
|
|
import Style 1.0
|
|
|
|
|
|
|
|
|
|
import "./"
|
|
|
|
|
import "../Controls2"
|
|
|
|
|
import "../Controls2/TextTypes"
|
|
|
|
|
import "../Config"
|
|
|
|
|
|
|
|
|
|
PageType {
|
|
|
|
|
id: root
|
|
|
|
|
|
2026-01-16 02:31:21 +04:00
|
|
|
// Debug-friendly: don't auto-close on send; keep the page responsive and show status.
|
|
|
|
|
property bool isSending: false
|
|
|
|
|
|
2025-11-17 19:20:27 +04:00
|
|
|
function getAvailableCount() {
|
|
|
|
|
var max = ApiAccountInfoModel.data("maxDeviceCount")
|
|
|
|
|
var active = ApiAccountInfoModel.data("activeDeviceCount")
|
|
|
|
|
if (!max || max <= 0) max = 7
|
|
|
|
|
if (!active || active < 0) active = 0
|
|
|
|
|
var remain = max - active
|
|
|
|
|
return remain > 0 ? remain : 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListViewType {
|
|
|
|
|
id: listView
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.topMargin: 20
|
|
|
|
|
|
|
|
|
|
header: ColumnLayout {
|
|
|
|
|
width: listView.width
|
|
|
|
|
|
2026-01-16 02:31:21 +04:00
|
|
|
BackButtonType {
|
|
|
|
|
backButtonFunction: function() {
|
|
|
|
|
if (root.isSending) {
|
|
|
|
|
// We cannot truly abort GatewayController::post() without changing it,
|
|
|
|
|
// but we can at least stop waiting on the other side and let the user navigate.
|
|
|
|
|
TransferController.stopWaitForConfig()
|
|
|
|
|
}
|
|
|
|
|
PageController.closePage()
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-17 19:20:27 +04:00
|
|
|
|
|
|
|
|
BaseHeaderType {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
|
|
|
|
|
headerText: qsTr("Share VPN with a new device?")
|
|
|
|
|
descriptionText: qsTr("Your Amnezia Premium subscription can connect %1 more devices").arg(getAvailableCount())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicButtonType {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
Layout.topMargin: 16
|
|
|
|
|
|
|
|
|
|
text: qsTr("Yes, share")
|
2026-01-16 02:31:21 +04:00
|
|
|
enabled: !root.isSending && root.getAvailableCount() > 0 && TransferController.pendingQrCode !== ""
|
2025-11-17 19:20:27 +04:00
|
|
|
|
|
|
|
|
clickedFunc: function() {
|
|
|
|
|
if (TransferController.pendingQrCode !== "") {
|
2026-01-16 02:31:21 +04:00
|
|
|
root.isSending = true
|
2025-11-17 19:20:27 +04:00
|
|
|
TransferController.onTransferQrScanned(TransferController.pendingQrCode)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicButtonType {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
|
|
|
|
Layout.topMargin: 8
|
|
|
|
|
|
|
|
|
|
defaultColor: AmneziaStyle.color.transparent
|
|
|
|
|
hoveredColor: AmneziaStyle.color.translucentWhite
|
|
|
|
|
pressedColor: AmneziaStyle.color.sheerWhite
|
|
|
|
|
textColor: AmneziaStyle.color.paleGray
|
|
|
|
|
borderColor: AmneziaStyle.color.paleGray
|
|
|
|
|
borderWidth: 1
|
|
|
|
|
|
|
|
|
|
text: qsTr("Cancel")
|
2026-01-16 02:31:21 +04:00
|
|
|
enabled: !root.isSending
|
2025-11-17 19:20:27 +04:00
|
|
|
|
|
|
|
|
clickedFunc: function() {
|
|
|
|
|
PageController.closePage()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-28 12:45:50 +04:00
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: TransferController
|
|
|
|
|
|
|
|
|
|
function onPostStarted() {
|
2026-01-16 02:31:21 +04:00
|
|
|
PageController.showNotificationMessage(qsTr("Sending configuration..."))
|
2025-11-28 12:45:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPostSucceeded() {
|
2026-01-16 02:31:21 +04:00
|
|
|
root.isSending = false
|
|
|
|
|
PageController.showNotificationMessage(qsTr("Configuration sent successfully"))
|
|
|
|
|
PageController.closePage()
|
2025-11-28 12:45:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPostFailed(message) {
|
2026-01-16 02:31:21 +04:00
|
|
|
root.isSending = false
|
2025-11-28 12:45:50 +04:00
|
|
|
PageController.showErrorMessage(message)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-17 19:20:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|