mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
feat: news notifications switch (#2126)
* feat: news notifications switch * update: text changes * fix: notifications enabled by default
This commit is contained in:
@@ -94,6 +94,15 @@ public:
|
|||||||
setValue("Conf/startMinimized", enabled);
|
setValue("Conf/startMinimized", enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isNewsNotifications() const
|
||||||
|
{
|
||||||
|
return value("Conf/newsNotifications", true).toBool();
|
||||||
|
}
|
||||||
|
void setNewsNotifications(bool enabled)
|
||||||
|
{
|
||||||
|
setValue("Conf/newsNotifications", enabled);
|
||||||
|
}
|
||||||
|
|
||||||
bool isSaveLogs() const
|
bool isSaveLogs() const
|
||||||
{
|
{
|
||||||
return value("Conf/saveLogs", false).toBool();
|
return value("Conf/saveLogs", false).toBool();
|
||||||
|
|||||||
@@ -308,6 +308,15 @@ void SettingsController::toggleStartMinimized(bool enable)
|
|||||||
emit startMinimizedChanged();
|
emit startMinimizedChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsController::isNewsNotificationsEnabled()
|
||||||
|
{
|
||||||
|
return m_settings->isNewsNotifications();
|
||||||
|
}
|
||||||
|
void SettingsController::toggleNewsNotificationsEnabled(bool enable)
|
||||||
|
{
|
||||||
|
m_settings->setNewsNotifications(enable);
|
||||||
|
}
|
||||||
|
|
||||||
bool SettingsController::isScreenshotsEnabled()
|
bool SettingsController::isScreenshotsEnabled()
|
||||||
{
|
{
|
||||||
return m_settings->isScreenshotsEnabled();
|
return m_settings->isScreenshotsEnabled();
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ public slots:
|
|||||||
bool isStartMinimizedEnabled();
|
bool isStartMinimizedEnabled();
|
||||||
void toggleStartMinimized(bool enable);
|
void toggleStartMinimized(bool enable);
|
||||||
|
|
||||||
|
bool isNewsNotificationsEnabled();
|
||||||
|
void toggleNewsNotificationsEnabled(bool enable);
|
||||||
|
|
||||||
bool isScreenshotsEnabled();
|
bool isScreenshotsEnabled();
|
||||||
void toggleScreenshotsEnabled(bool enable);
|
void toggleScreenshotsEnabled(bool enable);
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ PageType {
|
|||||||
id: news
|
id: news
|
||||||
|
|
||||||
property string title: qsTr("News & Notifications")
|
property string title: qsTr("News & Notifications")
|
||||||
readonly property string leftImagePath: NewsModel.hasUnread ? "qrc:/images/controls/news-unread.svg" : "qrc:/images/controls/news.svg"
|
readonly property string leftImagePath: NewsModel.hasUnread && SettingsController.isNewsNotificationsEnabled() ? "qrc:/images/controls/news-unread.svg" : "qrc:/images/controls/news.svg"
|
||||||
property bool isVisible: ServersModel.hasServersFromGatewayApi
|
property bool isVisible: ServersModel.hasServersFromGatewayApi
|
||||||
readonly property var clickedHandler: function() {
|
readonly property var clickedHandler: function() {
|
||||||
if (!ServersModel.hasServersFromGatewayApi) {
|
if (!ServersModel.hasServersFromGatewayApi) {
|
||||||
|
|||||||
@@ -168,6 +168,29 @@ PageType {
|
|||||||
DividerType {
|
DividerType {
|
||||||
visible: !GC.isMobile()
|
visible: !GC.isMobile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SwitcherType {
|
||||||
|
id: switcherNewsNotificationEnabled
|
||||||
|
|
||||||
|
visible: ServersModel.hasServersFromGatewayApi
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: 16
|
||||||
|
|
||||||
|
text: qsTr("News Notification")
|
||||||
|
descriptionText: qsTr("Show notification icon when has unread news")
|
||||||
|
|
||||||
|
checked: SettingsController.isNewsNotificationsEnabled()
|
||||||
|
onToggled: function() {
|
||||||
|
if (checked !== SettingsController.isNewsNotificationsEnabled()) {
|
||||||
|
SettingsController.toggleNewsNotificationsEnabled(checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DividerType {
|
||||||
|
visible: !GC.isMobile()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: ColumnLayout {
|
footer: ColumnLayout {
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ PageType {
|
|||||||
objectName: "settingsTabButton"
|
objectName: "settingsTabButton"
|
||||||
|
|
||||||
isSelected: tabBar.currentIndex === 2
|
isSelected: tabBar.currentIndex === 2
|
||||||
image: (ServersModel.hasServersFromGatewayApi && NewsModel.hasUnread) ? "qrc:/images/controls/settings-news.svg" : "qrc:/images/controls/settings.svg"
|
image: (ServersModel.hasServersFromGatewayApi && NewsModel.hasUnread && SettingsController.isNewsNotificationsEnabled()) ? "qrc:/images/controls/settings-news.svg" : "qrc:/images/controls/settings.svg"
|
||||||
Binding {
|
Binding {
|
||||||
target: settingsTabButton
|
target: settingsTabButton
|
||||||
property: "defaultColor"
|
property: "defaultColor"
|
||||||
|
|||||||
Reference in New Issue
Block a user