[Option][GUI] Tray icon settings

This commit is contained in:
Eric Kotato 2022-08-31 15:38:29 +03:00 committed by Eric Kotato
parent 1cc8612c27
commit bbd098b241
38 changed files with 281 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -87,6 +87,16 @@
"ktg_settings_userpic_rounding_big": "Big", "ktg_settings_userpic_rounding_big": "Big",
"ktg_settings_userpic_rounding_full": "Circle", "ktg_settings_userpic_rounding_full": "Circle",
"ktg_settings_userpic_rounding_desc": "You'll need to restart app to save changes.", "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": "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_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", "ktg_settings_chat_id_disable": "Hide",

View file

@ -4,7 +4,17 @@
<file alias="art/bg_thumbnail.png">../../art/bg_thumbnail.png</file> <file alias="art/bg_thumbnail.png">../../art/bg_thumbnail.png</file>
<file alias="art/bg_initial.jpg">../../art/bg_initial.jpg</file> <file alias="art/bg_initial.jpg">../../art/bg_initial.jpg</file>
<file alias="art/logo_256.png">../../art/logo_256.png</file> <file alias="art/logo_256.png">../../art/logo_256.png</file>
<file alias="art/logo_256_blue.png">../../art/logo_256_blue.png</file>
<file alias="art/logo_256_green.png">../../art/logo_256_green.png</file>
<file alias="art/logo_256_orange.png">../../art/logo_256_orange.png</file>
<file alias="art/logo_256_red.png">../../art/logo_256_red.png</file>
<file alias="art/logo_256_old.png">../../art/logo_256_old.png</file>
<file alias="art/logo_256_no_margin.png">../../art/logo_256_no_margin.png</file> <file alias="art/logo_256_no_margin.png">../../art/logo_256_no_margin.png</file>
<file alias="art/logo_256_no_margin_blue.png">../../art/logo_256_no_margin_blue.png</file>
<file alias="art/logo_256_no_margin_green.png">../../art/logo_256_no_margin_green.png</file>
<file alias="art/logo_256_no_margin_orange.png">../../art/logo_256_no_margin_orange.png</file>
<file alias="art/logo_256_no_margin_red.png">../../art/logo_256_no_margin_red.png</file>
<file alias="art/logo_256_no_margin_old.png">../../art/logo_256_no_margin_old.png</file>
<file alias="art/themeimage.jpg">../../art/themeimage.jpg</file> <file alias="art/themeimage.jpg">../../art/themeimage.jpg</file>
<file alias="art/dice_idle.tgs">../../art/dice_idle.tgs</file> <file alias="art/dice_idle.tgs">../../art/dice_idle.tgs</file>
<file alias="art/dart_idle.tgs">../../art/dart_idle.tgs</file> <file alias="art/dart_idle.tgs">../../art/dart_idle.tgs</file>

View file

@ -26,6 +26,11 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Icon with lowest ID value placed first to ensure application icon // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems. // remains consistent on all systems.
IDI_ICON1 ICON "..\\art\\icon256.ico" 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"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

View file

@ -376,6 +376,16 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
.type = SettingType::BoolSetting, .type = SettingType::BoolSetting,
.defaultValue = false, }}, .defaultValue = false, }},
#endif #endif
{ "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; using OldOptionKey = QString;

View file

@ -86,6 +86,32 @@ QString UserpicRoundingLabel(int rounding) {
return QString(); 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) { QString ChatIdLabel(int option) {
switch (option) { switch (option) {
case 0: case 0:
@ -418,6 +444,62 @@ void SetupKotatoSystem(
}, container->lifetime()); }, container->lifetime());
#endif // Qt < 6.0.0 #endif // Qt < 6.0.0
AddButton(
container,
rktr("ktg_settings_disable_tray_counter"),
st::settingsButtonNoIcon
)->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::settingsButtonNoIcon
)->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) | 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::settingsButtonNoIcon
)->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); AddSkip(container);
} }

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "platform/linux/tray_linux.h" #include "platform/linux/tray_linux.h"
#include "kotato/kotato_settings.h"
#include "base/invoke_queued.h" #include "base/invoke_queued.h"
#include "base/qt_signal_producer.h" #include "base/qt_signal_producer.h"
#include "core/application.h" #include "core/application.h"
@ -47,6 +48,7 @@ private:
[[nodiscard]] QString panelIconName(int counter, bool muted) const; [[nodiscard]] QString panelIconName(int counter, bool muted) const;
[[nodiscard]] QString trayIconName(int counter, bool muted) const; [[nodiscard]] QString trayIconName(int counter, bool muted) const;
[[nodiscard]] int counterSlice(int counter) const; [[nodiscard]] int counterSlice(int counter) const;
[[nodiscard]] bool useIconFromTheme(const QString &iconName) const;
void updateIconRegenerationNeeded( void updateIconRegenerationNeeded(
const QIcon &icon, const QIcon &icon,
int counter, int counter,
@ -57,6 +59,9 @@ private:
const QString _panelTrayIconName; const QString _panelTrayIconName;
const QString _mutePanelTrayIconName; const QString _mutePanelTrayIconName;
const QString _attentionPanelTrayIconName; const QString _attentionPanelTrayIconName;
const QString _telegramPanelTrayIconName;
const QString _telegramMutePanelTrayIconName;
const QString _telegramAttentionPanelTrayIconName;
const int _iconSizes[5]; const int _iconSizes[5];
@ -66,6 +71,8 @@ private:
QIcon _trayIcon; QIcon _trayIcon;
QString _themeName; QString _themeName;
QString _name; QString _name;
int _customId = 0;
bool _counterDisabled = false;
}; };
@ -73,17 +80,27 @@ IconGraphic::IconGraphic()
: _panelTrayIconName("kotatogram-panel") : _panelTrayIconName("kotatogram-panel")
, _mutePanelTrayIconName("kotatogram-mute-panel") , _mutePanelTrayIconName("kotatogram-mute-panel")
, _attentionPanelTrayIconName("kotatogram-attention-panel") , _attentionPanelTrayIconName("kotatogram-attention-panel")
, _telegramPanelTrayIconName("telegram-panel")
, _telegramMutePanelTrayIconName("telegram-mute-panel")
, _telegramAttentionPanelTrayIconName("telegram-attention-panel")
, _iconSizes{ 16, 22, 24, 32, 48 } { , _iconSizes{ 16, 22, 24, 32, 48 } {
} }
IconGraphic::~IconGraphic() = default; IconGraphic::~IconGraphic() = default;
QString IconGraphic::panelIconName(int counter, bool muted) const { QString IconGraphic::panelIconName(int counter, bool muted) const {
const auto useTelegramPanelIcon = ::Kotato::JsonSettings::GetBool("use_telegram_panel_icon");
return (counter > 0) return (counter > 0)
? (muted ? (muted
? _mutePanelTrayIconName ? (useTelegramPanelIcon
: _attentionPanelTrayIconName) ? _telegramMutePanelTrayIconName
: _panelTrayIconName; : _mutePanelTrayIconName)
: (useTelegramPanelIcon
? _telegramAttentionPanelTrayIconName
: _attentionPanelTrayIconName))
: (useTelegramPanelIcon
? _telegramPanelTrayIconName
: _panelTrayIconName);
} }
QString IconGraphic::trayIconName(int counter, bool muted) const { QString IconGraphic::trayIconName(int counter, bool muted) const {
@ -106,6 +123,13 @@ int IconGraphic::counterSlice(int counter) const {
: counter; : counter;
} }
bool IconGraphic::useIconFromTheme(const QString &iconName) const {
return ::Kotato::JsonSettings::GetBool("disable_tray_counter")
&& !QFileInfo::exists(cWorkingDir() + "tdata/icon.png")
&& ::Kotato::JsonSettings::GetInt("custom_app_icon") == 0
&& !iconName.isEmpty();
}
bool IconGraphic::isRefreshNeeded( bool IconGraphic::isRefreshNeeded(
int counter, int counter,
bool muted, bool muted,
@ -116,7 +140,9 @@ bool IconGraphic::isRefreshNeeded(
|| iconThemeName != _themeName || iconThemeName != _themeName
|| iconName != _name || iconName != _name
|| muted != _muted || muted != _muted
|| counterSlice(counter) != _count; || counterSlice(counter) != _count
|| ::Kotato::JsonSettings::GetInt("custom_app_icon") != _customId
|| ::Kotato::JsonSettings::GetBool("disable_tray_counter") != _counterDisabled;
} }
void IconGraphic::updateIconRegenerationNeeded( void IconGraphic::updateIconRegenerationNeeded(
@ -131,6 +157,8 @@ void IconGraphic::updateIconRegenerationNeeded(
_count = counterSlice(counter); _count = counterSlice(counter);
_themeName = iconThemeName; _themeName = iconThemeName;
_name = iconName; _name = iconName;
_customId = ::Kotato::JsonSettings::GetInt("custom_app_icon");
_counterDisabled = ::Kotato::JsonSettings::GetBool("disable_tray_counter");
} }
QSize IconGraphic::dprSize(const QImage &image) const { QSize IconGraphic::dprSize(const QImage &image) const {
@ -146,7 +174,7 @@ QIcon IconGraphic::trayIcon(int counter, bool muted) {
const auto iconName = trayIconName(counter, muted); const auto iconName = trayIconName(counter, muted);
if (iconName == panelIconName(counter, muted)) { if (useIconFromTheme(iconName)) {
const auto result = QIcon::fromTheme(iconName); const auto result = QIcon::fromTheme(iconName);
updateIconRegenerationNeeded(result, counter, muted, iconThemeName); updateIconRegenerationNeeded(result, counter, muted, iconThemeName);
return result; return result;
@ -154,6 +182,8 @@ QIcon IconGraphic::trayIcon(int counter, bool muted) {
QIcon result; QIcon result;
QIcon systemIcon; QIcon systemIcon;
const auto customAppIcon = ::Kotato::JsonSettings::GetInt("custom_app_icon");
const auto disableTrayCounter = ::Kotato::JsonSettings::GetInt("disable_tray_counter");
for (const auto iconSize : _iconSizes) { for (const auto iconSize : _iconSizes) {
auto &currentImageBack = _imageBack[iconSize]; auto &currentImageBack = _imageBack[iconSize];
@ -161,8 +191,14 @@ QIcon IconGraphic::trayIcon(int counter, bool muted) {
if (currentImageBack.isNull() if (currentImageBack.isNull()
|| iconThemeName != _themeName || iconThemeName != _themeName
|| iconName != _name) { || iconName != _name
if (!iconName.isEmpty()) { || customAppIcon != _customId
|| disableTrayCounter != _counterDisabled) {
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()) { if (systemIcon.isNull()) {
systemIcon = QIcon::fromTheme(iconName); systemIcon = QIcon::fromTheme(iconName);
} }
@ -205,7 +241,8 @@ QIcon IconGraphic::trayIcon(int counter, bool muted) {
auto iconImage = currentImageBack; auto iconImage = currentImageBack;
if (counter > 0) { if (!disableTrayCounter
&& counter > 0) {
const auto &bg = muted const auto &bg = muted
? st::trayCounterBgMute ? st::trayCounterBgMute
: st::trayCounterBg; : st::trayCounterBg;

View file

@ -116,6 +116,7 @@ private:
- (void) darkModeChanged:(NSNotification *)aNotification { - (void) darkModeChanged:(NSNotification *)aNotification {
Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Core::App().settings().setSystemDarkMode(Platform::IsDarkMode()); Core::App().settings().setSystemDarkMode(Platform::IsDarkMode());
Core::App().domain().notifyUnreadBadgeChanged();
}); });
} }

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "platform/mac/tray_mac.h" #include "platform/mac/tray_mac.h"
#include "kotato/kotato_settings.h"
#include "base/platform/mac/base_utilities_mac.h" #include "base/platform/mac/base_utilities_mac.h"
#include "core/application.h" #include "core/application.h"
#include "core/sandbox.h" #include "core/sandbox.h"
@ -90,13 +91,35 @@ namespace {
return false; return false;
} }
[[nodiscard]] QImage TrayIconBack(bool darkMode) { [[nodiscard]] QImage TrayIconBack(bool darkMode, bool selected = false) {
static const auto WithColor = [](QColor color) { static const auto WithColor = [](QColor color) {
return st::macTrayIcon.instance(color, 100); return st::macTrayIcon.instance(color, 100);
}; };
static const auto DarkModeResult = WithColor({ 255, 255, 255 });
static const auto LightModeResult = WithColor({ 0, 0, 0, 180 }); QImage iconImageLight(cWorkingDir() + "tdata/icon.png");
auto result = darkMode ? DarkModeResult : LightModeResult; 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(); result.detach();
return result; return result;
} }
@ -189,20 +212,21 @@ void UpdateIcon(const NSStatusItem *status) {
const auto selectedSize = QSize(side, side); const auto selectedSize = QSize(side, side);
auto result = TrayIconBack(darkMode); auto result = TrayIconBack(darkMode);
auto resultActive = result; auto resultActive = TrayIconBack(darkMode, true);
resultActive.detach();
const auto counter = Core::App().unreadBadge(); if (!::Kotato::JsonSettings::GetBool("disable_tray_counter")) {
const auto muted = Core::App().unreadBadgeMuted(); const auto counter = Core::App().unreadBadge();
const auto muted = Core::App().unreadBadgeMuted();
const auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg); const auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg);
const auto &fg = st::trayCounterFg; const auto &fg = st::trayCounterFg;
const auto &fgInvert = st::trayCounterFgMacInvert; const auto &fgInvert = st::trayCounterFgMacInvert;
const auto &bgInvert = st::trayCounterBgMacInvert; const auto &bgInvert = st::trayCounterBgMacInvert;
const auto &resultFg = !darkMode ? fg : muted ? fgInvert : fg; const auto &resultFg = !darkMode ? fg : muted ? fgInvert : fg;
PlaceCounter(result, side, counter, bg, resultFg); PlaceCounter(result, side, counter, bg, resultFg);
PlaceCounter(resultActive, side, counter, bgInvert, fgInvert); PlaceCounter(resultActive, side, counter, bgInvert, fgInvert);
}
// Scale large pixmaps to fit the available menu bar area. // Scale large pixmaps to fit the available menu bar area.
if (result.height() > maxImageHeight) { if (result.height() > maxImageHeight) {

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/win/tray_win.h" #include "platform/win/tray_win.h"
#include "kotato/kotato_lang.h" #include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "base/invoke_queued.h" #include "base/invoke_queued.h"
#include "base/qt_signal_producer.h" #include "base/qt_signal_producer.h"
#include "core/application.h" #include "core/application.h"
@ -32,8 +33,11 @@ constexpr auto kTooltipDelay = crl::time(10000);
bool supportMode, bool supportMode,
bool smallIcon) { bool smallIcon) {
static constexpr auto kCount = 3; static constexpr auto kCount = 3;
static auto ScaledLogo = std::array<QImage, kCount>(); static constexpr auto kLogoCount = 7;
static auto ScaledLogoNoMargin = std::array<QImage, kCount>(); static constexpr auto kTotalCount = kLogoCount * kCount;
static auto ScaledLogo = std::array<QImage, kTotalCount>();
static auto ScaledLogoNoMargin = std::array<QImage, kTotalCount>();
static auto CustomIcon = QImage(cWorkingDir() + "tdata/icon.png");
struct Dimensions { struct Dimensions {
int index = 0; int index = 0;
@ -62,13 +66,19 @@ constexpr auto kTooltipDelay = crl::time(10000);
auto &scaled = smallIcon ? ScaledLogoNoMargin : ScaledLogo; auto &scaled = smallIcon ? ScaledLogoNoMargin : ScaledLogo;
auto result = [&] { 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()) { if (image.isNull()) {
image = (smallIcon image = !CustomIcon.isNull()
? Window::LogoNoMargin() ? CustomIcon.scaledToWidth(d.size, Qt::SmoothTransformation)
: Window::Logo()).scaledToWidth( : (smallIcon
d.size, ? Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon"))
Qt::SmoothTransformation); : Window::Logo(::Kotato::JsonSettings::GetInt("custom_app_icon"))).scaledToWidth(
d.size,
Qt::SmoothTransformation);
} }
return image; return image;
}(); }();
@ -134,7 +144,8 @@ void Tray::updateIcon() {
if (!_icon) { if (!_icon) {
return; return;
} }
const auto counter = Core::App().unreadBadge(); const auto disableTrayCounter = ::Kotato::JsonSettings::GetBool("disable_tray_counter");
const auto counter = disableTrayCounter ? 0 : Core::App().unreadBadge();
const auto muted = Core::App().unreadBadgeMuted(); const auto muted = Core::App().unreadBadgeMuted();
const auto controller = Core::App().primaryWindow(); const auto controller = Core::App().primaryWindow();
const auto session = !controller const auto session = !controller

View file

@ -69,6 +69,7 @@ settingsIconStickers: icon {{ "settings/stickers", settingsIconFg }};
settingsIconEmoji: icon {{ "settings/emoji", settingsIconFg }}; settingsIconEmoji: icon {{ "settings/emoji", settingsIconFg }};
settingsIconThemes: icon {{ "settings/palette", settingsIconFg }}; settingsIconThemes: icon {{ "settings/palette", settingsIconFg }};
settingsIconKotato: icon {{ "settings/kotato", settingsIconFg }}; settingsIconKotato: icon {{ "settings/kotato", settingsIconFg }};
settingsIconKotatoOld: icon {{ "settings/kotato_old", settingsIconFg }};
settingsIconGroup: icon {{ "settings/group", settingsIconFg }}; settingsIconGroup: icon {{ "settings/group", settingsIconFg }};
settingsIconChannel: icon {{ "settings/channel", settingsIconFg }}; settingsIconChannel: icon {{ "settings/channel", settingsIconFg }};
settingsIconUser: icon {{ "settings/user", settingsIconFg }}; settingsIconUser: icon {{ "settings/user", settingsIconFg }};

View file

@ -374,7 +374,9 @@ void SetupSections(
addSection( addSection(
rktr("ktg_settings_kotato"), rktr("ktg_settings_kotato"),
Kotato::Id(), Kotato::Id(),
{ &st::settingsIconKotato, kIconPurple }); {(::Kotato::JsonSettings::GetInt("custom_app_icon") == 5
? &st::settingsIconKotatoOld
: &st::settingsIconKotato), kIconPurple });
SetupLanguageButton(container); SetupLanguageButton(container);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "settings/settings_notifications.h" #include "settings/settings_notifications.h"
#include "kotato/kotato_settings.h"
#include "settings/settings_common.h" #include "settings/settings_common.h"
#include "ui/controls/chat_service_checkbox.h" #include "ui/controls/chat_service_checkbox.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
@ -270,7 +271,7 @@ void NotificationsCount::prepareNotificationSampleSmall() {
void NotificationsCount::prepareNotificationSampleUserpic() { void NotificationsCount::prepareNotificationSampleUserpic() {
if (_notificationSampleUserpic.isNull()) { if (_notificationSampleUserpic.isNull()) {
_notificationSampleUserpic = Ui::PixmapFromImage( _notificationSampleUserpic = Ui::PixmapFromImage(
Window::LogoNoMargin().scaled( Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).scaled(
st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(),
st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(),
Qt::IgnoreAspectRatio, Qt::IgnoreAspectRatio,

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "window/main_window.h" #include "window/main_window.h"
#include "kotato/kotato_settings.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "ui/platform/ui_platform_window.h" #include "ui/platform/ui_platform_window.h"
@ -49,13 +50,41 @@ constexpr auto kSaveWindowPositionTimeout = crl::time(1000);
} // namespace } // 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 = 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; 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 = 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; return result;
} }
@ -111,7 +140,12 @@ QIcon CreateOfficialIcon(Main::Session *session) {
if (!support) { if (!support) {
return QIcon(); 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); ConvertIconToBlack(image);
return QIcon(Ui::PixmapFromImage(std::move(image))); return QIcon(Ui::PixmapFromImage(std::move(image)));
} }
@ -125,6 +159,12 @@ QIcon CreateIcon(Main::Session *session, bool returnNullIfDefault) {
auto result = QIcon(Ui::PixmapFromImage(base::duplicate(Logo()))); auto result = QIcon(Ui::PixmapFromImage(base::duplicate(Logo())));
#if defined Q_OS_UNIX && !defined Q_OS_MAC #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( const auto iconFromTheme = QIcon::fromTheme(
Platform::GetIconName(), Platform::GetIconName(),
result); result);
@ -414,9 +454,11 @@ void MainWindow::updateWindowIcon() {
? &sessionController()->session() ? &sessionController()->session()
: nullptr; : nullptr;
const auto supportIcon = session && session->supportMode(); 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); _icon = CreateIcon(session);
_usingSupportIcon = supportIcon; _usingSupportIcon = supportIcon;
_customIconId = customAppIcon;
} }
setWindowIcon(_icon); setWindowIcon(_icon);
} }

View file

@ -35,8 +35,8 @@ class SessionController;
class TitleWidget; class TitleWidget;
struct TermsLock; struct TermsLock;
[[nodiscard]] const QImage &Logo(); [[nodiscard]] const QImage &Logo(int variant = 0);
[[nodiscard]] const QImage &LogoNoMargin(); [[nodiscard]] const QImage &LogoNoMargin(int variant = 0);
[[nodiscard]] QIcon CreateIcon( [[nodiscard]] QIcon CreateIcon(
Main::Session *session = nullptr, Main::Session *session = nullptr,
bool returnNullIfDefault = false); bool returnNullIfDefault = false);
@ -209,6 +209,7 @@ private:
QIcon _icon; QIcon _icon;
bool _usingSupportIcon = false; bool _usingSupportIcon = false;
int _customIconId = 0;
bool _isActive = false; bool _isActive = false;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "window/notifications_manager_default.h" #include "window/notifications_manager_default.h"
#include "kotato/kotato_settings.h"
#include "platform/platform_notifications_manager.h" #include "platform/platform_notifications_manager.h"
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "core/application.h" #include "core/application.h"
@ -97,7 +98,7 @@ Manager::QueuedNotification::QueuedNotification(NotificationFields &&fields)
QPixmap Manager::hiddenUserpicPlaceholder() const { QPixmap Manager::hiddenUserpicPlaceholder() const {
if (_hiddenUserpicPlaceholder.isNull()) { if (_hiddenUserpicPlaceholder.isNull()) {
_hiddenUserpicPlaceholder = Ui::PixmapFromImage( _hiddenUserpicPlaceholder = Ui::PixmapFromImage(
LogoNoMargin().scaled( LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).scaled(
st::notifyPhotoSize, st::notifyPhotoSize,
st::notifyPhotoSize, st::notifyPhotoSize,
Qt::IgnoreAspectRatio, Qt::IgnoreAspectRatio,

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "window/notifications_utilities.h" #include "window/notifications_utilities.h"
#include "kotato/kotato_settings.h"
#include "window/main_window.h" #include "window/main_window.h"
#include "base/platform/base_platform_file_utilities.h" #include "base/platform/base_platform_file_utilities.h"
#include "base/random.h" #include "base/random.h"
@ -80,7 +81,7 @@ QString CachedUserpics::get(
peer->saveUserpic(view, v.path, st::notifyMacPhotoSize); peer->saveUserpic(view, v.path, st::notifyMacPhotoSize);
} }
} else { } else {
LogoNoMargin().save(v.path, "PNG"); LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).save(v.path, "PNG");
} }
i = _images.insert(key, v); i = _images.insert(key, v);
_someSavedFlag = true; _someSavedFlag = true;