From 4e9443e20095039f95d8aa79b6f7b9494922d718 Mon Sep 17 00:00:00 2001 From: ZavaruKitsu Date: Wed, 7 Feb 2024 23:25:02 +0300 Subject: [PATCH] feat: quick admins & recent actions Co-authored-by: c0re100 --- .../Resources/icons/ayu/top_bar_admins.png | Bin 0 -> 648 bytes .../Resources/icons/ayu/top_bar_admins@2x.png | Bin 0 -> 1174 bytes .../Resources/icons/ayu/top_bar_admins@3x.png | Bin 0 -> 1764 bytes .../icons/ayu/top_bar_recent_actions.png | Bin 0 -> 544 bytes .../icons/ayu/top_bar_recent_actions@2x.png | Bin 0 -> 901 bytes .../icons/ayu/top_bar_recent_actions@3x.png | Bin 0 -> 1250 bytes Telegram/SourceFiles/ayu/ui/ayu_styles.style | 31 +++++++++ .../view/history_view_top_bar_widget.cpp | 63 ++++++++++++++++++ .../view/history_view_top_bar_widget.h | 2 + 9 files changed, 96 insertions(+) create mode 100644 Telegram/Resources/icons/ayu/top_bar_admins.png create mode 100644 Telegram/Resources/icons/ayu/top_bar_admins@2x.png create mode 100644 Telegram/Resources/icons/ayu/top_bar_admins@3x.png create mode 100644 Telegram/Resources/icons/ayu/top_bar_recent_actions.png create mode 100644 Telegram/Resources/icons/ayu/top_bar_recent_actions@2x.png create mode 100644 Telegram/Resources/icons/ayu/top_bar_recent_actions@3x.png diff --git a/Telegram/Resources/icons/ayu/top_bar_admins.png b/Telegram/Resources/icons/ayu/top_bar_admins.png new file mode 100644 index 0000000000000000000000000000000000000000..3d44dba2847116e667509ca8200aaee4808d181b GIT binary patch literal 648 zcmV;30(bq1P)%EX+UZqmWM}UQPw#<=r^3_8%|o8zqly;#oYv+VbK-xSe`WwBUz$61e{%Li{2 zklnZ2&AU+Nh75JL1(z=u*i5kmgRD3zCi>-c#D#ZMQUtFBEp>-YN- zgD3**mgFN35DT8kbjFwygJPC3`u#KR_j~fJo0IX#<#I9aX;ni7WRda`Ae(hZdnw0K zsbqe2VkPBe4Lp|{Uco!IT72*xK0ue-%lWWctxR{LOHu_o{^r|r%cUiQT&-CCN{Ch( zat27sK}LCImEcI57~V-0fZ0$noy{5+pwO)my3W)A}!9YFlLY8K;vNq z5L&D~-`Sx{#9my;7lgY*s9uSfm}ICJ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/top_bar_admins@2x.png b/Telegram/Resources/icons/ayu/top_bar_admins@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f7b78dd7512cc5f209d2bec56b9e95d84c148b9e GIT binary patch literal 1174 zcmV;H1Zn$;P)08{`}08{`S02KfgKnFktIe(EH4Zb+*-|U@|Ct1pF zY{&CF;~9^=A|j1U7{6rVmf#c3UuwK42cyzrMb%VkX%v8bO=$^YiBA<;6RrXaU-=v$Nyv zhj+|6vp=L6hTO)GRZ0u;RQ&PrF-zziGI(Erh_r@RS65!48CZ(Yi^%Y;C6GKS0e!-w z2}egqtvQquyssP|ANOiq1_^Nu5K!a({=V7T+NvsaUqSWJ3axpG~ zif9e6@jFNzuvxHv%sS7;o+Sl(5`2Nz5Juk(npIp54i5hM-$szJ`0offJ3H&1Z*OnK zxYX`z$sSdh0C;aAL+ICEQ>rm{nYy3ufL3-0tiwFaxuh>RnW+yT89LwNQ-! z*ITggt*x!e=H})P;Vm!+-chKl$-s1Kp&9|t&(Ga6wvAvRaRY)=SG!3a?36||0vNPj z;qm<;ZjL(CwV)48W@%J)gQ&G$#m&ZP&{w+wk@XZcQI!Bx{_yayvuA`KTF`V_%!bFQ z;dUsZ35bon+;sPlK)OFnC?wQQiT*UA3Hbj0j{dlB1Ld~Y0*CGpb-k3JDVhNNkx=)f z1%*HsI(CC5iP1)W*gbva5|C;xQIV6I5emt|=%mF^=2*X@O^vZgZX^iHS__Er7a=sL z(eFa+U%OStl%fGiUf|*3p?fA&U4*{KkDVX_5cKdI(#D1MC^^AWwA$#rV5sVm#ALI= zCaAAI@5%U5CnTj#eT|Isfuu%1Qq!4v`J|#V!i*)Oue64)7L0kK>&|}WAx!!}v=*>x z*FF@X@D1%%(1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A zW;eIa9I*VY*K3kOOaKfX`vG4_i4aYIguoFP2-XCE7U5qeE`t;};^}d2bSM@5%NRI{3b?X) b!3*#QSrWw``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eBZn>w6V@L(#+c^&d9~%g?9zFY)-Kv4_1;Yvk zAl1ONfcZtkLM9JZPc08Ck08fMTs2j4Hj9H(&UJ=Y%|2ac{7cX|$MgKX*xWU?Mdw1# zE%bjW|ws+sYusEO4w7ZqPXLQeYSgi{ z$2jfn?7nUL9(%x4PEKx)Sl^xR$p?%S>mV zEQpPX3Hkp0yYw<9zu;F<=g*&)e!hR_&XwzX?I!pJ{p(I>__uMroxQ#F?VqPldvAOl z9~)b`>sgA?%HJLP#7eIH^y_ovX+NALF2QtU&;I?>1(eQr?!Eg~^mMks0>CgFGqQw_gkK{(rOy`Jv>eu!`_u0F5 z>n@iYZU|c0v2LR8sq%!LELH~|*(QyQ+3&M`jvbvSb8JNzgHDRm2DTgDWM(ML;P6y5 z=rkzYJ){4}GN=72&wWg|oLB@mo#t08nBed4UwZgwUw?nBe8Ik>Ne|0Z`>K`*wF@+&$Zpx;(_2zwFYqgv~(SN|+W2SX{$yqEKGp8jimv;)8 zvEWiBXW1{sBS3YcOjG>4H(cgd%&Ku%xuvD;i*v^+jTZu!g`P1(Q)<@gr5@|LOv8Nw zH68jwH!i!H-(e*@B|CIY=2z(?yM`Vs#-g=drfch*kJLEajy|&c&DW`MqTeI`E@NuE zGOsZib-ev`%&(;L6N6M# z^vxEYL}v-c0RsJ9swRu=YG3es`|vt+V_c?<%A n_xujn7=Hvar(-Jsp7B3AGw~vaqml@)NMi7G^>bP0l+XkKkc%v? literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/ayu/ui/ayu_styles.style b/Telegram/SourceFiles/ayu/ui/ayu_styles.style index e55d1df8b..719086b53 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_styles.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_styles.style @@ -10,6 +10,7 @@ using "ui/basic.style"; using "ui/colors.palette"; using "ui/widgets/widgets.style"; +using "info/info.style"; iconPreviewStroke: activeButtonBg; @@ -25,3 +26,33 @@ cpIconSize: 64px; recentStickersLimitPadding: margins(22px, 4px, 22px, 8px); imageViewPadding: margins(22px, 10px, 22px, 10px); imageViewInnerPadding: margins(16px, 16px, 16px, 16px); + +topBarAdmins: IconButton { + width: 40px; + height: topBarHeight; + + icon: icon {{ "ayu/top_bar_admins", menuIconFg }}; + iconOver: icon {{ "ayu/top_bar_admins", menuIconFgOver }}; + iconPosition: point(4px, 11px); + + rippleAreaPosition: point(0px, 7px); + rippleAreaSize: 40px; + ripple: RippleAnimation(defaultRippleAnimation) { + color: windowBgOver; + } +} + +topBarRecentActions: IconButton { + width: 40px; + height: topBarHeight; + + icon: icon {{ "ayu/top_bar_recent_actions", menuIconFg }}; + iconOver: icon {{ "ayu/top_bar_recent_actions", menuIconFgOver }}; + iconPosition: point(4px, 11px); + + rippleAreaPosition: point(0px, 7px); + rippleAreaSize: 40px; + ripple: RippleAnimation(defaultRippleAnimation) { + color: windowBgOver; + } +} diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 1408ce523..b72ca7adc 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -69,7 +69,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // AyuGram includes #include "ayu/ayu_settings.h" +#include "boxes/peers/edit_participants_box.h" #include "data/data_chat_filters.h" +#include "history/admin_log/history_admin_log_section.h" +#include "styles/style_ayu_styles.h" namespace HistoryView { @@ -127,6 +130,8 @@ TopBarWidget::TopBarWidget( , _search(this, st::topBarSearch) , _infoToggle(this, st::topBarInfo) , _menuToggle(this, st::topBarMenuToggle) +, _recentActions(this, st::topBarRecentActions) +, _admins(this, st::topBarAdmins) , _titlePeerText(st::windowMinWidth / 3) , _onlineUpdater([=] { updateOnlineDisplay(); }) { setAttribute(Qt::WA_OpaquePaintEvent); @@ -149,6 +154,21 @@ TopBarWidget::TopBarWidget( _groupCall->setClickedCallback([=] { groupCall(); }); _menuToggle->setClickedCallback([=] { showPeerMenu(); }); _infoToggle->setClickedCallback([=] { toggleInfoSection(); }); + + _recentActions->setClickedCallback([=] + { + const auto channel = _activeChat.key.peer()->asChannel(); + _controller->showSection(std::make_shared(channel)); + }); + _admins->setClickedCallback([=] + { + ParticipantsBoxController::Start( + controller, + _activeChat.key.peer(), + ParticipantsBoxController::Role::Admins + ); + }); + _back->setAcceptBoth(); _back->addClickHandler([=](Qt::MouseButton) { InvokeQueued(_back.data(), [=] { backClicked(); }); @@ -1071,6 +1091,16 @@ void TopBarWidget::updateControlsGeometry() { _groupCall->moveToRight(_rightTaken, otherButtonsTop); _rightTaken += _call->width(); } + + _recentActions->moveToRight(_rightTaken, otherButtonsTop); + if (!_recentActions->isHidden()) { + _rightTaken += _recentActions->width(); + } + _admins->moveToRight(_rightTaken, otherButtonsTop); + if (!_admins->isHidden()) { + _rightTaken += _admins->width(); + } + _search->moveToRight(_rightTaken, otherButtonsTop); if (!_search->isHidden()) { _rightTaken += _search->width() + st::topBarCallSkip; @@ -1180,6 +1210,39 @@ void TopBarWidget::updateControlsVisibility() { && !isOneColumn && _controller->canShowThirdSection() && !_chooseForReportReason); + + const auto showRecentActions = [&] + { + if (_activeChat.section == Section::ChatsList) { + return false; + } + if (const auto peer = _activeChat.key.peer()) { + if (peer->isMegagroup() || peer->isChannel()) { + const auto channel = peer->asChannel(); + return channel->hasAdminRights() || channel->amCreator(); + } + } + return false; + }(); + _recentActions->setVisible(showRecentActions); + const auto showAdmins = [&] + { + if (_activeChat.section == Section::ChatsList) { + return false; + } + if (const auto peer = _activeChat.key.peer()) { + if (peer->isMegagroup()) { + return true; + } + if (peer->isChannel()) { + const auto channel = peer->asChannel(); + return channel->hasAdminRights() || channel->amCreator(); + } + } + return false; + }(); + _admins->setVisible(showAdmins); + const auto callsEnabled = [&] { if (const auto peer = _activeChat.key.peer()) { if (const auto user = peer->asUser()) { diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h index d4cb8b2d6..fc8045868 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -232,6 +232,8 @@ private: object_ptr _search; object_ptr _infoToggle; object_ptr _menuToggle; + object_ptr _recentActions; + object_ptr _admins; base::unique_qptr _menu; object_ptr _membersShowArea = { nullptr };