diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 25d57f5a4..b44294f1d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3889,4 +3889,4 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ayu_IDCopiedToast" = "ID copied to clipboard."; "ayu_DrawerGhostModeToggle" = "Ghost Mode"; "ayu_OpenFromTray" = "Open Ayugram"; -"ayu_QuitFromTray" = "Quit Ayugram"; \ No newline at end of file +"ayu_QuitFromTray" = "Quit Ayugram"; diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index a8ac6f69b..0c81ad23b 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -153,6 +153,14 @@ namespace AyuSettings { GIFConfirmation = val; } + bool AyuGramSettings::getGhostModeValue() { + return (!sendReadPackets + && !sendOnlinePackets + && !sendUploadProgress + && sendOfflinePacketAfterOnline); + } + + rpl::producer get_deletedMarkReactive() { return deletedMarkReactive.value(); } diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index e4dce13f2..62a7a9507 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -110,6 +110,8 @@ namespace AyuSettings { void set_stickerConfirmation(bool val); void set_GIFConfirmation(bool val); + + bool getGhostModeValue(); }; AyuGramSettings &getInstance(); diff --git a/Telegram/SourceFiles/tray.cpp b/Telegram/SourceFiles/tray.cpp index 567e0f12d..d2e3bd87b 100644 --- a/Telegram/SourceFiles/tray.cpp +++ b/Telegram/SourceFiles/tray.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include +#include namespace Core { @@ -88,6 +89,29 @@ void Tray::rebuildMenu() { [=] { toggleSoundNotifications(); }); } + auto turnGhostModeText = _textUpdates.events( + ) | rpl::map([=] { + auto settings = AyuSettings::AyuGramSettings(); + bool ghostModeEnabled = settings.getGhostModeValue(); + + return ghostModeEnabled + ? tr::ayu_DisableGhostMode(tr::now) + : tr::ayu_EnableGhostMode(tr::now); + }); + + _tray.addAction(rpl::single(QString("Toggle ghost mode")), [=] { + auto settings = &AyuSettings::getInstance(); + bool ghostMode = (bool) AyuSettings::get_ghostModeEnabled(); + + settings->set_sendReadPackets(!ghostMode); + settings->set_sendOnlinePackets(!ghostMode); + settings->set_sendUploadProgress(!ghostMode); + + settings->set_sendOfflinePacketAfterOnline(ghostMode); + + AyuSettings::save(); + }); + _tray.addAction(tr::ayu_QuitFromTray(), [] { Core::Quit(); }); updateMenuText(); diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index ed163c477..b2eec63f3 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -69,6 +69,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_info.h" // infoTopBarMenu #include "styles/style_layers.h" #include "styles/style_menu_icons.h" +#include "tray.h" #include #include