Skip to content

Commit

Permalink
feature: added ad label on page home
Browse files Browse the repository at this point in the history
  • Loading branch information
Nethius committed Dec 26, 2024
1 parent 367789b commit 0026f12
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 4 deletions.
5 changes: 5 additions & 0 deletions client/images/controls/external-link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions client/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
<file>ui/qml/Pages2/PageSettingsApiLanguageList.qml</file>
<file>images/controls/archive-restore.svg</file>
<file>images/controls/help-circle.svg</file>
<file>images/controls/external-link.svg</file>
<file>ui/qml/Components/AdLabel.qml</file>
</qresource>
<qresource prefix="/countriesFlags">
<file>images/flagKit/ZW.svg</file>
Expand Down
10 changes: 10 additions & 0 deletions client/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions client/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion client/ui/controllers/settingsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,15 @@ bool SettingsController::isOnTv()
#else
return false;
#endif
}
}

bool SettingsController::isHomeAdLabelVisible()
{
return m_settings->isHomeAdLabelVisible();
}

void SettingsController::disableHomeAdLabel()
{
m_settings->disableHomeAdLabel();
emit isHomeAdLabelVisibleChanged(false);
}
7 changes: 7 additions & 0 deletions client/ui/controllers/settingsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -89,6 +91,9 @@ public slots:

bool isOnTv();

bool isHomeAdLabelVisible();
void disableHomeAdLabel();

signals:
void primaryDnsChanged();
void secondaryDnsChanged();
Expand All @@ -112,6 +117,8 @@ public slots:
void gatewayEndpointChanged(const QString &endpoint);
void devGatewayEnvChanged(bool enabled);

void isHomeAdLabelVisibleChanged(bool visible);

private:
QSharedPointer<ServersModel> m_serversModel;
QSharedPointer<ContainersModel> m_containersModel;
Expand Down
72 changes: 72 additions & 0 deletions client/ui/qml/Components/AdLabel.qml
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}
1 change: 1 addition & 0 deletions client/ui/qml/Modules/Style/AmneziaStyle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
17 changes: 14 additions & 3 deletions client/ui/qml/Pages2/PageHome.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects

import SortFilterProxyModel 0.2

Expand Down Expand Up @@ -38,8 +39,8 @@ PageType {

ColumnLayout {
anchors.fill: parent
anchors.topMargin: 34
anchors.bottomMargin: 34
anchors.topMargin: 12
anchors.bottomMargin: 16

Item {
id: focusItem
Expand All @@ -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
Expand Down Expand Up @@ -87,7 +99,6 @@ PageType {
id: splitTunnelingButton

Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.bottomMargin: 34
leftPadding: 16
rightPadding: 16

Expand Down
22 changes: 22 additions & 0 deletions client/ui/qml/Pages2/PageSetupWizardConfigSource.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
}
}

0 comments on commit 0026f12

Please sign in to comment.