2024-08-20 16:54:05 +07:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Dialogs
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
import PageEnum 1.0
|
|
|
|
|
import Style 1.0
|
|
|
|
|
|
|
|
|
|
import "./"
|
|
|
|
|
import "../Controls2"
|
|
|
|
|
import "../Controls2/TextTypes"
|
|
|
|
|
import "../Config"
|
|
|
|
|
import "../Components"
|
|
|
|
|
|
|
|
|
|
PageType {
|
|
|
|
|
id: root
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
property var processedServer
|
2026-03-25 07:34:42 +03:00
|
|
|
property bool subscriptionExpired: false
|
|
|
|
|
property bool subscriptionExpiringSoon: false
|
2026-04-08 11:21:12 +07:00
|
|
|
property bool isSubscriptionRenewalAvailable: false
|
|
|
|
|
property bool isInAppPurchase: false
|
|
|
|
|
|
2026-03-25 07:34:42 +03:00
|
|
|
function updateSubscriptionState() {
|
2026-05-28 10:57:08 +08:00
|
|
|
root.subscriptionExpired = ServersUiController.isServerSubscriptionExpired(ServersUiController.processedServerId)
|
|
|
|
|
root.subscriptionExpiringSoon = ServersUiController.isServerSubscriptionExpiringSoon(ServersUiController.processedServerId)
|
2026-04-08 11:21:12 +07:00
|
|
|
root.isSubscriptionRenewalAvailable = ApiAccountInfoModel.data("isSubscriptionRenewalAvailable")
|
|
|
|
|
root.isInAppPurchase = ApiAccountInfoModel.data("isInAppPurchase")
|
2026-03-25 07:34:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
root.updateSubscriptionState()
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
Connections {
|
2026-05-28 10:57:08 +08:00
|
|
|
target: ServersUiController
|
2025-01-31 10:06:35 +07:00
|
|
|
|
2026-05-28 10:57:08 +08:00
|
|
|
function onProcessedServerIdChanged() {
|
2025-01-31 10:06:35 +07:00
|
|
|
root.processedServer = proxyServersModel.get(0)
|
2026-03-25 14:48:32 +03:00
|
|
|
root.updateSubscriptionState()
|
2026-03-25 07:34:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 10:57:08 +08:00
|
|
|
Connections {
|
|
|
|
|
target: ServersModel
|
|
|
|
|
|
|
|
|
|
function onModelReset() {
|
|
|
|
|
root.processedServer = proxyServersModel.get(0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 11:21:12 +07:00
|
|
|
Connections {
|
|
|
|
|
target: ApiAccountInfoModel
|
|
|
|
|
|
|
|
|
|
function onModelReset() {
|
|
|
|
|
root.updateSubscriptionState()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
SortFilterProxyModel {
|
|
|
|
|
id: proxyServersModel
|
|
|
|
|
objectName: "proxyServersModel"
|
|
|
|
|
|
|
|
|
|
sourceModel: ServersModel
|
|
|
|
|
filters: [
|
|
|
|
|
ValueFilter {
|
2026-05-28 10:57:08 +08:00
|
|
|
roleName: "serverId"
|
|
|
|
|
value: ServersUiController.processedServerId
|
2025-01-31 10:06:35 +07:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
root.processedServer = proxyServersModel.get(0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 13:39:03 +07:00
|
|
|
ListViewType {
|
2024-08-20 16:54:05 +07:00
|
|
|
id: menuContent
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
model: ApiCountryModel
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
currentIndex: 0
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
ButtonGroup {
|
|
|
|
|
id: containersRadioButtonGroup
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
header: ColumnLayout {
|
|
|
|
|
width: menuContent.width
|
|
|
|
|
|
|
|
|
|
spacing: 4
|
|
|
|
|
|
|
|
|
|
BackButtonType {
|
|
|
|
|
id: backButton
|
|
|
|
|
objectName: "backButton"
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
Layout.topMargin: 20 + PageController.safeAreaTopMargin
|
2025-01-31 10:06:35 +07:00
|
|
|
}
|
|
|
|
|
|
2025-05-02 23:54:36 -07:00
|
|
|
HeaderTypeWithButton {
|
2025-01-31 10:06:35 +07:00
|
|
|
id: headerContent
|
|
|
|
|
objectName: "headerContent"
|
|
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
2026-04-08 11:21:12 +07:00
|
|
|
Layout.bottomMargin: root.subscriptionExpired || root.subscriptionExpiringSoon ? 0 : 4
|
2025-01-31 10:06:35 +07:00
|
|
|
|
|
|
|
|
actionButtonImage: "qrc:/images/controls/settings.svg"
|
|
|
|
|
|
|
|
|
|
headerText: root.processedServer.name
|
|
|
|
|
|
|
|
|
|
actionButtonFunction: function() {
|
2025-02-07 22:22:14 +07:00
|
|
|
PageController.showBusyIndicator(true)
|
2026-05-28 10:57:08 +08:00
|
|
|
let result = SubscriptionUiController.getAccountInfo(ServersUiController.processedServerId, false)
|
2025-02-07 22:22:14 +07:00
|
|
|
PageController.showBusyIndicator(false)
|
2025-02-10 15:10:59 +07:00
|
|
|
if (!result) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-02-07 22:22:14 +07:00
|
|
|
|
2025-01-31 10:06:35 +07:00
|
|
|
PageController.goToPage(PageEnum.PageSettingsApiServerInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-25 07:34:42 +03:00
|
|
|
|
2026-04-08 11:21:12 +07:00
|
|
|
ParagraphTextType {
|
2026-03-25 07:34:42 +03:00
|
|
|
visible: root.subscriptionExpired || root.subscriptionExpiringSoon
|
|
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
2026-04-08 11:21:12 +07:00
|
|
|
Layout.topMargin: 12
|
2026-03-25 07:34:42 +03:00
|
|
|
|
|
|
|
|
text: root.subscriptionExpired ? qsTr("Subscription expired") : qsTr("Subscription expiring soon")
|
|
|
|
|
color: root.subscriptionExpired ? AmneziaStyle.color.vibrantRed : AmneziaStyle.color.goldenApricot
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicButtonType {
|
2026-04-08 11:21:12 +07:00
|
|
|
visible: (root.subscriptionExpired || root.subscriptionExpiringSoon)
|
|
|
|
|
&& root.isSubscriptionRenewalAvailable && !root.isInAppPurchase
|
2026-03-25 07:34:42 +03:00
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
2026-04-08 11:21:12 +07:00
|
|
|
Layout.topMargin: 28
|
|
|
|
|
Layout.bottomMargin: 0
|
2026-03-25 07:34:42 +03:00
|
|
|
|
|
|
|
|
defaultColor: AmneziaStyle.color.paleGray
|
|
|
|
|
hoveredColor: AmneziaStyle.color.lightGray
|
|
|
|
|
pressedColor: AmneziaStyle.color.mutedGray
|
|
|
|
|
textColor: AmneziaStyle.color.midnightBlack
|
|
|
|
|
|
|
|
|
|
text: qsTr("Renew subscription")
|
|
|
|
|
|
|
|
|
|
clickedFunc: function() {
|
2026-05-28 10:57:08 +08:00
|
|
|
SubscriptionUiController.getRenewalLink(ServersUiController.processedServerId)
|
2026-03-25 07:34:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 11:21:12 +07:00
|
|
|
ParagraphTextType {
|
2026-03-25 07:34:42 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: 16
|
2026-04-08 11:21:12 +07:00
|
|
|
Layout.topMargin: (root.subscriptionExpired || root.subscriptionExpiringSoon) ? 12 : 4
|
2026-03-25 07:34:42 +03:00
|
|
|
Layout.bottomMargin: 8
|
|
|
|
|
|
|
|
|
|
text: qsTr("Location for connection")
|
|
|
|
|
color: AmneziaStyle.color.mutedGray
|
|
|
|
|
}
|
2025-01-31 10:06:35 +07:00
|
|
|
}
|
|
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
delegate: ColumnLayout {
|
|
|
|
|
id: content
|
|
|
|
|
|
2025-01-08 09:12:55 +03:00
|
|
|
width: menuContent.width
|
|
|
|
|
height: content.implicitHeight
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
RowLayout {
|
|
|
|
|
VerticalRadioButton {
|
|
|
|
|
id: containerRadioButton
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
text: countryName
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
ButtonGroup.group: containersRadioButtonGroup
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
imageSource: "qrc:/images/controls/download.svg"
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
checked: index === ApiCountryModel.currentIndex
|
|
|
|
|
checkable: !ConnectionController.isConnected
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
onClicked: {
|
2025-08-01 07:45:19 +04:00
|
|
|
if (ConnectionController.isConnectionInProgress) {
|
|
|
|
|
PageController.showNotificationMessage(qsTr("Unable change server location while trying to make an active connection"))
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-12-31 04:16:52 +01:00
|
|
|
if (ConnectionController.isConnected) {
|
|
|
|
|
PageController.showNotificationMessage(qsTr("Unable change server location while there is an active connection"))
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-12-09 09:32:49 +03:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
if (index !== ApiCountryModel.currentIndex) {
|
|
|
|
|
PageController.showBusyIndicator(true)
|
|
|
|
|
var prevIndex = ApiCountryModel.currentIndex
|
|
|
|
|
ApiCountryModel.currentIndex = index
|
2026-05-28 10:57:08 +08:00
|
|
|
if (!SubscriptionUiController.updateServiceFromGateway(ServersUiController.processedServerId, countryCode, countryName)) {
|
2024-12-31 04:16:52 +01:00
|
|
|
ApiCountryModel.currentIndex = prevIndex
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
2025-02-19 20:27:15 +07:00
|
|
|
PageController.showBusyIndicator(false)
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
2024-12-31 04:16:52 +01:00
|
|
|
}
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
Keys.onEnterPressed: {
|
|
|
|
|
if (checkable) {
|
|
|
|
|
checked = true
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
2024-12-31 04:16:52 +01:00
|
|
|
containerRadioButton.clicked()
|
|
|
|
|
}
|
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
|
if (checkable) {
|
|
|
|
|
checked = true
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
2024-12-31 04:16:52 +01:00
|
|
|
containerRadioButton.clicked()
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
2024-12-31 04:16:52 +01:00
|
|
|
}
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
Image {
|
|
|
|
|
Layout.rightMargin: 32
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
source: "qrc:/countriesFlags/images/flagKit/" + countryImageCode + ".svg"
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
2024-12-31 04:16:52 +01:00
|
|
|
}
|
2024-08-20 16:54:05 +07:00
|
|
|
|
2024-12-31 04:16:52 +01:00
|
|
|
DividerType {
|
|
|
|
|
Layout.fillWidth: true
|
2024-08-20 16:54:05 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|