From bf9ffd729a10dafe24384fe627b408b7d92969c6 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Fri, 9 Sep 2022 20:07:36 +0300 Subject: [PATCH] [Option][GUI] Disable notifications from top bar --- .../icons/info/info_notifications_active.png | Bin 0 -> 1653 bytes .../info/info_notifications_active@2x.png | Bin 0 -> 1848 bytes .../info/info_notifications_active@3x.png | Bin 0 -> 1934 bytes Telegram/Resources/langs/rewrites/en.json | 1 + Telegram/SourceFiles/info/info.style | 19 +++++++- .../SourceFiles/info/info_wrap_widget.cpp | 46 ++++++++++++++++++ Telegram/SourceFiles/info/info_wrap_widget.h | 1 + .../info/profile/info_profile_actions.cpp | 4 +- .../SourceFiles/kotato/kotato_settings.cpp | 3 ++ .../kotato/kotato_settings_menu.cpp | 1 + 10 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 Telegram/Resources/icons/info/info_notifications_active.png create mode 100644 Telegram/Resources/icons/info/info_notifications_active@2x.png create mode 100644 Telegram/Resources/icons/info/info_notifications_active@3x.png 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 0000000000000000000000000000000000000000..93aa4e90f3e6a5d8ac8eee74e77e708e7fb3eb42 GIT binary patch literal 1653 zcmbVNe`wrP9M4wiYPaHkC@WLekSV*)=JM-$y@aOYdRM)ZU0b`8w#d{pd3Viv$;*=5 z?yh6VoYXnAREM2bg{oMvl>Jdqu%*@cV{NI*aLmHC(mx!IF-JwQ!&$_a>)o+Q{k6c$ zdoS24#`ZeiH^EzVej4ZKy3 zVR!waM%(PR$R0t4np;v}2XLn~1EDdjc6Zv4qG~*P*^E^ef6w8tbL0TEzmeQnd?Z`6(fhC)&VXIKb9Y(1GCT)>G zny#3j83kJ1%DD+Sj7m!e#kgt5q%2U83pgWbCbGg6nF0x*0o}F`mMLJ3PH01`6aEc# z;rKQI$hDD3LB^`OXj(ypWj7o|X5<{QD%y%>3_!I23non&G#o@~?r^Lzgn$Vo8=6rF z6Zt?j=T*i70Vgm#?rK$a1*WXZTke3MWCM|4X_h8wj^yYl;}dAFz<3^}If15Epb@C3 zvCL{v27zveqO4IQTl!b9A`3BSY7(+p)ucF}3_VWZ1y2eAn1Ch{jI`sjT0|m3Shs9R zmq9ov63A?~swx7nFp9^^R+B7{IMV0wNF-1DIFje&SdEX9d@S(h?+2lrbb_0|ul&#Z zO{R*9OG?}^k5h6^RtO>0Lh;JviefJ~kXt2GJevrDBs&Q%60#Fnpb)vw>K%Jvg*Md* z5a~aJdj)2}n4OYL;EyA3{g;fQkp7fYjVq>5f3-4uc1z{v;iw%r%R(PQn?ff8I%;1g z>Qk?j{x*qWYh2-=KN_04-hXCB;HThEg7_n&zz z#9X+sIQ_x7kEiSO`Nql9`#)S-xOs7WV(ZD-nVC1GfuSpz9%=bCe|!J)eeb$@;n$-h zp#5|DQ*0Bz>xJZ;hdfUFT(WC;c>CFXbH5I$({Ql&{K>J|(U-RDoV}cJhc{0gxi+S( zpE}?g=Qf;paAwH=z*O_MMx(#w9Tb%2tNMf*eUJeeMKYnMGw92KP1m% z%dJKJjmEi}vcV&-n(GcPP!prSKY6q#wywN-afBd1 zUap$0i}y8sIbMA8aB)SG>$v&0|BtG4a^%8CqPQ=3dFokD;o~nQ5xjzBX&oOKO literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..4cb37d17da366129b396910ac2a544d39e625aec GIT binary patch literal 1848 zcmbVN4RF&`9M51o*f@kS@i=5$2y6nbP11H=((oh%K?b_=oF(u*QM>#1fzPx7mulfFQOcX4Ajp6e?T$mq( zgK5Ae(r7r~7ZfUN!y>#CoNL=ShDIRj92;iW1fpf`BGe(u z0L|2!bqs0BM6;}V(rh$Ytr@6+AT2my!AYZzG*c#mG8oY4g+XaD%TXoH$x&HwWy5@` zDp5Ed3Wf9`qh6G~IBB(7al(Kb3_6I=DO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u}Px!NK!iznJE(OYOgK(qt-c@vNPv+OM6PLJZq<3F}{jF1~*# XOU+JbuMMt={M=l*1xPcG;5T}lV$xYAW7*oV~yZr)fPj~KR?taPdmwdjT z@B5qbOl#W2anr{^5Hv9(-IN8Mx$+7h3GVJkKk?u()|0+WgrM=00wT24skr0DJj0ioinh<$s6^83jOo!rX1+FDxF+!z+0~Z3c3ABUAGMNLqz{!B* zNs@;^QLopl^s1G-;6!n~UXNlbRHae?ghKRl66sTLVswzf#E6u@dL)+TV40D$^M#TD z0hSKC;P!-QIWZ6>5HQq7dQe=6$u126X)1*C6bh~(Dpk_fPP2w|nL(3bqft(b9-h0D^w|O zVAwF!!qcq7|12mTN2s5Mf~uiOiTqbEO%V=WaFf7i)=fGY)WbOuI21|3$h&v}Cug^tnc6l!~1tOnC*XcE^1 zI!gZV(Q} zfxHdPA#eyyGKK@=O8|39TW6U8K_inhOv%~4j(Z)ghhxa7bA42om+U=f)gDh>wrBRj zm_Ndooxhwy#%$B9zVHq_e%s8>nQc?HCnjyG>`6FvfE$SFIhlBIhx2y7?V{a*-#_HP zJ!tKJus$Lsd{$ZTb}+8OJgV%Co!{TiKXK~%z3^Gr?|qSVaL1z8jy}G;v$dyt!139% zEjQ={@NN94YkM^r`j&8RRhy3=gOk+&<; z%M8`;o<^rdR4t!+<=8dXIygPdU*>+2gCQ38#Ip%LLp(39J?g4bW# zjE>kl@cyJOb6tC7V`Y@oT`+s*EBfi@Eont&Q!S9Vb8SU*SxsH$-1wDgzYcy`yf(7D z*;wt1ueHHd*7{q$r!RH-ZHLx+}l5 qy|8J)C93hpgW{&#pxkShsR_#A>ytP#RV`ijUO|>bx>;44CEwNDm literal 0 HcmV?d00001 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);