From 0026f12d5e4bedad2f034a535a0487e9ec86df40 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 26 Dec 2024 12:51:52 +0700 Subject: [PATCH] feature: added ad label on page home --- client/images/controls/external-link.svg | 5 ++ client/resources.qrc | 2 + client/settings.cpp | 10 +++ client/settings.h | 3 + client/ui/controllers/settingsController.cpp | 13 +++- client/ui/controllers/settingsController.h | 7 ++ client/ui/qml/Components/AdLabel.qml | 72 +++++++++++++++++++ client/ui/qml/Modules/Style/AmneziaStyle.qml | 1 + client/ui/qml/Pages2/PageHome.qml | 17 ++++- .../Pages2/PageSetupWizardConfigSource.qml | 22 ++++++ 10 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 client/images/controls/external-link.svg create mode 100644 client/ui/qml/Components/AdLabel.qml diff --git a/client/images/controls/external-link.svg b/client/images/controls/external-link.svg new file mode 100644 index 000000000..6a51c9025 --- /dev/null +++ b/client/images/controls/external-link.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/client/resources.qrc b/client/resources.qrc index a10a784d8..85aa61cd6 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -220,6 +220,8 @@ ui/qml/Pages2/PageSettingsApiLanguageList.qml images/controls/archive-restore.svg images/controls/help-circle.svg + images/controls/external-link.svg + ui/qml/Components/AdLabel.qml images/flagKit/ZW.svg diff --git a/client/settings.cpp b/client/settings.cpp index 7a572a136..94b11d00e 100644 --- a/client/settings.cpp +++ b/client/settings.cpp @@ -538,3 +538,13 @@ void Settings::toggleDevGatewayEnv(bool enabled) { m_isDevGatewayEnv = enabled; } + +bool Settings::isHomeAdLabelVisible() +{ + return value("Conf/homeAdLabelVisible", true).toBool(); +} + +void Settings::disableHomeAdLabel() +{ + setValue("Conf/homeAdLabelVisible", false); +} diff --git a/client/settings.h b/client/settings.h index f41f4d29a..b383d3da7 100644 --- a/client/settings.h +++ b/client/settings.h @@ -222,6 +222,9 @@ class Settings : public QObject bool isDevGatewayEnv(); void toggleDevGatewayEnv(bool enabled); + bool isHomeAdLabelVisible(); + void disableHomeAdLabel(); + signals: void saveLogsChanged(bool enabled); void screenshotsEnabledChanged(bool enabled); diff --git a/client/ui/controllers/settingsController.cpp b/client/ui/controllers/settingsController.cpp index c3945512f..477b78266 100644 --- a/client/ui/controllers/settingsController.cpp +++ b/client/ui/controllers/settingsController.cpp @@ -324,4 +324,15 @@ bool SettingsController::isOnTv() #else return false; #endif -} \ No newline at end of file +} + +bool SettingsController::isHomeAdLabelVisible() +{ + return m_settings->isHomeAdLabelVisible(); +} + +void SettingsController::disableHomeAdLabel() +{ + m_settings->disableHomeAdLabel(); + emit isHomeAdLabelVisibleChanged(false); +} diff --git a/client/ui/controllers/settingsController.h b/client/ui/controllers/settingsController.h index efc18a7d0..7781f6c74 100644 --- a/client/ui/controllers/settingsController.h +++ b/client/ui/controllers/settingsController.h @@ -29,6 +29,8 @@ class SettingsController : public QObject Q_PROPERTY(QString gatewayEndpoint READ getGatewayEndpoint WRITE setGatewayEndpoint NOTIFY gatewayEndpointChanged) Q_PROPERTY(bool isDevGatewayEnv READ isDevGatewayEnv WRITE toggleDevGatewayEnv NOTIFY devGatewayEnvChanged) + Q_PROPERTY(bool isHomeAdLabelVisible READ isHomeAdLabelVisible NOTIFY isHomeAdLabelVisibleChanged) + public slots: void toggleAmneziaDns(bool enable); bool isAmneziaDnsEnabled(); @@ -89,6 +91,9 @@ public slots: bool isOnTv(); + bool isHomeAdLabelVisible(); + void disableHomeAdLabel(); + signals: void primaryDnsChanged(); void secondaryDnsChanged(); @@ -112,6 +117,8 @@ public slots: void gatewayEndpointChanged(const QString &endpoint); void devGatewayEnvChanged(bool enabled); + void isHomeAdLabelVisibleChanged(bool visible); + private: QSharedPointer m_serversModel; QSharedPointer m_containersModel; diff --git a/client/ui/qml/Components/AdLabel.qml b/client/ui/qml/Components/AdLabel.qml new file mode 100644 index 000000000..6a3a980bc --- /dev/null +++ b/client/ui/qml/Components/AdLabel.qml @@ -0,0 +1,72 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Shapes +import Qt5Compat.GraphicalEffects + +import Style 1.0 + +import "../Config" +import "../Controls2" +import "../Controls2/TextTypes" + +Rectangle { + id: root + + property real contentHeight: ad.implicitHeight + ad.anchors.topMargin + ad.anchors.bottomMargin + + border.width: 1 + border.color: AmneziaStyle.color.goldenApricot + color: AmneziaStyle.color.transparent + radius: 13 + + visible: GC.isDesktop() && ServersModel.isDefaultServerFromApi + && ServersModel.isDefaultServerDefaultContainerHasSplitTunneling && SettingsController.isHomeAdLabelVisible + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + + onClicked: function() { + Qt.openUrlExternally(LanguageModel.getCurrentSiteUrl()) + } + } + + RowLayout { + id: ad + anchors.fill: parent + anchors.margins: 16 + + Image { + source: "qrc:/images/controls/amnezia.svg" + sourceSize: Qt.size(36, 36) + + layer { + effect: ColorOverlay { + color: AmneziaStyle.color.paleGray + } + } + } + + CaptionTextType { + Layout.fillWidth: true + Layout.rightMargin: 10 + Layout.leftMargin: 10 + + text: qsTr("Amnezia Premium - for access to any website") + color: AmneziaStyle.color.pearlGray + + lineHeight: 18 + font.pixelSize: 15 + } + + ImageButtonType { + image: "qrc:/images/controls/close.svg" + imageColor: AmneziaStyle.color.paleGray + + onClicked: function() { + SettingsController.disableHomeAdLabel() + } + } + } +} diff --git a/client/ui/qml/Modules/Style/AmneziaStyle.qml b/client/ui/qml/Modules/Style/AmneziaStyle.qml index 1abfbe3ae..f54fefcee 100644 --- a/client/ui/qml/Modules/Style/AmneziaStyle.qml +++ b/client/ui/qml/Modules/Style/AmneziaStyle.qml @@ -26,5 +26,6 @@ QtObject { readonly property color softGoldenApricot: Qt.rgba(251/255, 178/255, 106/255, 0.3) readonly property color mistyGray: Qt.rgba(215/255, 216/255, 219/255, 0.8) readonly property color cloudyGray: Qt.rgba(215/255, 216/255, 219/255, 0.65) + readonly property color pearlGray: '#EAEAEC' } } diff --git a/client/ui/qml/Pages2/PageHome.qml b/client/ui/qml/Pages2/PageHome.qml index 8422a10f2..12d212289 100644 --- a/client/ui/qml/Pages2/PageHome.qml +++ b/client/ui/qml/Pages2/PageHome.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import Qt5Compat.GraphicalEffects import SortFilterProxyModel 0.2 @@ -38,8 +39,8 @@ PageType { ColumnLayout { anchors.fill: parent - anchors.topMargin: 34 - anchors.bottomMargin: 34 + anchors.topMargin: 12 + anchors.bottomMargin: 16 Item { id: focusItem @@ -48,6 +49,17 @@ PageType { connectButton } + + AdLabel { + id: adLabel + + Layout.fillWidth: true + Layout.preferredHeight: adLabel.contentHeight + Layout.leftMargin: 16 + Layout.rightMargin: 16 + Layout.bottomMargin: 22 + } + BasicButtonType { id: loggingButton property bool isLoggingEnabled: SettingsController.isLoggingEnabled @@ -87,7 +99,6 @@ PageType { id: splitTunnelingButton Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - Layout.bottomMargin: 34 leftPadding: 16 rightPadding: 16 diff --git a/client/ui/qml/Pages2/PageSetupWizardConfigSource.qml b/client/ui/qml/Pages2/PageSetupWizardConfigSource.qml index f973c89cf..c3060124d 100644 --- a/client/ui/qml/Pages2/PageSetupWizardConfigSource.qml +++ b/client/ui/qml/Pages2/PageSetupWizardConfigSource.qml @@ -324,6 +324,28 @@ PageType { Qt.openUrlExternally(LanguageModel.getCurrentSiteUrl()) } } + + BasicButtonType { + id: siteLink2 + Layout.topMargin: 24 + Layout.bottomMargin: 16 + Layout.alignment: Qt.AlignHCenter + implicitHeight: 32 + + defaultColor: AmneziaStyle.color.transparent + hoveredColor: AmneziaStyle.color.translucentWhite + pressedColor: AmneziaStyle.color.sheerWhite + disabledColor: AmneziaStyle.color.mutedGray + textColor: AmneziaStyle.color.goldenApricot + + text: qsTr("Site Amnezia") + + rightImageSource: "qrc:/images/controls/external-link.svg" + + clickedFunc: function() { + Qt.openUrlExternally(LanguageModel.getCurrentSiteUrl()) + } + } } } }