Add property for checking if server config is premium
This commit is contained in:
parent
f44e030001
commit
f963cc071f
3 changed files with 17 additions and 7 deletions
|
|
@ -8,6 +8,8 @@
|
||||||
#include <AmneziaVPN-Swift.h>
|
#include <AmneziaVPN-Swift.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "core/api/apiUtils.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
namespace configKey
|
namespace configKey
|
||||||
|
|
@ -427,7 +429,7 @@ void ServersModel::updateDefaultServerContainersModel()
|
||||||
emit defaultServerContainersUpdated(containers);
|
emit defaultServerContainersUpdated(containers);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject ServersModel::getServerConfig(const int serverIndex)
|
QJsonObject ServersModel::getServerConfig(const int serverIndex) const
|
||||||
{
|
{
|
||||||
return m_servers.at(serverIndex).toObject();
|
return m_servers.at(serverIndex).toObject();
|
||||||
}
|
}
|
||||||
|
|
@ -814,3 +816,8 @@ const QString ServersModel::getDefaultServerImagePathCollapsed()
|
||||||
}
|
}
|
||||||
return QString("qrc:/countriesFlags/images/flagKit/%1.svg").arg(countryCode.toUpper());
|
return QString("qrc:/countriesFlags/images/flagKit/%1.svg").arg(countryCode.toUpper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServersModel::processedServerIsPremium() const
|
||||||
|
{
|
||||||
|
return apiUtils::isPremiumServer(getServerConfig(m_processedServerIndex));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ public:
|
||||||
Q_PROPERTY(bool isDefaultServerFromApi READ isDefaultServerFromApi NOTIFY defaultServerIndexChanged)
|
Q_PROPERTY(bool isDefaultServerFromApi READ isDefaultServerFromApi NOTIFY defaultServerIndexChanged)
|
||||||
|
|
||||||
Q_PROPERTY(int processedIndex READ getProcessedServerIndex WRITE setProcessedServerIndex NOTIFY processedServerIndexChanged)
|
Q_PROPERTY(int processedIndex READ getProcessedServerIndex WRITE setProcessedServerIndex NOTIFY processedServerIndexChanged)
|
||||||
|
Q_PROPERTY(bool processedServerIsPremium READ processedServerIsPremium NOTIFY processedServerChanged)
|
||||||
|
|
||||||
|
bool processedServerIsPremium() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setDefaultServerIndex(const int index);
|
void setDefaultServerIndex(const int index);
|
||||||
|
|
@ -92,7 +95,7 @@ public slots:
|
||||||
void removeServer();
|
void removeServer();
|
||||||
void removeServer(const int serverIndex);
|
void removeServer(const int serverIndex);
|
||||||
|
|
||||||
QJsonObject getServerConfig(const int serverIndex);
|
QJsonObject getServerConfig(const int serverIndex) const;
|
||||||
|
|
||||||
void reloadDefaultServerContainerConfig();
|
void reloadDefaultServerContainerConfig();
|
||||||
void updateContainerConfig(const int containerIndex, const QJsonObject config);
|
void updateContainerConfig(const int containerIndex, const QJsonObject config);
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ PageType {
|
||||||
|
|
||||||
FlickableType {
|
FlickableType {
|
||||||
id: fl
|
id: fl
|
||||||
Component.onCompleted: console.log("[Debug] isServerFromTelegramApi:", ServersModel.getProcessedServerData("isServerFromTelegramApi"), "service_type:", ServersModel.getProcessedServerData("apiConfig")["service_type"])
|
Component.onCompleted: console.log("[Debug] labelWithButton6.visible:", visible)
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
contentHeight: content.height
|
contentHeight: content.height
|
||||||
|
|
@ -256,14 +256,14 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {
|
||||||
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.getProcessedServerData("apiConfig")["service_type"] === "amnezia-premium"
|
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi")
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
id: labelWithButton6
|
id: labelWithButton6
|
||||||
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.getProcessedServerData("apiConfig")["service_type"] === "amnezia-premium"
|
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.processedServerIsPremium
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
onVisibleChanged: console.log("[Debug] labelWithButton6.visible:", visible, "service_type:", ServersModel.getProcessedServerData("apiConfig")["service_type"])
|
onVisibleChanged: console.log("[Debug] labelWithButton6.visible:", visible)
|
||||||
|
|
||||||
text: qsTr("Switch to the new Amnezia Premium subscription")
|
text: qsTr("Switch to the new Amnezia Premium subscription")
|
||||||
textColor: AmneziaStyle.color.vibrantRed
|
textColor: AmneziaStyle.color.vibrantRed
|
||||||
|
|
@ -275,7 +275,7 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {
|
||||||
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.getProcessedServerData("apiConfig")["service_type"] === "amnezia-premium"
|
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.processedServerIsPremium
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue