feat: trying to make ghost mode toggle in tray

This commit is contained in:
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 2023-06-22 20:35:15 +03:00
parent a1aac455db
commit e218f6da78
5 changed files with 36 additions and 1 deletions

View file

@ -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";
"ayu_QuitFromTray" = "Quit Ayugram";

View file

@ -153,6 +153,14 @@ namespace AyuSettings {
GIFConfirmation = val;
}
bool AyuGramSettings::getGhostModeValue() {
return (!sendReadPackets
&& !sendOnlinePackets
&& !sendUploadProgress
&& sendOfflinePacketAfterOnline);
}
rpl::producer<QString> get_deletedMarkReactive() {
return deletedMarkReactive.value();
}

View file

@ -110,6 +110,8 @@ namespace AyuSettings {
void set_stickerConfirmation(bool val);
void set_GIFConfirmation(bool val);
bool getGhostModeValue();
};
AyuGramSettings &getInstance();

View file

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/platform_specific.h"
#include <QtWidgets/QApplication>
#include <ayu/ayu_settings.h>
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();

View file

@ -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 <QtGui/QWindow>
#include <QtGui/QScreen>