diff --git a/Telegram/Resources/icons/info/info_notifications_active.png b/Telegram/Resources/icons/info/info_notifications_active.png new file mode 100644 index 000000000..93aa4e90f Binary files /dev/null and b/Telegram/Resources/icons/info/info_notifications_active.png differ diff --git a/Telegram/Resources/icons/info/info_notifications_active@2x.png b/Telegram/Resources/icons/info/info_notifications_active@2x.png new file mode 100644 index 000000000..4cb37d17d Binary files /dev/null and b/Telegram/Resources/icons/info/info_notifications_active@2x.png differ diff --git a/Telegram/Resources/icons/info/info_notifications_active@3x.png b/Telegram/Resources/icons/info/info_notifications_active@3x.png new file mode 100644 index 000000000..4844781da Binary files /dev/null and b/Telegram/Resources/icons/info/info_notifications_active@3x.png differ diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index be0a03be2..2e3800f65 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -70,6 +70,7 @@ "ktg_settings_filters_only_unmuted_counter": "Do not count muted chats", "ktg_settings_filters_hide_edit": "Hide Edit button", "ktg_settings_filters_hide_folder_names": "Compact folders", + "ktg_settings_top_bar_mute": "Mute in profile top bar", "ktg_settings_messages": "Messages", "ktg_settings_filters_hide_all": "Hide \"All chats\" folder", "ktg_settings_tray_icon": "Tray icon", diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index ab16a1bd1..185db65c8 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -162,8 +162,19 @@ infoTopBarMenu: IconButton(infoTopBarBack) { iconPosition: point(18px, -1px); rippleAreaPosition: point(1px, 6px); } -infoTopBarCall: IconButton(infoTopBarMenu) { + +infoTopBarNotifications: IconButton(infoTopBarMenu) { width: 42px; + icon: icon {{ "info/info_notifications", boxTitleCloseFg }}; + iconOver: icon {{ "info/info_notifications", boxTitleCloseFgOver }}; + iconPosition: point(5px, -1px); + rippleAreaPosition: point(0px, 6px); +} +infoNotificationsActive: icon {{ + "info/info_notifications_active", + windowBgActive +}}; +infoTopBarCall: IconButton(infoTopBarNotifications) { icon: icon {{ "top_bar_call", boxTitleCloseFg }}; iconOver: icon {{ "top_bar_call", boxTitleCloseFgOver }}; iconPosition: point(5px, -1px); @@ -257,6 +268,12 @@ infoLayerTopBarMenu: IconButton(infoLayerTopBarClose) { iconOver: icon {{ "title_menu_dots", boxTitleCloseFgOver }}; iconPosition: point(16px, -1px); } +infoLayerTopBarNotifications: IconButton(infoLayerTopBarMenu) { + icon: icon {{ "info/info_notifications", boxTitleCloseFg }}; + iconOver: icon {{ "info/info_notifications", boxTitleCloseFgOver }}; + iconPosition: point(4px, -1px); + rippleAreaPosition: point(0px, 9px); +} infoLayerTopBarCall: IconButton(infoLayerTopBarMenu) { icon: icon {{ "top_bar_call", boxTitleCloseFg }}; iconOver: icon {{ "top_bar_call", boxTitleCloseFgOver }}; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 50eb99333..6745cec28 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "info/info_wrap_widget.h" +#include "kotato/kotato_settings.h" #include "info/profile/info_profile_widget.h" #include "info/profile/info_profile_values.h" #include "info/media/info_media_widget.h" @@ -35,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peer_list_box.h" #include "ui/boxes/confirm_box.h" #include "main/main_session.h" +#include "menu/menu_mute.h" #include "mtproto/mtproto_config.h" #include "data/data_download_manager.h" #include "data/data_session.h" @@ -407,6 +409,11 @@ void WrapWidget::setupTopBarMenuToggle() { } }, _topBar->lifetime()); } + + if (section.type() == Section::Type::Profile + && ::Kotato::JsonSettings::GetBool("profile_top_mute")) { + addProfileNotificationsButton(); + } } void WrapWidget::checkBeforeClose(Fn close) { @@ -476,6 +483,45 @@ void WrapWidget::addProfileCallsButton() { } } +void WrapWidget::addProfileNotificationsButton() { + Expects(_topBar != nullptr); + + const auto peer = key().peer(); + if (!peer || peer->isSelf()) { + return; + } + const auto topic = key().topic(); + const auto topicRootId = topic ? topic->rootId() : MsgId(); + const auto makeThread = [=] { + return topicRootId + ? static_cast(peer->forumTopicFor(topicRootId)) + : reinterpret_cast(peer->owner().history(peer).get()); + }; + auto notifications = _topBar->addButton( + base::make_unique_q( + _topBar, + (wrap() == Wrap::Layer + ? st::infoLayerTopBarNotifications + : st::infoTopBarNotifications))); + MuteMenu::SetupMuteMenu( + notifications, + notifications->clicks() | rpl::to_empty, + makeThread, + _controller->uiShow()); + Profile::NotificationsEnabledValue( + peer + ) | rpl::start_with_next([notifications](bool enabled) { + const auto iconOverride = enabled + ? &st::infoNotificationsActive + : nullptr; + const auto rippleOverride = enabled + ? &st::lightButtonBgOver + : nullptr; + notifications->setIconOverride(iconOverride, iconOverride); + notifications->setRippleColorOverride(rippleOverride); + }, notifications->lifetime()); +} + void WrapWidget::showTopBarMenu(bool check) { if (_topBarMenu) { _topBarMenu->hideMenu(true); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index 5feb502f7..792286e35 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -204,6 +204,7 @@ private: void addTopBarMenuButton(); void addProfileCallsButton(); + void addProfileNotificationsButton(); void showTopBarMenu(bool check); rpl::variable _wrap; diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 71ed7f79d..d20e8ed92 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -1273,7 +1273,7 @@ object_ptr DetailsFiller::setupInfo() { addTranslateToMenu(about.text, AboutWithIdValue(_peer)); } } - if (!_peer->isSelf()) { + if (!_peer->isSelf() && !::Kotato::JsonSettings::GetBool("profile_top_mute")) { // No notifications toggle for Self => no separator. result->add(object_ptr>( result, @@ -1799,7 +1799,7 @@ object_ptr DetailsFiller::fill() { add(object_ptr(_wrap)); add(CreateSkipWidget(_wrap)); add(setupInfo()); - if (!_peer->isSelf()) { + if (!_peer->isSelf() && !::Kotato::JsonSettings::GetBool("profile_top_mute")) { add(setupMuteToggle()); } setupMainButtons(); diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 2d5619a46..9361d9f8e 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -323,6 +323,9 @@ const std::map> DefinitionMap { { "folders/hide_all_chats", { .type = SettingType::BoolSetting, .defaultValue = false, }}, + { "profile_top_mute", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, { "folders/local", { .scope = SettingScope::Account, .type = SettingType::QJsonArraySetting, }}, diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index a8c8245f3..215ce652e 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -160,6 +160,7 @@ void SetupKotatoChats( updateRecentStickersLimitHeight); updateRecentStickersLimitLabel(::Kotato::JsonSettings::GetInt("recent_stickers_limit")); + SettingsMenuJsonSwitch(ktg_settings_top_bar_mute, profile_top_mute); SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit); SettingsMenuJsonSwitch(ktg_settings_always_show_scheduled, always_show_scheduled);