mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Make native notifications setting tri-state
This commit is contained in:
parent
ec8ddb047d
commit
9b59e74d66
7 changed files with 33 additions and 8 deletions
|
@ -60,7 +60,7 @@ QByteArray Settings::serialize() const {
|
||||||
<< qint32(_desktopNotify ? 1 : 0)
|
<< qint32(_desktopNotify ? 1 : 0)
|
||||||
<< qint32(_flashBounceNotify ? 1 : 0)
|
<< qint32(_flashBounceNotify ? 1 : 0)
|
||||||
<< static_cast<qint32>(_notifyView)
|
<< static_cast<qint32>(_notifyView)
|
||||||
<< qint32(_nativeNotifications ? 1 : 0)
|
<< qint32(_nativeNotifications ? (*_nativeNotifications ? 1 : 2) : 0)
|
||||||
<< qint32(_notificationsCount)
|
<< qint32(_notificationsCount)
|
||||||
<< static_cast<qint32>(_notificationsCorner)
|
<< static_cast<qint32>(_notificationsCorner)
|
||||||
<< qint32(_autoLock)
|
<< qint32(_autoLock)
|
||||||
|
@ -141,7 +141,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 desktopNotify = _desktopNotify ? 1 : 0;
|
qint32 desktopNotify = _desktopNotify ? 1 : 0;
|
||||||
qint32 flashBounceNotify = _flashBounceNotify ? 1 : 0;
|
qint32 flashBounceNotify = _flashBounceNotify ? 1 : 0;
|
||||||
qint32 notifyView = static_cast<qint32>(_notifyView);
|
qint32 notifyView = static_cast<qint32>(_notifyView);
|
||||||
qint32 nativeNotifications = _nativeNotifications ? 1 : 0;
|
qint32 nativeNotifications = _nativeNotifications ? (*_nativeNotifications ? 1 : 2) : 0;
|
||||||
qint32 notificationsCount = _notificationsCount;
|
qint32 notificationsCount = _notificationsCount;
|
||||||
qint32 notificationsCorner = static_cast<qint32>(_notificationsCorner);
|
qint32 notificationsCorner = static_cast<qint32>(_notificationsCorner);
|
||||||
qint32 autoLock = _autoLock;
|
qint32 autoLock = _autoLock;
|
||||||
|
@ -313,7 +313,12 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
case dbinvShowName:
|
case dbinvShowName:
|
||||||
case dbinvShowPreview: _notifyView = uncheckedNotifyView; break;
|
case dbinvShowPreview: _notifyView = uncheckedNotifyView; break;
|
||||||
}
|
}
|
||||||
_nativeNotifications = (nativeNotifications == 1);
|
switch (nativeNotifications) {
|
||||||
|
case 0: _nativeNotifications = std::nullopt; break;
|
||||||
|
case 1: _nativeNotifications = true; break;
|
||||||
|
case 2: _nativeNotifications = false; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
_notificationsCount = (notificationsCount > 0) ? notificationsCount : 3;
|
_notificationsCount = (notificationsCount > 0) ? notificationsCount : 3;
|
||||||
const auto uncheckedNotificationsCorner = static_cast<ScreenCorner>(notificationsCorner);
|
const auto uncheckedNotificationsCorner = static_cast<ScreenCorner>(notificationsCorner);
|
||||||
switch (uncheckedNotificationsCorner) {
|
switch (uncheckedNotificationsCorner) {
|
||||||
|
@ -479,7 +484,7 @@ void Settings::resetOnLastLogout() {
|
||||||
_desktopNotify = true;
|
_desktopNotify = true;
|
||||||
_flashBounceNotify = true;
|
_flashBounceNotify = true;
|
||||||
_notifyView = dbinvShowPreview;
|
_notifyView = dbinvShowPreview;
|
||||||
//_nativeNotifications = false;
|
//_nativeNotifications = std::nullopt;
|
||||||
//_notificationsCount = 3;
|
//_notificationsCount = 3;
|
||||||
//_notificationsCorner = ScreenCorner::BottomRight;
|
//_notificationsCorner = ScreenCorner::BottomRight;
|
||||||
_includeMutedCounter = true;
|
_includeMutedCounter = true;
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/themes/window_themes_embedded.h"
|
#include "window/themes/window_themes_embedded.h"
|
||||||
#include "window/window_controls_layout.h"
|
#include "window/window_controls_layout.h"
|
||||||
#include "ui/chat/attach/attach_send_files_way.h"
|
#include "ui/chat/attach/attach_send_files_way.h"
|
||||||
|
#include "platform/platform_notifications_manager.h"
|
||||||
|
|
||||||
enum class RectPart;
|
enum class RectPart;
|
||||||
|
|
||||||
|
@ -135,10 +136,12 @@ public:
|
||||||
_notifyView = value;
|
_notifyView = value;
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool nativeNotifications() const {
|
[[nodiscard]] bool nativeNotifications() const {
|
||||||
return _nativeNotifications;
|
return _nativeNotifications.value_or(Platform::Notifications::ByDefault());
|
||||||
}
|
}
|
||||||
void setNativeNotifications(bool value) {
|
void setNativeNotifications(bool value) {
|
||||||
_nativeNotifications = value;
|
_nativeNotifications = (value == Platform::Notifications::ByDefault())
|
||||||
|
? std::nullopt
|
||||||
|
: std::make_optional(value);
|
||||||
}
|
}
|
||||||
[[nodiscard]] int notificationsCount() const {
|
[[nodiscard]] int notificationsCount() const {
|
||||||
return _notificationsCount;
|
return _notificationsCount;
|
||||||
|
@ -529,7 +532,7 @@ private:
|
||||||
bool _desktopNotify = true;
|
bool _desktopNotify = true;
|
||||||
bool _flashBounceNotify = true;
|
bool _flashBounceNotify = true;
|
||||||
DBINotifyView _notifyView = dbinvShowPreview;
|
DBINotifyView _notifyView = dbinvShowPreview;
|
||||||
bool _nativeNotifications = false;
|
std::optional<bool> _nativeNotifications;
|
||||||
int _notificationsCount = 3;
|
int _notificationsCount = 3;
|
||||||
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
||||||
bool _includeMutedCounter = true;
|
bool _includeMutedCounter = true;
|
||||||
|
|
|
@ -698,7 +698,11 @@ bool Supported() {
|
||||||
bool Enforced() {
|
bool Enforced() {
|
||||||
// Wayland doesn't support positioning
|
// Wayland doesn't support positioning
|
||||||
// and custom notifications don't work here
|
// and custom notifications don't work here
|
||||||
return IsQualifiedDaemon() || IsWayland();
|
return IsWayland();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ByDefault() {
|
||||||
|
return IsQualifiedDaemon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create(Window::Notifications::System *system) {
|
void Create(Window::Notifications::System *system) {
|
||||||
|
|
|
@ -35,6 +35,10 @@ bool Enforced() {
|
||||||
return IsWayland();
|
return IsWayland();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ByDefault() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Create(Window::Notifications::System *system) {
|
void Create(Window::Notifications::System *system) {
|
||||||
if (Enforced()) {
|
if (Enforced()) {
|
||||||
using DummyManager = Window::Notifications::DummyManager;
|
using DummyManager = Window::Notifications::DummyManager;
|
||||||
|
|
|
@ -167,6 +167,10 @@ bool Enforced() {
|
||||||
return Supported();
|
return Supported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ByDefault() {
|
||||||
|
return Supported();
|
||||||
|
}
|
||||||
|
|
||||||
void Create(Window::Notifications::System *system) {
|
void Create(Window::Notifications::System *system) {
|
||||||
if (Supported()) {
|
if (Supported()) {
|
||||||
system->setManager(std::make_unique<Manager>(system));
|
system->setManager(std::make_unique<Manager>(system));
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Notifications {
|
||||||
|
|
||||||
[[nodiscard]] bool Supported();
|
[[nodiscard]] bool Supported();
|
||||||
[[nodiscard]] bool Enforced();
|
[[nodiscard]] bool Enforced();
|
||||||
|
[[nodiscard]] bool ByDefault();
|
||||||
void Create(Window::Notifications::System *system);
|
void Create(Window::Notifications::System *system);
|
||||||
|
|
||||||
} // namespace Notifications
|
} // namespace Notifications
|
||||||
|
|
|
@ -273,6 +273,10 @@ bool Enforced() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ByDefault() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Create(Window::Notifications::System *system) {
|
void Create(Window::Notifications::System *system) {
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
if (Core::App().settings().nativeNotifications() && Supported()) {
|
if (Core::App().settings().nativeNotifications() && Supported()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue