diff --git a/Telegram/Resources/icons/ayu/ghost_tray.png b/Telegram/Resources/icons/ayu/ghost_tray.png new file mode 100644 index 000000000..e3973fd5c Binary files /dev/null and b/Telegram/Resources/icons/ayu/ghost_tray.png differ diff --git a/Telegram/Resources/icons/ayu/ghost_tray@2x.png b/Telegram/Resources/icons/ayu/ghost_tray@2x.png new file mode 100644 index 000000000..f00f8d2d4 Binary files /dev/null and b/Telegram/Resources/icons/ayu/ghost_tray@2x.png differ diff --git a/Telegram/Resources/icons/ayu/ghost_tray@3x.png b/Telegram/Resources/icons/ayu/ghost_tray@3x.png new file mode 100644 index 000000000..c92a525c2 Binary files /dev/null and b/Telegram/Resources/icons/ayu/ghost_tray@3x.png differ diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index 243083867..b6ec7f765 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -164,6 +164,15 @@ void load() { } catch (...) { LOG(("AyuGramSettings: failed to read settings file (not json-like)")); } + + if (cGhost()) { + settings->sendReadMessages = false; + settings->sendReadStories = false; + settings->sendOnlinePackets = false; + settings->sendUploadProgress = false; + settings->sendOfflinePacketAfterOnline = true; + } + postinitialize(); } diff --git a/Telegram/SourceFiles/ayu/ui/ayu_icons.style b/Telegram/SourceFiles/ayu/ui/ayu_icons.style index 0416ce22f..fa8f664c3 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_icons.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_icons.style @@ -23,3 +23,5 @@ outChannelBadgeIcon: icon {{ "ayu/channel", msgOutDateFg }}; outChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgOutDateFgSelected }}; infoExteraBadge: icon {{ "ayu/exterabadge", profileVerifiedCheckBg }}; + +winEnterWithGuestIcon: icon {{ "ayu/ghost_tray", windowFg }}; diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index 67f44a1e2..50af38902 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -516,6 +516,7 @@ void Launcher::processArguments() { { "-tosettings" , KeyFormat::NoValues }, { "-startintray" , KeyFormat::NoValues }, { "-quit" , KeyFormat::NoValues }, + { "-ghost" , KeyFormat::NoValues }, { "-sendpath" , KeyFormat::AllLeftValues }, { "-workdir" , KeyFormat::OneValue }, { "--" , KeyFormat::OneValue }, @@ -559,6 +560,7 @@ void Launcher::processArguments() { gStartToSettings = parseResult.contains("-tosettings"); gStartInTray = parseResult.contains("-startintray"); gQuit = parseResult.contains("-quit"); + gGhost = parseResult.contains("-ghost"); gSendPaths = parseResult.value("-sendpath", {}); _customWorkingDir = parseResult.value("-workdir", {}).join(QString()); if (!_customWorkingDir.isEmpty()) { diff --git a/Telegram/SourceFiles/platform/win/integration_win.cpp b/Telegram/SourceFiles/platform/win/integration_win.cpp index 0a44470da..71856388e 100644 --- a/Telegram/SourceFiles/platform/win/integration_win.cpp +++ b/Telegram/SourceFiles/platform/win/integration_win.cpp @@ -63,6 +63,38 @@ void WindowsIntegration::createCustomJumpList() { } } +void AddJumpListItem(IObjectCollection* collection, const QString& title, const QString& args, const QString& icon) { + auto shellLink = base::WinRT::TryCreateInstance(CLSID_ShellLink); + if (!shellLink) { + return; + } + + const auto exe = QDir::toNativeSeparators(cExeDir() + cExeName()); + const auto dir = QDir::toNativeSeparators(QDir(cWorkingDir()).absolutePath()); + shellLink->SetArguments(args.toStdWString().c_str()); + shellLink->SetPath(exe.toStdWString().c_str()); + shellLink->SetWorkingDirectory(dir.toStdWString().c_str()); + shellLink->SetIconLocation(icon.toStdWString().c_str(), 0); + + if (const auto propertyStore = shellLink.try_as()) { + auto appIdPropVar = PROPVARIANT(); + HRESULT hr = InitPropVariantFromString(AppUserModelId::Id().c_str(), &appIdPropVar); + if (SUCCEEDED(hr)) { + hr = propertyStore->SetValue(AppUserModelId::Key(), appIdPropVar); + PropVariantClear(&appIdPropVar); + } + auto titlePropVar = PROPVARIANT(); + hr = InitPropVariantFromString(title.toStdWString().c_str(), &titlePropVar); + if (SUCCEEDED(hr)) { + hr = propertyStore->SetValue(PKEY_Title, titlePropVar); + PropVariantClear(&titlePropVar); + } + propertyStore->Commit(); + } + + collection->AddObject(shellLink.get()); +} + void WindowsIntegration::refreshCustomJumpList() { auto added = false; auto maxSlots = UINT(); @@ -79,49 +111,17 @@ void WindowsIntegration::refreshCustomJumpList() { } }); - auto shellLink = base::WinRT::TryCreateInstance( - CLSID_ShellLink); - if (!shellLink) { - return; - } - - // Set the path to your application and the command-line argument for quitting - const auto exe = QDir::toNativeSeparators(cExeDir() + cExeName()); - const auto dir = QDir::toNativeSeparators(QDir(cWorkingDir()).absolutePath()); - const auto icon = Tray::QuitJumpListIconPath(); - shellLink->SetArguments(L"-quit"); - shellLink->SetPath(exe.toStdWString().c_str()); - shellLink->SetWorkingDirectory(dir.toStdWString().c_str()); - shellLink->SetIconLocation(icon.toStdWString().c_str(), 0); - - if (const auto propertyStore = shellLink.try_as()) { - auto appIdPropVar = PROPVARIANT(); - hr = InitPropVariantFromString( - AppUserModelId::Id().c_str(), - &appIdPropVar); - if (SUCCEEDED(hr)) { - hr = propertyStore->SetValue( - AppUserModelId::Key(), - appIdPropVar); - PropVariantClear(&appIdPropVar); - } - auto titlePropVar = PROPVARIANT(); - hr = InitPropVariantFromString( - tr::lng_quit_from_tray(tr::now).toStdWString().c_str(), - &titlePropVar); - if (SUCCEEDED(hr)) { - hr = propertyStore->SetValue(PKEY_Title, titlePropVar); - PropVariantClear(&titlePropVar); - } - propertyStore->Commit(); - } - auto collection = base::WinRT::TryCreateInstance( CLSID_EnumerableObjectCollection); if (!collection) { return; } - collection->AddObject(shellLink.get()); + + // add "Enter with Ghost" item + AddJumpListItem(collection.get(), tr::ayu_GhostModeShortcut(tr::now), "-ghost", Tray::GhostJumpListIconPath()); + + // add "Quit" item + AddJumpListItem(collection.get(), tr::lng_quit_from_tray(tr::now), "-quit", Tray::QuitJumpListIconPath()); _jumpList->AddUserTasks(collection.get()); added = true; diff --git a/Telegram/SourceFiles/platform/win/tray_win.cpp b/Telegram/SourceFiles/platform/win/tray_win.cpp index a0b171f71..256f5e623 100644 --- a/Telegram/SourceFiles/platform/win/tray_win.cpp +++ b/Telegram/SourceFiles/platform/win/tray_win.cpp @@ -30,7 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // AyuGram includes #include "ayu/ui/ayu_logo.h" -#include "ui/painter.h" +#include "styles/style_ayu_icons.h" namespace Platform { @@ -453,6 +453,26 @@ QString Tray::QuitJumpListIconPath() { return path; } +QString Tray::GhostJumpListIconPath() { + const auto dark = IsDarkTaskbar(); + const auto key = !dark ? 0 : *dark ? 1 : 2; + const auto path = cWorkingDir() + u"tdata/temp/ghost_%1.ico"_q.arg(key); + if (QFile::exists(path)) { + return path; + } + const auto color = !dark + ? st::trayCounterBg->c + : *dark + ? QColor(255, 255, 255) + : QColor(0, 0, 0, 228); + WriteIco(path, { + st::winEnterWithGuestIcon.instance(color, 100, true), + st::winEnterWithGuestIcon.instance(color, 200, true), + st::winEnterWithGuestIcon.instance(color, 300, true), + }); + return path; +} + bool HasMonochromeSetting() { return IsDarkTaskbar().has_value(); } diff --git a/Telegram/SourceFiles/platform/win/tray_win.h b/Telegram/SourceFiles/platform/win/tray_win.h index cb79c3beb..0297378f5 100644 --- a/Telegram/SourceFiles/platform/win/tray_win.h +++ b/Telegram/SourceFiles/platform/win/tray_win.h @@ -60,6 +60,7 @@ public: bool monochrome, bool supportMode); [[nodiscard]] static QString QuitJumpListIconPath(); + [[nodiscard]] static QString GhostJumpListIconPath(); private: base::unique_qptr _icon; diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index 4e2f6e878..366f94946 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -34,6 +34,7 @@ LaunchMode gLaunchMode = LaunchModeNormal; bool gSeenTrayTooltip = false; bool gRestartingUpdate = false, gRestarting = false, gRestartingToSettings = false, gWriteProtected = false; bool gQuit = false; +bool gGhost = false; int32 gLastUpdateCheck = 0; bool gNoStartUpdate = false; bool gStartToSettings = false; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index c0d6f1cbb..7902b7754 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -82,6 +82,7 @@ DeclareSetting(bool, StartToSettings); DeclareSetting(bool, DebugMode); DeclareReadSetting(bool, ManyInstance); DeclareSetting(bool, Quit); +DeclareSetting(bool, Ghost); DeclareSetting(QByteArray, LocalSalt); DeclareSetting(int, ScreenScale);