diff --git a/Telegram/Resources/art/icon256blue.ico b/Telegram/Resources/art/icon256blue.ico new file mode 100644 index 000000000..4b0b5a396 Binary files /dev/null and b/Telegram/Resources/art/icon256blue.ico differ diff --git a/Telegram/Resources/art/icon256green.ico b/Telegram/Resources/art/icon256green.ico new file mode 100644 index 000000000..de7bdc7cf Binary files /dev/null and b/Telegram/Resources/art/icon256green.ico differ diff --git a/Telegram/Resources/art/icon256old.ico b/Telegram/Resources/art/icon256old.ico new file mode 100644 index 000000000..4749c1f79 Binary files /dev/null and b/Telegram/Resources/art/icon256old.ico differ diff --git a/Telegram/Resources/art/icon256orange.ico b/Telegram/Resources/art/icon256orange.ico new file mode 100644 index 000000000..639f37e4a Binary files /dev/null and b/Telegram/Resources/art/icon256orange.ico differ diff --git a/Telegram/Resources/art/icon256red.ico b/Telegram/Resources/art/icon256red.ico new file mode 100644 index 000000000..a5e333fce Binary files /dev/null and b/Telegram/Resources/art/icon256red.ico differ diff --git a/Telegram/Resources/art/icon512_blue@2x.png b/Telegram/Resources/art/icon512_blue@2x.png new file mode 100644 index 000000000..65a165c8e Binary files /dev/null and b/Telegram/Resources/art/icon512_blue@2x.png differ diff --git a/Telegram/Resources/art/icon512_green@2x.png b/Telegram/Resources/art/icon512_green@2x.png new file mode 100644 index 000000000..569e49ae7 Binary files /dev/null and b/Telegram/Resources/art/icon512_green@2x.png differ diff --git a/Telegram/Resources/art/icon512_orange@2x.png b/Telegram/Resources/art/icon512_orange@2x.png new file mode 100644 index 000000000..791d1cbbb Binary files /dev/null and b/Telegram/Resources/art/icon512_orange@2x.png differ diff --git a/Telegram/Resources/art/icon512_red@2x.png b/Telegram/Resources/art/icon512_red@2x.png new file mode 100644 index 000000000..89e557c77 Binary files /dev/null and b/Telegram/Resources/art/icon512_red@2x.png differ diff --git a/Telegram/Resources/art/logo_256_blue.png b/Telegram/Resources/art/logo_256_blue.png new file mode 100644 index 000000000..8443bd4da Binary files /dev/null and b/Telegram/Resources/art/logo_256_blue.png differ diff --git a/Telegram/Resources/art/logo_256_green.png b/Telegram/Resources/art/logo_256_green.png new file mode 100644 index 000000000..90688030b Binary files /dev/null and b/Telegram/Resources/art/logo_256_green.png differ diff --git a/Telegram/Resources/art/logo_256_no_margin_blue.png b/Telegram/Resources/art/logo_256_no_margin_blue.png new file mode 100644 index 000000000..b772365cf Binary files /dev/null and b/Telegram/Resources/art/logo_256_no_margin_blue.png differ diff --git a/Telegram/Resources/art/logo_256_no_margin_green.png b/Telegram/Resources/art/logo_256_no_margin_green.png new file mode 100644 index 000000000..0522cde26 Binary files /dev/null and b/Telegram/Resources/art/logo_256_no_margin_green.png differ diff --git a/Telegram/Resources/art/logo_256_no_margin_old.png b/Telegram/Resources/art/logo_256_no_margin_old.png new file mode 100644 index 000000000..1d4b3d4c2 Binary files /dev/null and b/Telegram/Resources/art/logo_256_no_margin_old.png differ diff --git a/Telegram/Resources/art/logo_256_no_margin_orange.png b/Telegram/Resources/art/logo_256_no_margin_orange.png new file mode 100644 index 000000000..b13d32d09 Binary files /dev/null and b/Telegram/Resources/art/logo_256_no_margin_orange.png differ diff --git a/Telegram/Resources/art/logo_256_no_margin_red.png b/Telegram/Resources/art/logo_256_no_margin_red.png new file mode 100644 index 000000000..36b08072e Binary files /dev/null and b/Telegram/Resources/art/logo_256_no_margin_red.png differ diff --git a/Telegram/Resources/art/logo_256_old.png b/Telegram/Resources/art/logo_256_old.png new file mode 100644 index 000000000..e03acca61 Binary files /dev/null and b/Telegram/Resources/art/logo_256_old.png differ diff --git a/Telegram/Resources/art/logo_256_orange.png b/Telegram/Resources/art/logo_256_orange.png new file mode 100644 index 000000000..888d9cba1 Binary files /dev/null and b/Telegram/Resources/art/logo_256_orange.png differ diff --git a/Telegram/Resources/art/logo_256_red.png b/Telegram/Resources/art/logo_256_red.png new file mode 100644 index 000000000..6a8fa31f9 Binary files /dev/null and b/Telegram/Resources/art/logo_256_red.png differ diff --git a/Telegram/Resources/icons/settings/settings_kotato_old.png b/Telegram/Resources/icons/settings/settings_kotato_old.png new file mode 100644 index 000000000..17cf76b1e Binary files /dev/null and b/Telegram/Resources/icons/settings/settings_kotato_old.png differ diff --git a/Telegram/Resources/icons/settings/settings_kotato_old@2x.png b/Telegram/Resources/icons/settings/settings_kotato_old@2x.png new file mode 100644 index 000000000..2eb82f743 Binary files /dev/null and b/Telegram/Resources/icons/settings/settings_kotato_old@2x.png differ diff --git a/Telegram/Resources/icons/settings/settings_kotato_old@3x.png b/Telegram/Resources/icons/settings/settings_kotato_old@3x.png new file mode 100644 index 000000000..c267c40d0 Binary files /dev/null and b/Telegram/Resources/icons/settings/settings_kotato_old@3x.png differ diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index 5fd5d9f68..6dad6dbc7 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -91,6 +91,16 @@ "ktg_settings_userpic_rounding_big": "Big", "ktg_settings_userpic_rounding_full": "Circle", "ktg_settings_userpic_rounding_desc": "You'll need to restart app to save changes.", + "ktg_settings_tray_icon": "Tray icon", + "ktg_settings_tray_icon_default": "Default", + "ktg_settings_tray_icon_blue": "Blue", + "ktg_settings_tray_icon_green": "Green", + "ktg_settings_tray_icon_orange": "Orange", + "ktg_settings_tray_icon_red": "Red", + "ktg_settings_tray_icon_legacy": "Legacy", + "ktg_settings_tray_icon_desc": "If you don't like any of these icons, you can place icon.png in your profile folder, but you'll need to restart app to see it.\n\nIcons below don't require restart.", + "ktg_settings_disable_tray_counter": "Disable tray icon counter", + "ktg_settings_use_telegram_panel_icon": "Ask the system for telegram icon", "ktg_settings_chat_id": "Chat ID in profile", "ktg_settings_chat_id_desc": "You can choose desired format here.\n\nTelegram API uses IDs as-is, but Bot API adds minus in the beginning for groups, and -100 for channels and supergroups to fit it in one field.\n\nIf you have profile panel opened, re-open it to see changes.", "ktg_settings_chat_id_disable": "Hide", diff --git a/Telegram/Resources/qrc/telegram/telegram.qrc b/Telegram/Resources/qrc/telegram/telegram.qrc index e83d242c0..d6bc5fa0c 100644 --- a/Telegram/Resources/qrc/telegram/telegram.qrc +++ b/Telegram/Resources/qrc/telegram/telegram.qrc @@ -46,7 +46,17 @@ ../../art/bg_thumbnail.png ../../art/bg_initial.jpg ../../art/logo_256.png + ../../art/logo_256_blue.png + ../../art/logo_256_green.png + ../../art/logo_256_orange.png + ../../art/logo_256_red.png + ../../art/logo_256_old.png ../../art/logo_256_no_margin.png + ../../art/logo_256_no_margin_blue.png + ../../art/logo_256_no_margin_green.png + ../../art/logo_256_no_margin_orange.png + ../../art/logo_256_no_margin_red.png + ../../art/logo_256_no_margin_old.png ../../art/themeimage.jpg ../../art/dice_idle.tgs ../../art/dart_idle.tgs diff --git a/Telegram/Resources/winrc/Kotatogram.rc b/Telegram/Resources/winrc/Kotatogram.rc index 441af8347..131955b55 100644 --- a/Telegram/Resources/winrc/Kotatogram.rc +++ b/Telegram/Resources/winrc/Kotatogram.rc @@ -26,6 +26,11 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON1 ICON "..\\art\\icon256.ico" +IDI_ICON2 ICON "..\\art\\icon256blue.ico" +IDI_ICON3 ICON "..\\art\\icon256green.ico" +IDI_ICON4 ICON "..\\art\\icon256orange.ico" +IDI_ICON5 ICON "..\\art\\icon256red.ico" +IDI_ICON6 ICON "..\\art\\icon256old.ico" ///////////////////////////////////////////////////////////////////////////// // diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index d67503424..15332609b 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -397,6 +397,16 @@ const std::map> DefinitionMap { .type = SettingType::IntSetting, .defaultValue = int(Platform::FileDialog::ImplementationType::Default), .limitHandler = FileDialogLimit(), }}, + { "disable_tray_counter", { + .type = SettingType::BoolSetting, + .defaultValue = Platform::IsLinux(), }}, + { "use_telegram_panel_icon", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, + { "custom_app_icon", { + .type = SettingType::IntSetting, + .defaultValue = 0, + .limitHandler = IntLimit(0, 5), }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index c627f8786..f5ddf93ae 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -100,6 +100,32 @@ QString UserpicRoundingLabel(int rounding) { return QString(); } +QString TrayIconLabel(int icon) { + switch (icon) { + case 0: + return ktr("ktg_settings_tray_icon_default"); + + case 1: + return ktr("ktg_settings_tray_icon_blue"); + + case 2: + return ktr("ktg_settings_tray_icon_green"); + + case 3: + return ktr("ktg_settings_tray_icon_orange"); + + case 4: + return ktr("ktg_settings_tray_icon_red"); + + case 5: + return ktr("ktg_settings_tray_icon_legacy"); + + default: + Unexpected("Icon in Settings::TrayIconLabel."); + } + return QString(); +} + QString ChatIdLabel(int option) { switch (option) { case 0: @@ -461,6 +487,64 @@ void SetupKotatoSystem( }); } + AddButton( + container, + rktr("ktg_settings_disable_tray_counter"), + st::settingsButton + )->toggleOn( + rpl::single(::Kotato::JsonSettings::GetBool("disable_tray_counter")) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != ::Kotato::JsonSettings::GetBool("disable_tray_counter")); + }) | rpl::start_with_next([controller](bool enabled) { + ::Kotato::JsonSettings::Set("disable_tray_counter", enabled); + controller->session().data().notifyUnreadBadgeChanged(); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + + if (Platform::IsLinux()) { + AddButton( + container, + rktr("ktg_settings_use_telegram_panel_icon"), + st::settingsButton + )->toggleOn( + rpl::single(::Kotato::JsonSettings::GetBool("use_telegram_panel_icon")) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != ::Kotato::JsonSettings::GetBool("use_telegram_panel_icon")); + }) | rpl::start_with_next([controller](bool enabled) { + ::Kotato::JsonSettings::Set("use_telegram_panel_icon", enabled); + controller->session().data().notifyUnreadBadgeChanged(); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + } + + auto trayIconText = rpl::single( + rpl::empty_value() + ) | rpl::then( + controller->session().data().unreadBadgeChanges() + ) | rpl::map([] { + return TrayIconLabel(::Kotato::JsonSettings::GetInt("custom_app_icon")); + }); + + AddButtonWithLabel( + container, + rktr("ktg_settings_tray_icon"), + trayIconText, + st::settingsButton + )->addClickHandler([=] { + Ui::show(Box<::Kotato::RadioBox>( + ktr("ktg_settings_tray_icon"), + ktr("ktg_settings_tray_icon_desc"), + ::Kotato::JsonSettings::GetInt("custom_app_icon"), + 6, + TrayIconLabel, + [=] (int value) { + ::Kotato::JsonSettings::Set("custom_app_icon", value); + controller->session().data().notifyUnreadBadgeChanged(); + ::Kotato::JsonSettings::Write(); + }, false)); + }); AddSkip(container); } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index dfec88d0d..759f6976f 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/linux/main_window_linux.h" +#include "kotato/kotato_settings.h" #include "styles/style_window.h" #include "platform/linux/specific_linux.h" #include "platform/linux/linux_wayland_integration.h" @@ -63,12 +64,17 @@ using WorkMode = Core::Settings::WorkMode; constexpr auto kPanelTrayIconName = "kotatogram-panel"_cs; constexpr auto kMutePanelTrayIconName = "kotatogram-mute-panel"_cs; constexpr auto kAttentionPanelTrayIconName = "kotatogram-attention-panel"_cs; +constexpr auto kTelegramPanelTrayIconName = "telegram-panel"_cs; +constexpr auto kTelegramMutePanelTrayIconName = "telegram-mute-panel"_cs; +constexpr auto kTelegramAttentionPanelTrayIconName = "telegram-attention-panel"_cs; bool TrayIconMuted = true; int32 TrayIconCount = 0; base::flat_map TrayIconImageBack; QIcon TrayIcon; QString TrayIconThemeName, TrayIconName; +int TrayIconCustomId = 0; +bool TrayIconCounterDisabled = false; #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION void XCBSkipTaskbar(QWindow *window, bool skip) { @@ -166,11 +172,24 @@ void SkipTaskbar(QWindow *window, bool skip) { } QString GetPanelIconName(int counter, bool muted) { + const auto useTelegramPanelIcon = ::Kotato::JsonSettings::GetBool("use_telegram_panel_icon"); + const auto iconName = useTelegramPanelIcon + ? kTelegramPanelTrayIconName.utf16() + : kPanelTrayIconName.utf16(); + + const auto muteIconName = useTelegramPanelIcon + ? kTelegramMutePanelTrayIconName.utf16() + : kMutePanelTrayIconName.utf16(); + + const auto attentionIconName = useTelegramPanelIcon + ? kTelegramAttentionPanelTrayIconName.utf16() + : kAttentionPanelTrayIconName.utf16(); + return (counter > 0) ? (muted - ? kMutePanelTrayIconName.utf16() - : kAttentionPanelTrayIconName.utf16()) - : kPanelTrayIconName.utf16(); + ? muteIconName + : attentionIconName) + : iconName; } QString GetTrayIconName(int counter, bool muted) { @@ -192,6 +211,13 @@ int GetCounterSlice(int counter) { : counter; } +bool UseIconFromTheme(const QString &iconName) { + return ::Kotato::JsonSettings::GetBool("disable_tray_counter") + && !QFileInfo::exists(cWorkingDir() + "tdata/icon.png") + && ::Kotato::JsonSettings::GetInt("custom_app_icon") == 0 + && !iconName.isEmpty(); +} + bool IsIconRegenerationNeeded( int counter, bool muted, @@ -203,7 +229,9 @@ bool IsIconRegenerationNeeded( || iconThemeName != TrayIconThemeName || iconName != TrayIconName || muted != TrayIconMuted - || counterSlice != TrayIconCount; + || counterSlice != TrayIconCount + || ::Kotato::JsonSettings::GetInt("custom_app_icon") != TrayIconCustomId + || ::Kotato::JsonSettings::GetBool("disable_tray_counter") != TrayIconCounterDisabled; } void UpdateIconRegenerationNeeded( @@ -219,6 +247,8 @@ void UpdateIconRegenerationNeeded( TrayIconCount = counterSlice; TrayIconThemeName = iconThemeName; TrayIconName = iconName; + TrayIconCustomId = ::Kotato::JsonSettings::GetInt("custom_app_icon"); + TrayIconCounterDisabled = ::Kotato::JsonSettings::GetBool("disable_tray_counter"); } QIcon TrayIconGen(int counter, bool muted) { @@ -229,9 +259,8 @@ QIcon TrayIconGen(int counter, bool muted) { } const auto iconName = GetTrayIconName(counter, muted); - const auto panelIconName = GetPanelIconName(counter, muted); - if (iconName == panelIconName) { + if (UseIconFromTheme(iconName)) { const auto result = QIcon::fromTheme(iconName); UpdateIconRegenerationNeeded(result, counter, muted, iconThemeName); return result; @@ -252,14 +281,23 @@ QIcon TrayIconGen(int counter, bool muted) { return image.size() / image.devicePixelRatio(); }; + const auto customAppIcon = ::Kotato::JsonSettings::GetInt("custom_app_icon"); + const auto disableTrayCounter = ::Kotato::JsonSettings::GetInt("disable_tray_counter"); + for (const auto iconSize : iconSizes) { auto ¤tImageBack = TrayIconImageBack[iconSize]; const auto desiredSize = QSize(iconSize, iconSize); if (currentImageBack.isNull() || iconThemeName != TrayIconThemeName - || iconName != TrayIconName) { - if (!iconName.isEmpty()) { + || iconName != TrayIconName + || customAppIcon != TrayIconCustomId + || disableTrayCounter != TrayIconCounterDisabled) { + if (QFileInfo::exists(cWorkingDir() + "tdata/icon.png")) { + currentImageBack = QImage(cWorkingDir() + "tdata/icon.png"); + } else if (customAppIcon != 0) { + currentImageBack = Window::Logo(customAppIcon); + } else if (!iconName.isEmpty()) { if (systemIcon.isNull()) { systemIcon = QIcon::fromTheme(iconName); } @@ -302,7 +340,8 @@ QIcon TrayIconGen(int counter, bool muted) { auto iconImage = currentImageBack; - if (counter > 0) { + if (!disableTrayCounter + && counter > 0) { const auto &bg = muted ? st::trayCounterBgMute : st::trayCounterBg; diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index b67e6d5e7..e46a1df26 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/mac/main_window_mac.h" #include "kotato/kotato_lang.h" +#include "kotato/kotato_settings.h" #include "data/data_session.h" #include "styles/style_window.h" #include "mainwindow.h" @@ -66,13 +67,35 @@ namespace { // fullscreen mode, after that we'll hide the window no matter what. constexpr auto kHideAfterFullscreenTimeoutMs = 3000; -[[nodiscard]] QImage TrayIconBack(bool darkMode) { +[[nodiscard]] QImage TrayIconBack(bool darkMode, bool selected = false) { static const auto WithColor = [](QColor color) { return st::macTrayIcon.instance(color, 100); }; - static const auto DarkModeResult = WithColor({ 255, 255, 255 }); - static const auto LightModeResult = WithColor({ 0, 0, 0, 180 }); - auto result = darkMode ? DarkModeResult : LightModeResult; + + QImage iconImageLight(cWorkingDir() + "tdata/icon.png"); + QImage iconImageDark(cWorkingDir() + "tdata/icon_dark.png"); + QImage iconImageLightSelected(cWorkingDir() + "tdata/icon_selected.png"); + QImage iconImageDarkSelected(cWorkingDir() + "tdata/icon_dark_selected.png"); + + + static const auto LightModeResult = iconImageLight.isNull() + ? WithColor({ 0, 0, 0, 180 }) + : iconImageLight; + static const auto DarkModeResult = iconImageDark.isNull() + ? (iconImageLight.isNull() + ? WithColor({ 255, 255, 255 }) + : iconImageLight) + : iconImageDark; + static const auto LightModeSelectedResult = iconImageLightSelected.isNull() + ? DarkModeResult + : iconImageLightSelected; + static const auto DarkModeSelectedResult = iconImageDarkSelected.isNull() + ? LightModeSelectedResult + : iconImageDarkSelected; + + auto result = darkMode + ? (selected ? DarkModeSelectedResult : DarkModeResult) + : (selected ? LightModeSelectedResult : LightModeResult); result.detach(); return result; } @@ -127,6 +150,7 @@ private: - (void) darkModeChanged:(NSNotification *)aNotification { Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::App().settings().setSystemDarkMode(Platform::IsDarkMode()); + Core::App().domain().notifyUnreadBadgeChanged(); }); } @@ -395,34 +419,23 @@ void MainWindow::updateIconCounters() { QIcon MainWindow::generateIconForTray(int counter, bool muted) const { auto result = QIcon(); - auto lightMode = TrayIconBack(false); - auto darkMode = TrayIconBack(true); - auto lightModeActive = darkMode; - auto darkModeActive = darkMode; - lightModeActive.detach(); - darkModeActive.detach(); + const auto dm = Platform::IsDarkMenuBar(); + auto img = TrayIconBack(dm); + auto imgsel = TrayIconBack(dm, true); + img.detach(); + imgsel.detach(); const auto size = 22 * cIntRetinaFactor(); const auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg); - _placeCounter(lightMode, size, counter, bg, st::trayCounterFg); - _placeCounter(darkMode, size, counter, bg, muted ? st::trayCounterFgMacInvert : st::trayCounterFg); - _placeCounter(lightModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); - _placeCounter(darkModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); + if (!::Kotato::JsonSettings::GetBool("disable_tray_counter")) { + _placeCounter(img, size, counter, bg, (dm && muted) ? st::trayCounterFgMacInvert : st::trayCounterFg); + _placeCounter(imgsel, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); + } result.addPixmap(Ui::PixmapFromImage( - std::move(lightMode)), - QIcon::Normal, - QIcon::Off); + std::move(img)), + QIcon::Normal); result.addPixmap(Ui::PixmapFromImage( - std::move(darkMode)), - QIcon::Normal, - QIcon::On); - result.addPixmap(Ui::PixmapFromImage( - std::move(lightModeActive)), - QIcon::Active, - QIcon::Off); - result.addPixmap(Ui::PixmapFromImage( - std::move(darkModeActive)), - QIcon::Active, - QIcon::On); + std::move(imgsel)), + QIcon::Active); return result; } diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 146fac142..0e96fb67f 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/win/main_window_win.h" #include "kotato/kotato_lang.h" +#include "kotato/kotato_settings.h" #include "styles/style_window.h" #include "platform/platform_specific.h" #include "platform/platform_notifications_manager.h" @@ -101,8 +102,11 @@ uint32 kTaskbarCreatedMsgId = 0; Main::Session *session, bool smallIcon) { static constexpr auto kCount = 3; - static auto ScaledLogo = std::array(); - static auto ScaledLogoNoMargin = std::array(); + static constexpr auto kLogoCount = 7; + static constexpr auto kTotalCount = kLogoCount * kCount; + static auto ScaledLogo = std::array(); + static auto ScaledLogoNoMargin = std::array(); + static auto CustomIcon = QImage(cWorkingDir() + "tdata/icon.png"); struct Dimensions { int index = 0; @@ -131,13 +135,19 @@ uint32 kTaskbarCreatedMsgId = 0; auto &scaled = smallIcon ? ScaledLogoNoMargin : ScaledLogo; auto result = [&] { - auto &image = scaled[d.index]; + const auto idx = CustomIcon.isNull() + ? ::Kotato::JsonSettings::GetInt("custom_app_icon") + : kLogoCount - 1; + auto &image = scaled[idx * kCount + d.index]; + if (image.isNull()) { - image = (smallIcon - ? Window::LogoNoMargin() - : Window::Logo()).scaledToWidth( - d.size, - Qt::SmoothTransformation); + image = !CustomIcon.isNull() + ? CustomIcon.scaledToWidth(d.size, Qt::SmoothTransformation) + : (smallIcon + ? Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")) + : Window::Logo(::Kotato::JsonSettings::GetInt("custom_app_icon"))).scaledToWidth( + d.size, + Qt::SmoothTransformation); } return image; }(); @@ -317,9 +327,11 @@ void MainWindow::psTrayMenuUpdated() { void MainWindow::psSetupTrayIcon() { if (!trayIcon) { trayIcon = new QSystemTrayIcon(this); - - const auto icon = QIcon(Ui::PixmapFromImage( - QImage(Window::LogoNoMargin()))); + auto icon = QIcon(cWorkingDir() + "tdata/icon.png"); + if (icon.isNull()) { + icon = QIcon(Ui::PixmapFromImage( + QImage(Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon"))))); + } trayIcon->setIcon(icon); connect( @@ -482,9 +494,16 @@ void MainWindow::updateIconCounters() { if (trayIcon) { // Force Qt to use right icon size, not the larger one. QIcon forTrayIcon; + const auto disableTrayCounter = ::Kotato::JsonSettings::GetBool("disable_tray_counter"); + auto forTrayIcon16 = disableTrayCounter + ? iconWithCounter(16, 0, true) + : iconSmallPixmap16; + auto forTrayIcon32 = disableTrayCounter + ? iconWithCounter(32, 0, true) + : iconSmallPixmap32; forTrayIcon.addPixmap(iconSizeSmall.width() >= 20 - ? iconSmallPixmap32 - : iconSmallPixmap16); + ? forTrayIcon32 + : forTrayIcon16); trayIcon->setIcon(forTrayIcon); } diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index 20ea09da3..7bcaaa1dc 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -64,6 +64,7 @@ settingsIconStickers: icon {{ "settings/settings_stickers", menuIconFg }}; settingsIconEmoji: icon {{ "settings/settings_emoji", menuIconFg }}; settingsIconThemes: icon {{ "settings/settings_themes", menuIconFg }}; settingsIconKotato: icon {{ "settings/settings_kotato", menuIconFg }}; +settingsIconKotatoOld: icon {{ "settings/settings_kotato_old", menuIconFg }}; settingsSetPhotoSkip: 7px; diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index f9b6b4890..07e8b7154 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -166,7 +166,9 @@ void SetupSections( addSection( rktr("ktg_settings_kotato"), Type::Kotato, - &st::settingsIconKotato); + (::Kotato::JsonSettings::GetInt("custom_app_icon") == 5 + ? &st::settingsIconKotatoOld + : &st::settingsIconKotato)); SetupLanguageButton(container); diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 301ca33b0..afef5abcb 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "settings/settings_notifications.h" +#include "kotato/kotato_settings.h" #include "settings/settings_common.h" #include "ui/effects/animations.h" #include "ui/wrap/vertical_layout.h" @@ -259,7 +260,7 @@ void NotificationsCount::prepareNotificationSampleSmall() { void NotificationsCount::prepareNotificationSampleUserpic() { if (_notificationSampleUserpic.isNull()) { _notificationSampleUserpic = Ui::PixmapFromImage( - Window::LogoNoMargin().scaled( + Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).scaled( st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(), Qt::IgnoreAspectRatio, diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 374f39cd3..ef9eb0cd8 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/main_window.h" +#include "kotato/kotato_settings.h" #include "storage/localstorage.h" #include "platform/platform_specific.h" #include "ui/platform/ui_platform_window.h" @@ -48,13 +49,41 @@ constexpr auto kSaveWindowPositionTimeout = crl::time(1000); } // namespace -const QImage &Logo() { +const QImage &Logo(int variant) { static const auto result = QImage(u":/gui/art/logo_256.png"_q); + static const auto result_blue = QImage(u":/gui/art/logo_256_blue.png"_q); + static const auto result_green = QImage(u":/gui/art/logo_256_green.png"_q); + static const auto result_orange = QImage(u":/gui/art/logo_256_orange.png"_q); + static const auto result_red = QImage(u":/gui/art/logo_256_red.png"_q); + static const auto result_old = QImage(u":/gui/art/logo_256_old.png"_q); + + switch (variant) { + case 1: return result_blue; + case 2: return result_green; + case 3: return result_orange; + case 4: return result_red; + case 5: return result_old; + } + return result; } -const QImage &LogoNoMargin() { +const QImage &LogoNoMargin(int variant) { static const auto result = QImage(u":/gui/art/logo_256_no_margin.png"_q); + static const auto result_blue = QImage(u":/gui/art/logo_256_no_margin_blue.png"_q); + static const auto result_green = QImage(u":/gui/art/logo_256_no_margin_green.png"_q); + static const auto result_orange = QImage(u":/gui/art/logo_256_no_margin_orange.png"_q); + static const auto result_red = QImage(u":/gui/art/logo_256_no_margin_red.png"_q); + static const auto result_old = QImage(u":/gui/art/logo_256_no_margin_old.png"_q); + + switch (variant) { + case 1: return result_blue; + case 2: return result_green; + case 3: return result_orange; + case 4: return result_red; + case 5: return result_old; + } + return result; } @@ -110,7 +139,12 @@ QIcon CreateOfficialIcon(Main::Session *session) { if (!support) { return QIcon(); } - auto image = Logo(); + const auto customIcon = QImage(cWorkingDir() + "tdata/icon.png"); + + auto image = customIcon.isNull() + ? Logo(::Kotato::JsonSettings::GetInt("custom_app_icon")) + : customIcon; + ConvertIconToBlack(image); return QIcon(Ui::PixmapFromImage(std::move(image))); } @@ -124,6 +158,12 @@ QIcon CreateIcon(Main::Session *session, bool returnNullIfDefault) { auto result = QIcon(Ui::PixmapFromImage(base::duplicate(Logo()))); #if defined Q_OS_UNIX && !defined Q_OS_MAC + if ((session && session->supportMode()) + || (::Kotato::JsonSettings::GetInt("custom_app_icon") != 0) + || QFileInfo::exists(cWorkingDir() + "tdata/icon.png")) { + return result; + } + const auto iconFromTheme = QIcon::fromTheme( Platform::GetIconName(), result); @@ -412,9 +452,11 @@ void MainWindow::updateWindowIcon() { ? &sessionController()->session() : nullptr; const auto supportIcon = session && session->supportMode(); - if (supportIcon != _usingSupportIcon || _icon.isNull()) { + const auto customAppIcon = ::Kotato::JsonSettings::GetInt("custom_app_icon"); + if (supportIcon != _usingSupportIcon || _icon.isNull() || _customIconId != customAppIcon) { _icon = CreateIcon(session); _usingSupportIcon = supportIcon; + _customIconId = customAppIcon; } setWindowIcon(_icon); } diff --git a/Telegram/SourceFiles/window/main_window.h b/Telegram/SourceFiles/window/main_window.h index 70a886ddd..bff4548d9 100644 --- a/Telegram/SourceFiles/window/main_window.h +++ b/Telegram/SourceFiles/window/main_window.h @@ -37,8 +37,8 @@ class SessionController; class TitleWidget; struct TermsLock; -[[nodiscard]] const QImage &Logo(); -[[nodiscard]] const QImage &LogoNoMargin(); +[[nodiscard]] const QImage &Logo(int variant = 0); +[[nodiscard]] const QImage &LogoNoMargin(int variant = 0); [[nodiscard]] QIcon CreateIcon( Main::Session *session = nullptr, bool returnNullIfDefault = false); @@ -230,6 +230,7 @@ private: QIcon _icon; bool _usingSupportIcon = false; + int _customIconId = 0; bool _isActive = false; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 8d1e90d80..253f3cdc2 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/notifications_manager_default.h" +#include "kotato/kotato_settings.h" #include "platform/platform_notifications_manager.h" #include "platform/platform_specific.h" #include "core/application.h" @@ -93,7 +94,7 @@ Manager::QueuedNotification::QueuedNotification(NotificationFields &&fields) QPixmap Manager::hiddenUserpicPlaceholder() const { if (_hiddenUserpicPlaceholder.isNull()) { _hiddenUserpicPlaceholder = Ui::PixmapFromImage( - LogoNoMargin().scaled( + LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).scaled( st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, diff --git a/Telegram/SourceFiles/window/notifications_utilities.cpp b/Telegram/SourceFiles/window/notifications_utilities.cpp index 2911ed575..295a1bd1a 100644 --- a/Telegram/SourceFiles/window/notifications_utilities.cpp +++ b/Telegram/SourceFiles/window/notifications_utilities.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/notifications_utilities.h" +#include "kotato/kotato_settings.h" #include "window/main_window.h" #include "base/platform/base_platform_file_utilities.h" #include "base/random.h" @@ -80,7 +81,7 @@ QString CachedUserpics::get( peer->saveUserpic(view, v.path, st::notifyMacPhotoSize); } } else { - LogoNoMargin().save(v.path, "PNG"); + LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).save(v.path, "PNG"); } i = _images.insert(key, v); _someSavedFlag = true;