From 388541a3fb90c3147fc3dcbbf28df23fbe70a8f2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 25 Feb 2023 16:17:48 +0400 Subject: [PATCH] Show a new "Battery and Animations" settings item. --- Telegram/Resources/icons/menu/chat_bubble.png | Bin 0 -> 661 bytes .../Resources/icons/menu/chat_bubble@2x.png | Bin 0 -> 1247 bytes .../Resources/icons/menu/chat_bubble@3x.png | Bin 0 -> 1854 bytes Telegram/Resources/icons/menu/emoji.png | Bin 0 -> 575 bytes Telegram/Resources/icons/menu/emoji@2x.png | Bin 0 -> 1218 bytes Telegram/Resources/icons/menu/emoji@3x.png | Bin 0 -> 1849 bytes Telegram/Resources/icons/menu/phone.png | Bin 0 -> 676 bytes Telegram/Resources/icons/menu/phone@2x.png | Bin 0 -> 1291 bytes Telegram/Resources/icons/menu/phone@3x.png | Bin 0 -> 1914 bytes Telegram/Resources/icons/settings/battery.png | Bin 0 -> 353 bytes .../Resources/icons/settings/battery@2x.png | Bin 0 -> 574 bytes .../Resources/icons/settings/battery@3x.png | Bin 0 -> 884 bytes Telegram/Resources/langs/lang.strings | 6 +- .../boxes/peers/edit_participant_box.cpp | 4 +- .../boxes/peers/edit_peer_permissions_box.cpp | 135 +++++++++--------- .../boxes/peers/edit_peer_permissions_box.h | 55 ++++--- Telegram/SourceFiles/settings/settings.style | 11 ++ .../settings/settings_advanced.cpp | 2 +- .../SourceFiles/settings/settings_common.cpp | 9 +- .../SourceFiles/settings/settings_common.h | 1 + .../SourceFiles/settings/settings_main.cpp | 17 ++- .../settings/settings_power_saving.cpp | 75 ++++++++-- .../settings/settings_power_saving.h | 18 +-- Telegram/SourceFiles/ui/menu_icons.style | 3 + 24 files changed, 220 insertions(+), 116 deletions(-) create mode 100644 Telegram/Resources/icons/menu/chat_bubble.png create mode 100644 Telegram/Resources/icons/menu/chat_bubble@2x.png create mode 100644 Telegram/Resources/icons/menu/chat_bubble@3x.png create mode 100644 Telegram/Resources/icons/menu/emoji.png create mode 100644 Telegram/Resources/icons/menu/emoji@2x.png create mode 100644 Telegram/Resources/icons/menu/emoji@3x.png create mode 100644 Telegram/Resources/icons/menu/phone.png create mode 100644 Telegram/Resources/icons/menu/phone@2x.png create mode 100644 Telegram/Resources/icons/menu/phone@3x.png create mode 100644 Telegram/Resources/icons/settings/battery.png create mode 100644 Telegram/Resources/icons/settings/battery@2x.png create mode 100644 Telegram/Resources/icons/settings/battery@3x.png diff --git a/Telegram/Resources/icons/menu/chat_bubble.png b/Telegram/Resources/icons/menu/chat_bubble.png new file mode 100644 index 0000000000000000000000000000000000000000..a22bd585d88f6da0d3ab22926848bb8145db8cc7 GIT binary patch literal 661 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlgf?7ydrV~B;| z(~!NZ9TO$?waS#nbkTkrmX|9a9!2R()35`64Wi*^RBY)K4S8L}|o zfPlZk30sx!0oxG;Rv zO`UlyUEiu~`P!S8*DpMnAh7Q9mhc@h?=noh)F$umOE}}8z|i`=!bYO6;n&|f4H2c7 zBMo7CV%_bB55E4YB$Bx-AxSZKgZ7J(UFV-SXWq)&KKUfeEv9AiZaxbGo_wxsK4>u4 zPf+nvM5>YG^2?DcLt^yA-z=!Gsk53p#Y=U{&yD?3y=;N`E*&Mx83s4(eAI-^_Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91FrWhf1ONa40RR91FaQ7m0NXcg3;+NGNl8ROR9Fe^SV<^$Q5gOVnTI6v zut8)2Yu#hMzu@GTtC?!KFk|+^bAoCClGS9>RiP0-;LYb+pVoF#A9S+WNvP5XJ_Z`?v4-G+uJKFEJQe&Y{`R@l9DhMoTcgM z>57Vq@bGXWBjKPM8yiPQM^{%@&(F_u`0ed&RLYxCf-o^Lsi~=Xd3k~Q>+9>_;9x{V zgc2e!m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/Telegram/Resources/icons/menu/emoji.png new file mode 100644 index 0000000000000000000000000000000000000000..0820c4c24b7acb83a96f04995889008cac2048d3 GIT binary patch literal 575 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlgfY^A4*V~B;| z*(thxhXMqSFT5F2*wDscYN5B`C8t9%D-RP3dj>0C^O{wzLU{+=1y(y0Hnue=C>{*F z{ElBPGcEpQ8td%4>Iu*6|Iaj!uWdb4Z+&!63(w(-{qu`<@;ooFsJY`WbG%Z|DsNWW z{`>ZF{nuZYZjJJN$IdvlV1~jAyU4v!YxB0>{#$qdWr^3)Nh%ANl5XXgU0C8d-LUw1 zj@e}=4>>iC3q{Ej4R$&#vc6=j?cCrNcRqVb#if60;*x?=DKRP)lXtefyTo*N!g}Xr z4z{(&3njXI)H#?Y>5Iw#ZfxM1;nvo}-KSY3%+}1vJnaI|nn_E-R%;3{iUt%F91K*< zf7QQsahm6++Wi+ZS`t?{w7e|Yb^EOfyZF|14gC(6)}&l7HQjJGFS{c|e)6*1sa~#9 zI;SVCnq(>V5Y4XVFfX{^MV(YtSP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91FrWhf1ONa40RR91FaQ7m0NXcg3;+NGEJ;K`R9Fe^m^&|RQ4q%u5kZL3 zBZo>vMd%a~BE++$Rrml3p%jUTMnWMHK`Ek9sg=IKDM%DTJQL#m=HA~i_pGz_W9`S; z+$*_uan9^n|M}1Cwbq`QwPUfL>t_a{%|KQ(^Q3iQVPScBIl|G=(e3SRbi&XK`T6<1 zy}e6IOWWJq*Vos-w2NDm3;_TZnmVjOb#?X1%F5l{ofd;p1O^zBP+o#AS!rqM*x1gr0S;^yXNYHF&Xp~1@_76SkbuvlRZiML76(UFmnx3@QVUtV73=H^ODN`hL( zVt_Hh5OYYN3U2F;Tv%9;M`VF~XT_c3W416C9tce^fBop_sIY8pZLx>^4a^A4ArZC= z=ZPhkm4YZQFVE~N=m;bd6SSfC6AvW2n5m99H+sBK$=X34j&^>2p6O*XX1s6oICL38 z+2gp-^J8 zPft(rc-%UeyhF*5U;sM-qQM0i+?fD>^fV9PJYIpz%S&;_Z(m=ZldiwNUjYC+0iux? z8Fw~7w(VY8Eo!(;uWlb69$aOmyuZI!vJO^C5yXYK(}yep(fbt@6)`OBgpO14>guY< zXJ==do103n1e6TPtpcl2C5Q{$;Z!N@0*OIpyScg9K9;)A&CQ*hoWxUYZEZ?t|F5g7 z0{{%LeJpj43-RTZje-P}B8>WP3dpi#YNeb@8`ZzVUb#?C1!4(^GXpu40Xk6!!zU}m z1@3GI6-z+)lz8cjP5#^3+SJ3DFro(r*n|-mw&`&Jdnd-Ot}b@s#l=N^eZ7mZree#V zpPvKn?CjLkX)$PG^e!DWH8qcqj}lXRdwZJRDm67VQ96JD#>6_9ybDn}e2Z&GM+fN+ zXIyJ*Ypt!V+1crJZ)|K_US58Ge`oah`PtMNhA6It@7sRx#_sLyeT0?9Hi z{Selb0UHd?lo?x3dH?_b07*qoM6N<$f;OKY^Z)<= literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/menu/emoji@3x.png b/Telegram/Resources/icons/menu/emoji@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..d2251e543cb25e4cddae1501a47376f8ebdd90ed GIT binary patch literal 1849 zcmV-92gdk`P)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91NT34%1ONa40RR91NB{r;0FW_8?*IS>qe(e5o6k#CTNKBAreRoU znm-^X1^TK{Ac9GjfuJ}y$-oG5W{BX}fjHEG=pSG~fuqVn7KAj>5=E3(*b@suokdo! zBJxLlp8K&_=bU}+J>GNfeP#CyE_<)Netg$HXYalC+WTf?q@Q#Tq8yc$dRh5sy}z1va&L&JlOhY_gPz8`+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png b/Telegram/Resources/icons/menu/phone@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..920fc33b49ae51d0fdde26ce4d0cbd402326051a GIT binary patch literal 1291 zcmV+m1@!ufP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91FrWhf1ONa40RR91FaQ7m0NXcg3;+NGbxA})R9Fe^SV<^-VH7vZtWf41 z8}k%JGL&IK#@KnWVr9riEU>U)BV!h_kx-;ak&%Q;a z=Xv+4f4#f7oqN7>&hNbQopZkPJu@@YV~T(&0_sMz z_xJZ>*C>Fer)ODN+4c1`mTqrvv6Xa5T_PhRgM`A{+gleYGBWb@^%VjQ4Gp@hs&EPm z3yDKEHa1*<;o)Hjtgo+gSB+#^$mk=rxvPtdi{OWZgjiU}sdIJpGC3AcPELp#n?S4~ zQu)@_*2pTBuLv#YkW|{zR^;#RuZR<@5spJ=XJ;=jFAzdkWJM|c+YWtxer{}R06r!r zhC0C#H#aws0ms9`gXJqib0P%0tE;Pc$Hm2wLqmk*>gsA~X$dBAOSEd_C*Ps@`FYqy zABvBU*9FMW&nL{y%}w1^RX7d~4oD+3o1UH?5rDh9``z6gmbSOIx$zUpEA}}#ISEu8 z5h!ogXjfMk_}Hw(#6*^_I$cy$1YkVb+1V5KNu*G@d&!FhH z-SP49#>U2gfB>T$g0h#F7s?8Dfe{fA!J11>PDaNfz?f^%BXHP}@}%B~2(*%ki3wCO zYsX+3*RjXPN0>f6Jq-&BWA#!0xUcD=;yQ&36Yd2`Nl6tI6&)QNb8~aV2!x^H=;+AW zF__NE$|41iIOXQ%vifLLrKP1bRM?$_galTA(x^(Be6_W;l>b8_Cntww2EtxnUoWzP zv!%Vgy{)ay&dyG>B>F@$AxMXZhh(%8ts3@;!Z|oNAR9C^H00vqVwnD4X?pt$3=I5% zx>yCn>%zhU@dlo?MMdGJ3wQ*T%*POb zij+ZR_&7R{q$s_IhX>X(E{!13F-sYE87sINq^72}w6x63%#d3O>l2za4nb}QlKYQQ z2G7tX9EJGn0uRnFw27sqC4|sWBPMxM1pdzm`~ltt_Ceq`bF=^e002ovPDHLkV1f~r BO9ub| literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/menu/phone@3x.png b/Telegram/Resources/icons/menu/phone@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..853e7e11ace4bbb1f5af6442447537ccef0c726a GIT binary patch literal 1914 zcmV-=2Zi{FP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91NT34%1ONa40RR91NB{r;0FW_8?*IS>e5T3bj}O%%>Fvx}Nq zl2j_9WYR-r7bUxZl;Mk4R3uSCA574fFw^KkvXQ_Ccb_9M#)7ctXQ!kJw3g%vvX!<=8x$2_3PKFs;b!7 zSW8RG#iW>*m)G;>&qeA;Wc2m*ZQs6qap<;c)vDg!UI`@(WKB&?9XWDD3%Xg!lSoNP z@$vCtm>)lW+_`h-)vH%OfBvLe>({T}wr$()-Mg{Hh%5rS<94r^LiWYArfCn&br$<>FJLjKQbO0H*PeB(CgQ)8Ep0H z)mX{KR524qPBC;jI5@~UHd3)SZ{845S65e()fddD*rrXJ)Ypf4R8Z{g+qVq5ZrwUN zJ3FdoNFY1_nx3(zPoI(wJ9q9R*^sbkmSRUo2kBspVlekGIjo9{iwo6NUr<2>B{iHKBTQk8p`0!SEQgAI&Nuc zVclbC`TF|GQwa?XrHOj*;DJ1NflJ}el53ltoh`%0$;kzA9Gn+$m2i{Rsr zjg2w7*m5$2%F4=U2#Sh|WRO}Z0!w1-?d>f|Yu~F88wu&GGOK|PlHO6es znl&*oF&s>4I4H4!|KqXL$np4VPH>-De;EfM=WYX>A$&-?dj~+dW zml}fM3F_3TQ_Geu6N0yH-HPA}VI&2FQl30{a_Q0~HJ&?;9Xlo@k(87qq)Re}fG(g6 zj|suS008CzrUlQ1!gdtp=H_P1A+>K7;o`-M!~=dwWMrgdH*43fg)c%#Cg6#%tE-F4 z92ptG<3>Y61KxM&%;Ydg!e|8q1W5K}noJl8>;&o^F;qgtim;fV$ z+o~{LgcZAG%a(|Uh%;x-l$Mqv8Y`^w;ll^9halPYKW3tPJPT5ncyl>%;)J2LcI?<8 zo+WHNL{r4hC)WsuCM+yWc#2}naTpUPaYi*ZHj-`-^7He#s||IDeU+M;igz4_$3)>3 zn@SZ0Pft(sNb%4G`>a@HUI09+mzS3db;DMX2?pES+n+mk4r`3Fkj9XJm7K1F?=OD=X(xbskuFy+R8CQwhsS;o*5S{8v@7 zu@tEOtJqA5{rmR|BLx^*#DZYlOxWGcn>X2v;r3+0W|f;lXaLR;>zn@T>+4PR=zjkE zd1}_|_JdOwTMl=#@$qqDzyw4P6yE^2ro_qHw{Nr7aJnd-6XNP7$bn%LMuA94*i3vd z2V44YeUOhvujK#M&U|YH1qH!dC#^`pX@(OI4^)N@J;{!flar|hO+;2gLPF@{EMmq4 zXoyG=zUNWAv%&59{{1^u_xJagR9@{&xPnlxuC5MygUE3Lu5GoowK+LCxIG*`d>COr zoaVU8;&yZ8$`xTn>@>9%Q0&j$-90xqmpc_W4ds*g?o(}hsHhbIU^($gAT$(y6)3L{ zD{XIYN7S9#(X@cwg_u`fULFi4j$K3Q;kJ^Ik)def=k^u1Y6F9<2t9G#!nCj-^!)PW zOKWQ@zC*)}TQw$nNBRipBcP9fJ_7m(EW`->2bWQ7KPRUcy#N3J07*qoM6N<$g7f5t A0ssI2 literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/settings/battery.png b/Telegram/Resources/icons/settings/battery.png new file mode 100644 index 0000000000000000000000000000000000000000..4287599be3066711a9b4fd596f0d9c3588ed3d59 GIT binary patch literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlfUo%VEb46zV= zJIRo*MM1#zsJ2JaBSsyIhO(F=FH|*iY#T*4F8au1W+rm%?)(V?Mw?EjZNBQZ>fz`A z&gmyMRo|8UAe%AEExUH!^T$UI3G!_C>9MEbrI*CCl->CNxDS<3|2WurG-Qdk-?@A*0PrCYAm zaTaY{q|qX9dt0l>l^qZ6uAg{N|8!93)m`gaCgqt)?l)}H=$j$;|GZpE4a@dl%VjH= X)Gn0H*M2LR4Dz0*tDnm{r-UW|?rwgE literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/settings/battery@2x.png b/Telegram/Resources/icons/settings/battery@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b454099496059882363c1690b3ca6ce735973e0f GIT binary patch literal 574 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1SD@H=XCICV>L+R3@>qV*2>$*IZR`xARQIp=cPA4s1gyHrJq*OqtVMuTZm@8j;I zs3zt!OgwV>Y}ny5d(8W{=iCVE7PmgYw}JT$1CaVt&VK9dw;H?tMK6kW*4S@lV3AQ- zux?AUX zu`IImy?iw*^ydY^JsNY*KYv)DalgWBcJ1BkdE1p67R8%5Om3OZ#Su4U+2xg!j+*!~ z%@AdoKZR$%8fV=3&r=L!{;7C!Bm_5=#Qxv2e$AS^?Yr;4=QPzwW!+nG`bfg*O-Fcq zFPqKgUF*h`^<**I@3&>Izg9U3m~9N`6`AsNt5b{x1H0D+-RY+frCkh2tl78q!}W(2 zd;!~Xr-uapc>Uu<_ldMe7U%4qJwE) literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/settings/battery@3x.png b/Telegram/Resources/icons/settings/battery@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..2c1fe9a28d94ff781650ac8c5baa9caffe121762 GIT binary patch literal 884 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1SD_us|Wxo#^NA%Cx&(BWL^R}E~ycoX}-P; zT0k}j17mw80}DtA5K93u0|WB{Mh0de%?J`(zyz1|Sip>6gA`6MbbHUhz;w^k#W5s< z^=+i%YQsd4eRe-ZHZ968EuW+j?fs7-GCCrnL-+rIL;N4OTh^qiYNje{FI|(PVJ2oK z)VlBe%9r!*)g+(UbLP(Mb2@qb<>xBT70p5fRhq>(aly4mctAzHHi?!vbM7rH1;aSptETYLIxt*^duPJzYJhZ7>o z*1D_@xN>Lakqg~lRX*gHWp9lV>eR@6j+ylQ^X#=kHXeo>H>SU9y#CsB zqKCtryLt9={jRL_Yq+Flwk)_MD`II-;1t$o$EywP-S!(dUd(9WUaH}}{4#%a0I$K7 z8~V-{iw^F-t2g;%g2>b_9x6)5lQm9v9V^;-r)sZS$|CYw)e@+@q6xj@@Y|}eq8n33JspU7as*T zNPKPhTh}lB;Q!Y2&?@$8&Jj$5NdzrH*;#qZ$#;?D~{wK_GLXfBA*xfJ=g!DGsl_j~SY za|Nvw$z(ck{PfdB`{lb-Cdq$naN~cJY$Dbz%g25xiz6U;J$qY;#=*xQXOyroHNGv= zc3iYXpkFTGSHA0=3!<`h`{mCk{kf`q`jted_}K~@zNvcCvyEnY#A~a}`n^c=qgTJa z#JwZC?!GgQRlNSadminRights() : ~Flag(0))); const auto disabledMessages = [&] { - auto result = std::map(); + auto result = base::flat_map(); if (!canSave()) { result.emplace( ~Flags(0), @@ -725,7 +725,7 @@ void EditRestrictedBox::prepare() { ? (Flag::ChangeInfo | Flag::PinMessages) : Flags(0))); const auto disabledMessages = [&] { - auto result = std::map(); + auto result = base::flat_map(); if (!canSave()) { result.emplace( ~Flags(0), diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 421d3eb12..a32758489 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -48,18 +48,12 @@ constexpr auto kSuggestGigagroupThreshold = 199000; return {}; } -struct NestedRestrictionLabels { - std::optional> nestedLabel; - std::vector restrictionLabels; -}; - [[nodiscard]] auto NestedRestrictionLabelsList( Data::RestrictionsSetOptions options) { using Flag = ChatRestriction; auto first = std::vector{ { Flag::SendOther, tr::lng_rights_chat_send_text(tr::now) }, - // { Flag::SendMedia, tr::lng_rights_chat_send_media(tr::now) }, }; auto inner = std::vector{ { Flag::SendPhotos, tr::lng_rights_chat_photos(tr::now) }, @@ -89,7 +83,7 @@ struct NestedRestrictionLabels { &RestrictionLabel::flags), end(second)); } - return std::vector{ + return std::vector>{ { std::nullopt, std::move(first) }, { tr::lng_rights_chat_send_media(), std::move(inner) }, { std::nullopt, std::move(second) }, @@ -267,19 +261,24 @@ ChatRestrictions DisabledByAdminRights(not_null peer) { not_null AddInnerToggle( not_null container, + const style::SettingsButton &st, std::vector> innerCheckViews, not_null*> wrap, rpl::producer buttonLabel, - std::optional locked) { - const auto &stButton = st::rightsButton; + std::optional locked, + Settings::IconDescriptor &&icon) { const auto button = container->add(object_ptr( container, nullptr, - stButton)); + st)); + if (icon) { + Settings::AddButtonIcon(button, st, std::move(icon)); + } + const auto toggleButton = Ui::CreateChild( container.get(), nullptr, - stButton); + st); struct State final { State(const style::Toggle &st, Fn c) @@ -291,7 +290,7 @@ not_null AddInnerToggle( std::vector> innerChecks; }; const auto state = button->lifetime().make_state( - stButton.toggle, + st.toggle, [=] { toggleButton->update(); }); state->innerChecks = std::move(innerCheckViews); const auto countChecked = [=] { @@ -309,12 +308,12 @@ not_null AddInnerToggle( { const auto separator = Ui::CreateChild(container.get()); separator->paintRequest( - ) | rpl::start_with_next([=, bg = stButton.textBgOver] { + ) | rpl::start_with_next([=, bg = st.textBgOver] { auto p = QPainter(separator); p.fillRect(separator->rect(), bg); }, separator->lifetime()); - const auto separatorHeight = 2 * stButton.toggle.border - + stButton.toggle.diameter; + const auto separatorHeight = 2 * st.toggle.border + + st.toggle.diameter; button->geometryValue( ) | rpl::start_with_next([=](const QRect &r) { const auto w = st::rightsButtonToggleWidth; @@ -341,7 +340,7 @@ not_null AddInnerToggle( toggleButton->sizeValue( ) | rpl::start_with_next([=](const QSize &s) { checkWidget->moveToRight( - stButton.toggleSkip, + st.toggleSkip, (s.height() - checkWidget->height()) / 2); }, toggleButton->lifetime()); } @@ -392,8 +391,8 @@ not_null AddInnerToggle( }, arrow->lifetime()); } button->sizeValue( - ) | rpl::start_with_next([=](const QSize &s) { - const auto labelLeft = stButton.padding.left(); + ) | rpl::start_with_next([=, &st](const QSize &s) { + const auto labelLeft = st.padding.left(); const auto labelRight = s.width() - toggleButton->width(); label->resizeToWidth(labelRight - labelLeft - arrow->width()); @@ -446,22 +445,18 @@ not_null AddInnerToggle( return button; } -template < - typename Flags, - typename DisabledMessagePairs, - typename FlagLabelPairs> -[[nodiscard]] EditFlagsControl CreateEditFlags( +template +[[nodiscard]] EditFlagsControl CreateEditFlags( not_null container, - rpl::producer header, Flags checked, - const DisabledMessagePairs &disabledMessagePairs, - const FlagLabelPairs &flagLabelPairsNested) { + EditFlagsDescriptor &&descriptor) { struct State final { std::map> checkViews; rpl::event_stream<> anyChanges; }; const auto state = container->lifetime().make_state(); + const auto &st = descriptor.st ? *descriptor.st : st::rightsButton; const auto value = [=] { auto result = Flags(0); for (const auto &[flags, checkView] : state->checkViews) { @@ -478,23 +473,23 @@ template < ApplyDependencies(state->checkViews, dependencies, view); }; - if (header) { + if (descriptor.header) { container->add( object_ptr( container, - std::move(header), + std::move(descriptor.header), st::rightsHeaderLabel), st::rightsHeaderMargin); } const auto addCheckbox = [&]( not_null verticalLayout, bool isInner, - Flags flags, - const QString &text) { + const EditFlagsLabel &entry) { + const auto flags = entry.flags; const auto lockedIt = ranges::find_if( - disabledMessagePairs, + descriptor.disabledMessages, [&](const auto &pair) { return (pair.first & flags) != 0; }); - const auto locked = (lockedIt != end(disabledMessagePairs)) + const auto locked = (lockedIt != end(descriptor.disabledMessages)) ? std::make_optional(lockedIt->second) : std::nullopt; const auto toggled = ((checked & flags) != 0); @@ -504,10 +499,10 @@ template < const auto checkbox = verticalLayout->add( object_ptr( verticalLayout, - text, + entry.label, toggled, st::settingsCheckbox), - st::rightsButton.padding); + st.padding); const auto button = Ui::CreateChild( verticalLayout.get(), st::defaultRippleAnimation); @@ -530,13 +525,14 @@ template < } else { const auto button = Settings::AddButton( verticalLayout, - rpl::single(text), - st::rightsButton); + rpl::single(entry.label), + st, + { entry.icon }); const auto toggle = Ui::CreateChild( button.get()); auto &lifetime = toggle->lifetime(); const auto checkView = lifetime.make_state( - st::rightsButton.toggle, + st.toggle, toggled, [=] { toggle->update(); }); toggle->resize(checkView->getSize()); @@ -548,7 +544,7 @@ template < button->sizeValue( ) | rpl::start_with_next([=](const QSize &s) { toggle->moveToRight( - st::rightsButton.toggleSkip, + st.toggleSkip, (s.height() - toggle->height()) / 2); }, toggle->lifetime()); button->setClickedCallback([=] { @@ -581,8 +577,10 @@ template < return checkView; }; - for (const auto &[nestedLabel, flagLabelPairs] : flagLabelPairsNested) { - const auto isInner = nestedLabel.has_value(); + for (const auto &nestedWithLabel : descriptor.labels) { + Assert(!nestedWithLabel.nested.empty()); + + const auto isInner = nestedWithLabel.nestingLabel.has_value(); auto wrap = isInner ? object_ptr>( container, @@ -590,8 +588,8 @@ template < : object_ptr>{ nullptr }; const auto verticalLayout = wrap ? wrap->entity() : container.get(); auto innerChecks = std::vector>(); - for (const auto &[flags, label] : flagLabelPairs) { - const auto c = addCheckbox(verticalLayout, isInner, flags, label); + for (const auto &entry : nestedWithLabel.nested) { + const auto c = addCheckbox(verticalLayout, isInner, entry); if (isInner) { innerChecks.push_back(c); } @@ -601,10 +599,12 @@ template < raw->hide(anim::type::instant); AddInnerToggle( container, + st, innerChecks, raw, - *nestedLabel, - std::nullopt); + *nestedWithLabel.nestingLabel, + std::nullopt, + { nestedWithLabel.nested.front().icon }); container->add(std::move(wrap)); container->widthValue( ) | rpl::start_with_next([=](int w) { @@ -857,10 +857,10 @@ void ShowEditPeerPermissionsBox( Unexpected("User in EditPeerPermissionsBox."); }()); const auto disabledMessages = [&] { - auto result = std::map(); - result.emplace( - disabledByAdminRights, - tr::lng_rights_permission_cant_edit(tr::now)); + auto result = base::flat_map(); + result.emplace( + disabledByAdminRights, + tr::lng_rights_permission_cant_edit(tr::now)); if (const auto channel = peer->asChannel()) { if (channel->isPublic() || (channel->isMegagroup() && channel->linkedChat())) { @@ -1026,19 +1026,21 @@ std::vector AdminRightLabels( } } -EditFlagsControl CreateEditRestrictions( +EditFlagsControl CreateEditRestrictions( QWidget *parent, rpl::producer header, ChatRestrictions restrictions, - std::map disabledMessages, + base::flat_map disabledMessages, Data::RestrictionsSetOptions options) { auto widget = object_ptr(parent); auto result = CreateEditFlags( widget.data(), - header, NegateRestrictions(restrictions), - disabledMessages, - NestedRestrictionLabelsList(options)); + { + .header = std::move(header), + .labels = NestedRestrictionLabelsList(options), + .disabledMessages = std::move(disabledMessages), + }); result.widget = std::move(widget); result.value = [original = std::move(result.value)]{ return NegateRestrictions(original()); @@ -1050,22 +1052,21 @@ EditFlagsControl CreateEditRestrictions( return result; } -EditFlagsControl CreateEditAdminRights( +EditFlagsControl CreateEditAdminRights( QWidget *parent, rpl::producer header, ChatAdminRights rights, - std::map disabledMessages, + base::flat_map disabledMessages, Data::AdminRightsSetOptions options) { - using String = std::optional>; - using Labels = std::pair>; - auto widget = object_ptr(parent); auto result = CreateEditFlags( widget.data(), - header, rights, - disabledMessages, - std::vector{ { std::nullopt, AdminRightLabels(options) } }); + { + .header = std::move(header), + .labels = { { std::nullopt, AdminRightLabels(options) } }, + .disabledMessages = std::move(disabledMessages), + }); result.widget = std::move(widget); return result; @@ -1130,24 +1131,22 @@ ChatRestrictions FixDependentRestrictions(ChatRestrictions restrictions) { ChatAdminRights AdminRightsForOwnershipTransfer( Data::AdminRightsSetOptions options) { auto result = ChatAdminRights(); - for (const auto &[flag, label] : AdminRightLabels(options)) { - if (!(flag & ChatAdminRight::Anonymous)) { - result |= flag; + for (const auto &entry : AdminRightLabels(options)) { + if (!(entry.flags & ChatAdminRight::Anonymous)) { + result |= entry.flags; } } return result; } -EditFlagsControl CreateEditPowerSaving( +EditFlagsControl CreateEditPowerSaving( QWidget *parent, PowerSaving::Flags flags) { auto widget = object_ptr(parent); auto result = CreateEditFlags( widget.data(), - nullptr, flags, - std::map{}, - Settings::PowerSavingLabelsList()); + Settings::PowerSavingLabels()); result.widget = std::move(widget); return result; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h index 75d806dea..0cc1d0ed8 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat_participant_status.h" +namespace style { +struct SettingsButton; +} // namespace style + namespace Ui { class GenericBox; class RoundButton; @@ -44,42 +48,57 @@ void ShowEditPeerPermissionsBox( not_null channel, not_null controller); -struct RestrictionLabel { - ChatRestrictions flags; +template +struct EditFlagsLabel { + Flags flags; QString label; + const style::icon *icon = nullptr; }; -[[nodiscard]] std::vector RestrictionLabels( - Data::RestrictionsSetOptions options); -struct AdminRightLabel { - ChatAdminRights flags; - QString label; -}; -[[nodiscard]] std::vector AdminRightLabels( - Data::AdminRightsSetOptions options); - -template +template struct EditFlagsControl { - object_ptr widget; + object_ptr widget; Fn value; rpl::producer changes; }; +template +struct NestedEditFlagsLabels { + std::optional> nestingLabel; + std::vector> nested; +}; + +template +struct EditFlagsDescriptor { + rpl::producer header; + std::vector> labels; + base::flat_map disabledMessages; + const style::SettingsButton *st = nullptr; +}; + +using RestrictionLabel = EditFlagsLabel; +[[nodiscard]] std::vector RestrictionLabels( + Data::RestrictionsSetOptions options); + +using AdminRightLabel = EditFlagsLabel; +[[nodiscard]] std::vector AdminRightLabels( + Data::AdminRightsSetOptions options); + [[nodiscard]] auto CreateEditRestrictions( QWidget *parent, rpl::producer header, ChatRestrictions restrictions, - std::map disabledMessages, + base::flat_map disabledMessages, Data::RestrictionsSetOptions options) --> EditFlagsControl; +-> EditFlagsControl; [[nodiscard]] auto CreateEditAdminRights( QWidget *parent, rpl::producer header, ChatAdminRights rights, - std::map disabledMessages, + base::flat_map disabledMessages, Data::AdminRightsSetOptions options) --> EditFlagsControl; +-> EditFlagsControl; [[nodiscard]] ChatAdminRights DisabledByDefaultRestrictions( not_null peer); @@ -91,4 +110,4 @@ struct EditFlagsControl { [[nodiscard]] auto CreateEditPowerSaving( QWidget *parent, PowerSaving::Flags flags -) -> EditFlagsControl; +) -> EditFlagsControl; diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index 76b5b9dc6..e2a72af3b 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -81,6 +81,7 @@ settingsIconFolders: icon {{ "settings/folders", settingsIconFg }}; settingsIconGeneral: icon {{ "settings/advanced", settingsIconFg }}; settingsIconLock: icon {{ "settings/lock", settingsIconFg }}; settingsIconLanguage: icon {{ "settings/language", settingsIconFg }}; +settingsIconBattery: icon {{ "settings/battery", settingsIconFg }}; settingsIconInterfaceScale: icon {{ "settings/interface_scale", settingsIconFg }}; settingsIconFaq: icon {{ "settings/faq", settingsIconFg }}; settingsIconCalls: icon {{ "settings/calls", settingsIconFg }}; @@ -526,3 +527,13 @@ requestPeerRestriction: FlatLabel(defaultFlatLabel) { lineHeight: 22px; } } + +powerSavingButton: SettingsButton(settingsButton) { + style: boxTextStyle; + padding: margins(57px, 8px, 22px, 8px); + iconLeft: 20px; +} +powerSavingButtonNoIcon: SettingsButton(powerSavingButton) { + padding: margins(22px, 8px, 22px, 8px); +} +powerSavingSubtitlePadding: margins(0px, 4px, 0px, -2px); diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index 3fe1c256f..4c6ef2284 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -664,7 +664,7 @@ void SetupAnimations( not_null container) { AddButton( container, - tr::lng_settings_power_title(), + tr::lng_settings_power_menu(), st::settingsButtonNoIcon )->setClickedCallback([=] { window->show(Box(PowerSavingBox)); diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 7bd0e0983..f2144d1cc 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -60,11 +60,12 @@ base::options::toggle OptionMonoSettingsIcons({ const char kOptionMonoSettingsIcons[] = "mono-settings-icons"; Icon::Icon(IconDescriptor descriptor) : _icon(descriptor.icon) { - const auto background = [&] { - if (OptionMonoSettingsIcons.value()) { + const auto background = [&]() -> const style::color* { + if (descriptor.type == IconType::Simple) { + return nullptr; + } else if (OptionMonoSettingsIcons.value()) { return &st::transparent; - } - if (descriptor.color > 0) { + } else if (descriptor.color > 0) { const auto list = std::array{ &st::settingsIconBg1, &st::settingsIconBg2, diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index e0dffe917..9ee703093 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -141,6 +141,7 @@ inline constexpr auto kIconGray = 9; enum class IconType { Rounded, Round, + Simple, }; struct IconDescriptor { diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index f12f2e81e..39fd8133d 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_advanced.h" #include "settings/settings_folders.h" #include "settings/settings_calls.h" +#include "settings/settings_power_saving.h" #include "settings/settings_premium.h" #include "settings/settings_scale_preview.h" #include "boxes/language_box.h" @@ -257,6 +258,19 @@ void Cover::refreshUsernameGeometry(int newWidth) { } // namespace +void SetupPowerSavingButton( + not_null window, + not_null container) { + const auto button = AddButton( + container, + tr::lng_settings_power_menu(), + st::settingsButton, + { &st::settingsIconBattery, kIconDarkOrange }); + button->setClickedCallback([=] { + window->show(Box(PowerSavingBox)); + }); +} + void SetupLanguageButton( not_null window, not_null container, @@ -270,7 +284,7 @@ void SetupLanguageButton( Lang::GetInstance().idChanges() ) | rpl::map([] { return Lang::GetInstance().nativeName(); }), icon ? st::settingsButton : st::settingsButtonNoIcon, - { icon ? &st::settingsIconLanguage : nullptr, kIconDarkOrange }); + { icon ? &st::settingsIconLanguage : nullptr, kIconLightBlue }); const auto guard = Ui::CreateChild(button.get()); button->addClickHandler([=] { const auto m = button->clickModifiers(); @@ -381,6 +395,7 @@ void SetupSections( Calls::Id(), { &st::settingsIconCalls, kIconGreen }); + SetupPowerSavingButton(&controller->window(), container); SetupLanguageButton(&controller->window(), container); if (controller->session().premiumPossible()) { diff --git a/Telegram/SourceFiles/settings/settings_power_saving.cpp b/Telegram/SourceFiles/settings/settings_power_saving.cpp index 88cc2829e..bd75ebbf7 100644 --- a/Telegram/SourceFiles/settings/settings_power_saving.cpp +++ b/Telegram/SourceFiles/settings/settings_power_saving.cpp @@ -10,13 +10,31 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peers/edit_peer_permissions_box.h" #include "core/application.h" #include "lang/lang_keys.h" +#include "settings/settings_common.h" #include "ui/layers/generic_box.h" +#include "ui/widgets/buttons.h" #include "ui/power_saving.h" +#include "styles/style_menu_icons.h" +#include "styles/style_layers.h" +#include "styles/style_settings.h" namespace Settings { void PowerSavingBox(not_null box) { + box->setStyle(st::layerBox); box->setTitle(tr::lng_settings_power_title()); + box->setWidth(st::boxWideWidth); + + const auto container = box->verticalLayout(); + + // Force top shadow visibility. + box->setPinnedToTopContent( + object_ptr(box, st::lineWidth)); + + AddSubsectionTitle( + container, + tr::lng_settings_power_subtitle(), + st::powerSavingSubtitlePadding); auto [checkboxes, getResult, changes] = CreateEditPowerSaving( box, @@ -24,6 +42,22 @@ void PowerSavingBox(not_null box) { box->addRow(std::move(checkboxes), {}); + auto automatic = (Ui::SettingsButton*)nullptr; + const auto hasBattery = true; + const auto automaticEnabled = true; + if (hasBattery) { + AddSkip(container); + AddDivider(container); + AddSkip(container); + AddButton( + container, + tr::lng_settings_power_auto(), + st::powerSavingButtonNoIcon + )->toggleOn(rpl::single(automaticEnabled)); + AddSkip(container); + AddDividerText(container, tr::lng_settings_power_auto_about()); + } + box->addButton(tr::lng_settings_save(), [=, collect = getResult] { Set(PowerSaving::kAll & ~collect()); Core::App().saveSettingsDelayed(); @@ -32,35 +66,56 @@ void PowerSavingBox(not_null box) { box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); } -std::vector PowerSavingLabelsList() { +EditFlagsDescriptor PowerSavingLabels() { using namespace PowerSaving; - using Label = PowerSavingLabel; + using Label = EditFlagsLabel; + auto stickers = std::vector