mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
add ui Configuration Files
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
namespace
|
||||
{
|
||||
Logger logger("AccountInfoModel");
|
||||
|
||||
constexpr QLatin1String kCountryConfigSourceType("country_config");
|
||||
}
|
||||
|
||||
ApiAccountInfoModel::ApiAccountInfoModel(QObject *parent) : QAbstractListModel(parent)
|
||||
@@ -121,6 +123,9 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
const int spare = m_accountInfoData.maxDeviceCount - m_accountInfoData.activeDeviceCount;
|
||||
return qMax(0, spare);
|
||||
}
|
||||
case ConfigurationFilesCountRole: {
|
||||
return m_accountInfoData.configurationFilesCount;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@@ -135,6 +140,15 @@ void ApiAccountInfoModel::updateModel(const QJsonObject &accountInfoObject, cons
|
||||
m_availableCountries = accountInfoObject.value(apiDefs::key::availableCountries).toArray();
|
||||
m_issuedConfigsInfo = accountInfoObject.value(apiDefs::key::issuedConfigs).toArray();
|
||||
|
||||
int configurationFilesCount = 0;
|
||||
for (int i = 0; i < m_issuedConfigsInfo.size(); ++i) {
|
||||
const QJsonObject issued = m_issuedConfigsInfo.at(i).toObject();
|
||||
if (issued.value(apiDefs::key::sourceType).toString() == kCountryConfigSourceType) {
|
||||
++configurationFilesCount;
|
||||
}
|
||||
}
|
||||
accountInfoData.configurationFilesCount = configurationFilesCount;
|
||||
|
||||
accountInfoData.activeDeviceCount = accountInfoObject.value(apiDefs::key::activeDeviceCount).toInt();
|
||||
accountInfoData.maxDeviceCount = accountInfoObject.value(apiDefs::key::maxDeviceCount).toInt();
|
||||
accountInfoData.subscriptionEndDate = accountInfoObject.value(apiDefs::key::subscriptionEndDate).toString();
|
||||
@@ -223,6 +237,7 @@ QHash<int, QByteArray> ApiAccountInfoModel::roleNames() const
|
||||
roles[ActiveDeviceCountRole] = "activeDeviceCount";
|
||||
roles[MaxDeviceCountRole] = "maxDeviceCount";
|
||||
roles[AvailableDeviceSlotsRole] = "availableDeviceSlots";
|
||||
roles[ConfigurationFilesCountRole] = "configurationFilesCount";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ public:
|
||||
IsInAppPurchaseRole,
|
||||
ActiveDeviceCountRole,
|
||||
MaxDeviceCountRole,
|
||||
AvailableDeviceSlotsRole
|
||||
AvailableDeviceSlotsRole,
|
||||
ConfigurationFilesCountRole
|
||||
};
|
||||
|
||||
explicit ApiAccountInfoModel(QObject *parent = nullptr);
|
||||
@@ -67,6 +68,7 @@ private:
|
||||
|
||||
bool isInAppPurchase = false;
|
||||
bool isRenewalAvailable = false;
|
||||
int configurationFilesCount = 0;
|
||||
};
|
||||
|
||||
AccountInfoData m_accountInfoData;
|
||||
|
||||
@@ -241,6 +241,26 @@ PageType {
|
||||
|
||||
DividerType {}
|
||||
}
|
||||
|
||||
footer: ColumnLayout {
|
||||
width: listView.width
|
||||
|
||||
LabelWithButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 8
|
||||
|
||||
text: qsTr("Configuration Files: %1").arg(ApiAccountInfoModel.data("configurationFilesCount"))
|
||||
descriptionText: qsTr("Generated configuration files also count towards the device limit")
|
||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
clickedFunction: function() {
|
||||
SubscriptionUiController.updateApiCountryModel()
|
||||
PageController.goToPage(PageEnum.PageSettingsApiNativeConfigs)
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {}
|
||||
}
|
||||
}
|
||||
|
||||
function deactivateExternalDevice(serverIndex, supportTag, countryCode) {
|
||||
|
||||
Reference in New Issue
Block a user