Files
amnezia-client/client/ui/qml/Pages2/PageSettingsApiDevices.qml
T
NickVs2015andvkamn ddde43635e feat: local proxy mode (#3166)
* fix: share double-stop guard via VpnProtocol base class

* feat: add local proxy core module

* feat: local proxy settings api

* feat: wire local proxy into app controllers

* feat: local proxy settings ui

* feat: arbitrate shared xray engine ownership via ipc tokens

* fix: remove connection type

* chore: add qthttpserver to desktop ci qt modules

* fix: local proxy port fallback and active port reporting

* fix: keep text field button aligned when error is shown

* fix: hide local proxy for free servers and guard device unlink

* fix: show local proxy state per server

* fix: anchor text field button to content

* fix: adapt local proxy pages to design

* fix: copy logic and port logic

* refactor: move local proxy files to controllers and utils

* refactor: merge local proxy into LocalProxyController

* refactor: reuse gateway config request and keep local proxy state in memory

---------

Co-authored-by: vkamn <vk@amnezia.org>
2026-10-18 21:25:04 +08:00

110 lines
3.7 KiB
QML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import QtCore
import SortFilterProxyModel 0.2
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
ListViewType {
id: listView
anchors.fill: parent
model: ApiDevicesModel
header: ColumnLayout {
width: listView.width
spacing: 0
NavigationBarType {
Layout.fillWidth: true
title: qsTr("Active Devices")
description: qsTr("Manage currently connected devices")
}
NotificationType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 24
Layout.rightMargin: 16
Layout.leftMargin: 16
text: qsTr("You can find the identifier on the Support tab or, for older versions of the app, "
+ "by tapping '+' and then the three dots at the top of the page.")
}
}
footer: Item {
width: listView.width
height: 16 + PageController.safeAreaBottomMargin
}
delegate: ColumnLayout {
width: listView.width
spacing: 0
ListItemType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: osVersion + (isCurrentDevice ? qsTr(" (current device)") : "")
subtitle: qsTr("Support tag: ") + "\n" + supportTag + "\n" + qsTr("Last updated: ") + lastUpdate
trailingIconSource: "qrc:/images/controls/trash.svg"
onClicked: {
if (isCurrentDevice && ServersUiController.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected) {
PageController.showNotificationMessage(qsTr("Cannot unlink device during active connection"))
return
}
if (isCurrentDevice && LocalProxyController.isEnabled
&& LocalProxyController.ownerId === ServersUiController.processedServerId) {
PageController.showNotificationMessage(qsTr("Cannot unlink device while local proxy is running"))
return
}
var headerText = qsTr("Are you sure you want to unlink this device?")
var descriptionText = qsTr("This will unlink the device from your subscription. You can reconnect it anytime by pressing \"Reload API config\" in subscription settings on device.")
var yesButtonText = qsTr("Continue")
var noButtonText = qsTr("Cancel")
var yesButtonFunction = function() {
var serverId = ServersUiController.processedServerId
Qt.callLater(deactivateExternalDevice, serverId, supportTag, countryCode)
}
var noButtonFunction = function() {
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
}
}
}
function deactivateExternalDevice(serverId, supportTag, countryCode) {
PageController.showBusyIndicator(true)
if (SubscriptionUiController.deactivateExternalDevice(serverId, supportTag, countryCode)) {
SubscriptionUiController.getAccountInfo(serverId, true)
}
PageController.showBusyIndicator(false)
}
}