From 3c4f575bc2b85fe3a17f939945e7cb48c7ef2c1d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 29 Mar 2022 02:53:25 +0300 Subject: [PATCH] Added ability to set auto-delete from profile info. --- Telegram/CMakeLists.txt | 2 + .../Resources/icons/chat/input_autodelete.png | Bin 0 -> 667 bytes .../icons/chat/input_autodelete@2x.png | Bin 0 -> 1314 bytes .../icons/chat/input_autodelete@3x.png | Bin 0 -> 1987 bytes .../icons/chat/input_autodelete_1d.png | Bin 860 -> 0 bytes .../icons/chat/input_autodelete_1d@2x.png | Bin 1735 -> 0 bytes .../icons/chat/input_autodelete_1d@3x.png | Bin 2541 -> 0 bytes .../icons/chat/input_autodelete_30d.png | Bin 840 -> 0 bytes .../icons/chat/input_autodelete_30d@2x.png | Bin 1672 -> 0 bytes .../icons/chat/input_autodelete_30d@3x.png | Bin 2478 -> 0 bytes .../icons/chat/input_autodelete_7d.png | Bin 878 -> 0 bytes .../icons/chat/input_autodelete_7d@2x.png | Bin 1800 -> 0 bytes .../icons/chat/input_autodelete_7d@3x.png | Bin 2681 -> 0 bytes Telegram/Resources/langs/lang.strings | 2 +- .../view/controls/history_view_ttl_button.cpp | 121 ++--------------- .../view/controls/history_view_ttl_button.h | 10 +- .../SourceFiles/info/info_wrap_widget.cpp | 16 ++- Telegram/SourceFiles/menu/menu_ttl.cpp | 4 +- .../SourceFiles/menu/menu_ttl_validator.cpp | 122 ++++++++++++++++++ .../SourceFiles/menu/menu_ttl_validator.h | 38 ++++++ .../ui/boxes/auto_delete_settings.cpp | 2 +- Telegram/SourceFiles/ui/chat/chat.style | 17 ++- .../SourceFiles/window/window_peer_menu.cpp | 24 ++++ 23 files changed, 227 insertions(+), 131 deletions(-) create mode 100644 Telegram/Resources/icons/chat/input_autodelete.png create mode 100644 Telegram/Resources/icons/chat/input_autodelete@2x.png create mode 100644 Telegram/Resources/icons/chat/input_autodelete@3x.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_1d.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_1d@2x.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_1d@3x.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_30d.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_30d@2x.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_30d@3x.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_7d.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_7d@2x.png delete mode 100644 Telegram/Resources/icons/chat/input_autodelete_7d@3x.png create mode 100644 Telegram/SourceFiles/menu/menu_ttl_validator.cpp create mode 100644 Telegram/SourceFiles/menu/menu_ttl_validator.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 0653486a2..3072e1235 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -898,6 +898,8 @@ PRIVATE menu/menu_mute.h menu/menu_send.cpp menu/menu_send.h + menu/menu_ttl_validator.cpp + menu/menu_ttl_validator.h mtproto/config_loader.cpp mtproto/config_loader.h mtproto/connection_abstract.cpp diff --git a/Telegram/Resources/icons/chat/input_autodelete.png b/Telegram/Resources/icons/chat/input_autodelete.png new file mode 100644 index 0000000000000000000000000000000000000000..68f8f7b74e5e5c1ecc243602c95556953bfb6ec5 GIT binary patch literal 667 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`xTHpSruq6Z zXaU(A42G$TlC0TWzSVF5FO4N|zKE$K4@0~4#Ki(`lf z@7qw@6OMrrW$#rDJpz@QMJ91Z_9Pj2tSOt_>1e3j9HeG1EoLO0!{zFwW~g~8K1Jc_ z^J?#(JMX-{_df6bbHDeMb@z(T{k~Vs*ZuYHzZzD9F6%2f)Ma(VL2oNcF{ z7Fo>=S~#s+zzrNv^gTjNd-HHaY&suEu zTi!hHc#@&azseT{77B}xKVBK4_51I>iy1m%+-9@?zS0rly8U+A@yC0EQatv?$@jVi zWOTYPsdK9-M=iUW#dsjl!LmxYjKTc6JouHpcA}n=)7r4ZG8_0;Om$kQFv;-H)1peV*{yX4c1G(>{}Ay{Pu3|fSZk_S pH>;m~jMu}088LrS|7Ww-F}zuJE&NU3BT%|v@O1TaS?83{1OOQE7fApB literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/chat/input_autodelete@2x.png b/Telegram/Resources/icons/chat/input_autodelete@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..37c858111a613f9bfe8092e5e64a4a8a5ab4ec09 GIT binary patch literal 1314 zcmV+-1>O3IP)00001b5ch_0Itp) z=>Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91K%fHv1ONa40RR91KmY&$07g+lumAuAj7da6RA>e5SxG2$aTGT^vjsxt z3`L@Zg()G$LLn3@3#8akqLh^t3l@m7Q5HgENajKrvoT~NV`f4!mFfF_b-wp^d+%}Y zd+*-Y{p!BOd*_~ehTl2=>HN<#GgCfF29yja8Bj8yWI)M)k^zG=U}>2Tt1`C&CPpydRPo;X=&`0EQr#42hkdo?>eKBqon zb0#7p0+HbH$wy&fAu-vvzFYgizyRr1R8&ZUn;D&(nsi`UQQB+hU zTuY$j($W$c$5ALyMMI3IG)ICH5)w#fdU{$z+4x7gzQK;azrSJDcmfCw4W)VkmlBj; zhWYqK3)fD1%dM<_k=OfGUS1vz@#yHN-pT?Lf`Wo}c6K&4Hn5-ti0cqh>ELl#%jTml>)DEQwRVwpi>MfDJiCKDY}o=)>aAtrJLx+O<^!FFp%1VSkN&sF{W@S zx{toTJ{km^I1-kPqT^-;(RpTFlji1T#+L&js0x30ctFXHzmI@8E-vo={@xT9S#i^Y z?Wn)MpC%H%aV3{&llhmh?d?>1jB;X;^5%m|Mwrgc48Eck^vc;PAS45S Y0pDCO8E&kbr~m)}07*qoM6N<$f|j6TVgLXD literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/chat/input_autodelete@3x.png b/Telegram/Resources/icons/chat/input_autodelete@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..2ad4551d10a08c41e3a11baf846c9101f6b44d05 GIT binary patch literal 1987 zcmaJ?dpHwp8{ZtV*P%DrXdBVw@Tz5PWQ-TXnu^LHXA_~+>_ffI(Hu%)NJmSf(xgoe zi!iY!L{<)=C8w`fvK+^d!#n?c-yh#~eSiG!-|v2&-*w&heO=G>+!-gF534A`6afH$ ziX+k9MaltN0Le%rd3A&$C18}xVLX7{r8y~0?1McWL!6udMp6v|0I!|{$Zc7qfJp%W z$TENcSt$dz&KNTPxeZ{*{#S1qOEDy806+ohXm9Hl1N`ahLv(incXd|7{ohrVLBApp zsfc3bye1|nA?L{cowBM~hN5CyuJ}YgI8cAUZs%fvg9gP=KPKK4{fIYx@2}TS{W{k+ zXF@kwpP&NsI*Iu&I#&QCd1K;Pro#!LOP$Y6tKgp*jqiT|61 zhXlO8Z)z6)C1!JDy((1TTxe-d{%m3wgX+u*>!E(j!8vx!Y`@$@A6CTwnK_3VH+exI6> zrLhSiIZIs+aEI+J6P8g}>@q(?ZGC;+%@ObJ-Y1^yQIQc|Lb3ho3E(dcv99N^78a|k zi&JjLdD1?1s;T)Ybb*k4{r#?+a2O2x_|nuTZo*1lp%Jf~^csyu*WSO{!D6xOZDV6! zeGsWt{k$38bjHy7x`%Ng@$66Xow;h@_s-hQU5}ck>qaXq!j!voj{O zk)%d?H1>}_+ArUck&&4ViBN09MNd~#g2$c;YbX=ktgI}pmzc)JM&9-j$;@z>NBQng zAMzDfR#xnH9J;DYzu1}uH)uFNpmOYiMPEL6K*7(?&q;2G8{glEPP*Q%w0cIVsH7x) z-(4HR^@+}V7!S7ZU=3whs#u8W>FE+@|GJCq&$3zXRu(373A$0B$;ru=`C0C?ClX$o zlIE(kpgPifFN2PYKG1J|@p}#fb>ScqnH9f0J8I|YIq>4tv`5?f_upzE(9^4#Pz<(~ z;MNllg8xR{E5s})WC5S^MH?plBjR-C`0Y0{408?hwvic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Telegram/Resources/icons/chat/input_autodelete_1d.png b/Telegram/Resources/icons/chat/input_autodelete_1d.png deleted file mode 100644 index 22aa744ba905e44014f4ca3ff943dde3ef55bfe8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 860 zcmV-i1Ec(jP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91B%lKT1ONa40RR91Bme*a04fgS`~Uy~#z{m$R7ef&RXs>@VHD24GzAF^ zqEKBsNk zyKuSOu6nQFl<#!jbDr~m-uH}+jn1e7f3gAsPFd^qdWAw!uh%(g4FXhCFczu2S^Yi2NdO2HR zsgTWP&(F^Zut+3ICX=Y@=H@0#b#Ac7$H#+%15!sI5F8&L!=J<9Aen;`CX*?b%f(_b zKA%51If>Em`~6gN$nWOnrc$X)O-)hxoM|49cXxN!XfzP}*4CEGTqd0r3I!AvcCl3P zg?4ksTt=wD&GPax!o0n`4Tr-TjiyJ85{abMY5{=PjTCzzdx?}vWjr3oR|~JNudgT< ziKb?T)q_@fJf1)x(4&l9Gb4;XJw0KL=jZ3w*VnNvF#@DBDuEy%Iy^j7sZ=N_RWuYD mD@i7k4aM}x=%@lisK7tl&qR%#*66kX0000Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91NT34%1ONa40RR91NB{r;0FW_8?*IS>F-b&0RA>e5T3bj}T@cptlBRgU z)Xc;bMNttY)pwA}EMY`e39)LN7u$Dn-l0QUmQ`87XKYc*}c= zl}ePBmiB-A^Ed1~7x&(sa}xgT!)dKqvu5U-wbrazvokVM{uB==9#A}>ctG)h;sM12 ziU$-AC>~Heu&q6?Q-9VSKYlznH#aCKXm)mXadA<9iVQ0G%$YMkfBmhktyNT1*xK3} z)B-&zo12^ah3mh6KYaL*lar$-bp{fP#UV7y%gaxmJP{&%^yra`i;IEm(775nH#Y(^ zIXMa8@$vC*-@avd3kwUev9UT=Y6y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z-m)q^zx4(b?PG$*zQ59C@*97d;sZ%@``y4wQl?bXG5#7+h z$n<^t_TlDv{`|QRAuxyshBJogjEx$vU%$rxfBBoh7yxoS1d_zW#O&;BwdYOKia`Rd zubVe-B1Zud{Gxb{_gG0u$+iH-2xT{LzfZ_qg1BwR}4=5f` dJn;YWz(2%@Uc5dDrw0H4002ovPDHLkV1l547lZ%+ diff --git a/Telegram/Resources/icons/chat/input_autodelete_1d@3x.png b/Telegram/Resources/icons/chat/input_autodelete_1d@3x.png deleted file mode 100644 index 97fb566d0e6c42881eebbd4f65c206618d06c7af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2541 zcma)8c|6nqAD<05`)(%5QOprxnUUPr#A=4ZL`Er+V>xneX~+@ZY07&EACK4den0p_nQR3 z00;55=K!21_@b3LsJc&P0WdH(oUvXuHlS00E&$?5@B#7uh5#f55C{Y*;sHSb$@BZJ z2>jnyzaq&0^xwdpvC-ookRSnzF>?s#S;@Q8?br+daH6@{;04?gX7A^q4m|<^v?Cpd z2cj{4mg?%_!XnF=3W=&e4f`^tB^47NL^eJ+=+;QYa*PH~aco1+6B?#DKa>&6Tl6<~&qdHvoW8?0&XYr}gI*)rGTX?0yg`o!P@xuFM4} z;GS2rC?&u>QkjBq-w!tz6H;us}Y#!rBX6(I`b8DkFz!+QXZ#_c}?Eg0D?!8HF)J* zd(EsWlDqx{R2#85Uu5{?lp3M>V}VPK#n#%CiFokF&}?X>dmAyAv$gOkN5@wx<1y0B zWfNCm_{D?kU+dm>*M+$>QX_m6xj*LA)1i5HKiogp0$!l%QeSqaC~R#qr|NQ@*RD^T z_AEhIJ`Z-aGtTSpLKBlfAOEa@_tgPI&mA`s9hH2CE0H3eEELGHug1L%oX{d%8yKJ! zJdZ=EK4cA5WHQ`G>wOAMqLCse@p-qablC!QNNp4+V5C^ASf1T#TWFkw1w7mV&p^bH zUoDQ*)GX=Q2l|5w7_}D(HN=UAdaiDsNpx$x*UY;lR=w{C((R4^*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85ba465a6b3a96eaae64cfaf7d9247bb626f8210..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 840 zcmV-O1GoH%P)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91B%lKT1ONa40RR91Bme*a04fgS`~Uy~vPnciR7ef&Ry{~^Q5Y^wLI(*H zBBwx6qDdoyCIcNrM0C{EoQgn2BKH!9NN7@9q+I+NoE+Rl4T>acvC=>-@TU?7MacXf zz6){jUi03*@zd!&&v~BrJ-$EZ+?ko_Z<>MsG6P&z|9WL*MI;ivy}hwg{f4a7YKOz& zU@$m6JrxRtzj47_N)_$nNm}uCK4_^}1LrCgZH_+1c6K+uM(i51ifQa+%F$7@M1$BaT*A zSJ5wCuXhAzw=@_G@NTtQ6NyBx*URN{&1Q3MZjS2Z;^Lyy>G1h{>K0QZlgT_iJ)tm* zi;I|I1Ri&MjYflAoleKp^$2fiX$hUZzrRo5>+9=BM@J~z2#r|I&(HV!{lmjU+TF>Z z-EPNW6$-^<>R-m=<6|TenMkIo0W@oCYmG*uSS(J|6NGd+jk+=s3}fj~gJMSwDy4E-68$A923-8wipzzE|tp%tjrYN9`JL(&r1foKhks?X=6%5a<9 z-`|Hqp@)YDBG~fsa4pQTQMri^(>QMPAa{KLvxJR;$@;Ho08By}gas5}yUMUZ&tQ1Jexrlz~5@phqH} S2P9Mg0000{6- diff --git a/Telegram/Resources/icons/chat/input_autodelete_30d@2x.png b/Telegram/Resources/icons/chat/input_autodelete_30d@2x.png deleted file mode 100644 index 052d067f878c1d8e0e6934a77fd395256ca66e83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1672 zcmZuyc~}x?8VAKf@kUoP*ApboHBei$95(?KusrbAbu=*t(Xkq7N=8G;6dY8h&7<(Z zvOI9{R?5`LJ8j8PM~xK2&5kFrywZ$p@Soj(=J}rA`+L9l_~U)v-}8N(K!0ByEi)|u z0H8x8;K?c`>;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PyS|=-ryz^lE#?pqp&hu?hK~m4&C+NzEeIsi$IndFUG>dRGcuXK=>hiP7n%=i zqo5f3#s|3_)j6mz|A!J(h!(+7Vv}H4Ntj&w-JrtVB(M7&fG{T@g5q5>h>G%Z^NUWK ze%!6Ct?9u?kaeEaZA76^1o0Oxj@Cz${;qv{d~EC%pHK8nPj@$WM>8jB_%XOni3uZ_i>M(gGi&T0v-&A)l8U?2@`@6y&#`3$ib_ zf4y-YT%xCY>>l&V7nQyi=I77*cySKZB0t@^eDqHqTEKRejh^x#c*n_ur3_>3{{lpB Kf4m4A$NB@G!TWRo diff --git a/Telegram/Resources/icons/chat/input_autodelete_30d@3x.png b/Telegram/Resources/icons/chat/input_autodelete_30d@3x.png deleted file mode 100644 index c71ea6fcb1eac5c83cdf213a5135bb2d643fa77f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2478 zcmb7Gc{mi@8lORBHdz`;w&+ld{@1Mo?Ck-{OrIS9ObrIG{Yhbp7*hZM))F9qm1%*0 z)=F6Zvl~{z`d|M~;{La3NdSOD#2RAm8V6j*-Ff5Y2F}%rK0l4;1Ltz}wN0R~6^W zrA&}}ro@w$gu|GDJk5M9e;a*|g|b^y_5MWU{+3}1@kS$pO#52riyX7TyPx3^6B06C zF^ZyEeT-TZ=vO2XV6|`*WqV~*;W0Frb94Ulnc5wX1~zQOAXb-UVtaKm`p1xQEPbZN zi)d2;YL4Ad^Zam&C4Z^7>f8Hp!Mvd&<5fG)R^^8ZWOTQZ=mk zX8`jC`7k`RB$Y>8_$G}nak|FKG}Edx{p?d+eOS}&l-*y}BAWqR01{NF^LFDm5ewV+IJb9q0WdFtFyBkCMu6>;fBydz)o> z4BEJgk$3Rro;tUho5p0vzdH%QxW`=uO*aT3)s`7V%J2POx;jkoEGr5PV`)S0JQ_*C zx2{$?%ZaUjq%A8wSA&TS25sibDZWeKjS1aZo4Ue&(uHYf(8-5W4S_yj6i#uwOKNyT zI>v&D-b)E>lZCw`G*`!)D`gPA&wt6(R$VGQr7}Rrlvj+$&O{6dLc^2ih za~UuzdqXDS5h#oN1!u9O#9iP({XliN6!vw|3O2my2`LvS~sf&CldhYW^-M6q8swE(o0{hVK84 z;1gz%6rJQ7$*9#vV09AY5p%5_?9c!LqH#2-KoZ@U{iG6j zNz(3>Pu)DLZl&VAU3y_;X!;<|dZZd65W!@H;G%PGn1B)=#|}`YKXkI1Ns&t17iu$4 zj3kV%T3jK^^n=itM0|iv=l8#x1u~~^$2cj2!B?xGTs~coLFxJNikOv>27!b|9q#-{{g2sAES8^jYg0oB|!y;ph$Zc<8}odzpm}-RFvBQFX)tyL$0bjN&l*tZU}W9uVf&2 z?vXxdFWYKN+OoVZdb!f2qHo{oPEEU0g~K`i-6V>Al`h3@b7D6JxNxw&N?2@Ry<-3h zSNCegig+tVe7y*H2i%400k-Q%6qtW9q>3n)!4#RD4)5>H# zZc)pg`QJMh8Z7SiZp|@}`g>CQt9l!pWD963;<7k**Jz1-mboAA*3bdgoX-&5zkzpe zKvs)Vd&*q(-b|5JtN~;9KqFZ>8WmTs-0mC^*Ysh#%U8u7P3@66s*`WioN&>&Z)fH= zBdQ(X6t=tnD=?fj^}Jgb2mBYoy=?z4o+?R6&E#}TCz)2G~WmMydhqg45=^7`FUZ@j>-$V mJDx01cl3XZAOD_JP;JEdupxQ3(cd$FW+iK=1El&g9Q`k1(3Zad diff --git a/Telegram/Resources/icons/chat/input_autodelete_7d.png b/Telegram/Resources/icons/chat/input_autodelete_7d.png deleted file mode 100644 index c5dae024f3d14c5462e9a42885a1caf7d2fc7a9e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 878 zcmV-!1CjiRP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91B%lKT1ONa40RR91Bme*a04fgS`~Uy~*hxe|R7ef&RxwC&Q4~%s(uN2u zLoskklcov>n{_aV(6!a1MG1@$bS^0f0tYeO(#3L-qM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|>gMU;$;+KI zl>3U~wl%l4d*n|~qu3_GZP-P<0LN)g5p9+}1~Ny+n>(M69a1{|C<$J^l*&L5%~9 zqVG;-;A`n3bsH?`EG~o++}lbnA=vEk&rgGXAD7;3Pao*P&+_v1POP(_;(l%aNUGzZ zzcFMxI8PYng%wh?SoLd3hO3-mWEiJ;?2O!pQw=U$nmQ6-ZYQnQ>_#_ z5xr}k-MRG!MHAAYX09q+g8VEyh=v$;VPtl@(YsMHC6A$5zHtH?@cht*B6!vwMsD19L?5x zWs?>1@hO()nAjX%!s4J5kcJH|vM7PfywKTP>4Uu+PnLeR_#C5sp1uzTUb7Xfn2#5R<-oFCX16875ws(m_!q08Ut?_ONX_a}I$b9T8ekwR ztdo^`YvfysJWHTvIcoU6ZdAHTJporB%4`$2dRwataTvI-a3bQd+-sGX<-gLGcBnTf zipFNhq#*Te>(f^E#l${%-`vWzs-uw z@lXn;73o#W>i6#8Ea@6axAidXhRc#tmp4VCQu8-fB^*ef9YzZ}VtI$fbQ8CMrMyZ5 zOfDr0U@`7Or6%F`tStonG-bCnROg2~0Yauj1|U-Wn-`y-)G3m3&elc?Gn72?0?$v4 znT07uj=J88XjLjHtUhwz;NfqcEJvAK(032OVWD55bQ5>DAg3+h0R;wKsbDyy%=TOS zZcf2F73wX>a z55YlWYnmtEF$txM@0F8nX2nRIXqJqKGxv*C*_07wY0rZ?!wP+7lPVglKe;)#Pb72z z1uHE=2FWGhke*T318qZrF;;EHcOG!eD_7|RVY;8(yt|lBo3@&vzb~t&c=I6fzUesd z=nWJk4U_gP*R$8<;V#uz1lc+VMj8v*`>`gKZN*)yV;gGCbznM4b3ee#Jg3eWuopka*XI>fJA0AEZP{AvF lXZHVYlKSu1rR@g1_(zu(f1)nzD)4vg)6vq06l++9{s%uK1EBx_ diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f88ef925b..921b35184 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1123,7 +1123,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_manage_history_visibility_hidden_legacy" = "New members won't see more than 100 previous messages."; "lng_manage_messages_ttl_title" = "Auto-delete after..."; -"lng_manage_messages_ttl_never" = "Disable"; +"lng_manage_messages_ttl_disable" = "Disable"; "lng_manage_messages_ttl_after1" = "1 hour"; "lng_manage_messages_ttl_after2" = "1 day"; "lng_manage_messages_ttl_after3" = "1 week"; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp index af3ae4947..7e293f8e4 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp @@ -7,102 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/controls/history_view_ttl_button.h" -#include "data/data_peer.h" -#include "data/data_chat.h" -#include "data/data_channel.h" #include "data/data_changes.h" +#include "data/data_peer.h" #include "main/main_session.h" -#include "menu/menu_ttl.h" -#include "lang/lang_keys.h" -#include "boxes/peers/edit_peer_info_box.h" -#include "ui/boxes/auto_delete_settings.h" -#include "ui/toast/toast.h" -#include "ui/toasts/common_toasts.h" +#include "menu/menu_ttl_validator.h" +#include "ui/text/format_values.h" #include "ui/text/text_utilities.h" -#include "apiwrap.h" #include "styles/style_chat.h" namespace HistoryView::Controls { -namespace { - -constexpr auto kToastDuration = crl::time(3500); - -void ShowAutoDeleteToast( - not_null parent, - not_null peer) { - const auto period = peer->messagesTTL(); - if (!period) { - Ui::Toast::Show(parent, tr::lng_ttl_about_tooltip_off(tr::now)); - return; - } - - const auto duration = (period == 5) - ? u"5 seconds"_q - : (period < 2 * 86400) - ? tr::lng_ttl_about_duration1(tr::now) - : (period < 8 * 86400) - ? tr::lng_ttl_about_duration2(tr::now) - : tr::lng_ttl_about_duration3(tr::now); - const auto text = peer->isBroadcast() - ? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration) - : tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration); - Ui::ShowMultilineToast({ - .parentOverride = parent, - .text = { text }, - .duration = kToastDuration, - }); -} - -} // namespace - -void AutoDeleteSettingsMenu( - not_null parent, - std::shared_ptr show, - not_null peer, - rpl::producer<> triggers) { - struct State { - TimeId savingPeriod = 0; - mtpRequestId savingRequestId = 0; - QPointer weak; - }; - const auto state = std::make_shared(State{ - .weak = Ui::MakeWeak(parent.get()), - }); - auto callback = [=](TimeId period) { - auto &api = peer->session().api(); - if (state->savingRequestId) { - if (period == state->savingPeriod) { - return; - } - api.request(state->savingRequestId).cancel(); - } - state->savingPeriod = period; - state->savingRequestId = api.request(MTPmessages_SetHistoryTTL( - peer->input, - MTP_int(period) - )).done([=](const MTPUpdates &result) { - peer->session().api().applyUpdates(result); - ShowAutoDeleteToast(show->toastParent(), peer); -#if 0 - if (const auto strong = state->weak.data()) { - strong->closeBox(); - } -#endif - }).fail([=] { - state->savingRequestId = 0; - }).send(); - }; - auto about = peer->isUser() - ? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName())) - : peer->isBroadcast() - ? tr::lng_ttl_edit_about_channel() - : tr::lng_ttl_edit_about_group(); - const auto ttl = peer->messagesTTL(); - TTLMenu::SetupTTLMenu( - parent, - std::move(triggers), - { std::move(show), ttl, std::move(about), std::move(callback) }); -} TTLButton::TTLButton( not_null parent, @@ -110,37 +23,23 @@ TTLButton::TTLButton( not_null peer) : _peer(peer) , _button(parent, st::historyMessagesTTL) { - auto triggers = _button.clicks( + + const auto validator = TTLMenu::TTLValidator(std::move(show), peer); + auto clicks = _button.clicks( ) | rpl::to_empty | rpl::filter([=] { - const auto canEdit = peer->isUser() - || (peer->isChat() - && peer->asChat()->canDeleteMessages()) - || (peer->isChannel() - && peer->asChannel()->canDeleteMessages()); - if (!canEdit) { - ShowAutoDeleteToast(show->toastParent(), peer); + if (!validator.can()) { + validator.showToast(); return false; } return true; }); - AutoDeleteSettingsMenu(parent, show, peer, std::move(triggers)); + TTLMenu::SetupTTLMenu(parent, std::move(clicks), validator.createArgs()); peer->session().changes().peerFlagsValue( peer, Data::PeerUpdate::Flag::MessagesTTL ) | rpl::start_with_next([=] { - const auto ttl = peer->messagesTTL(); - if (ttl < 2 * 86400) { - _button.setIconOverride(nullptr, nullptr); - } else if (ttl < 8 * 86400) { - _button.setIconOverride( - &st::historyMessagesTTL2Icon, - &st::historyMessagesTTL2IconOver); - } else { - _button.setIconOverride( - &st::historyMessagesTTL3Icon, - &st::historyMessagesTTL3IconOver); - } + _button.setText(Ui::FormatTTLTiny(peer->messagesTTL())); }, _button.lifetime()); } diff --git a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.h b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.h index bfc431765..dbdc50a9f 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "ui/widgets/buttons.h" +#include "ui/widgets/icon_button_with_text.h" namespace Ui { class Show; @@ -15,12 +15,6 @@ class Show; namespace HistoryView::Controls { -void AutoDeleteSettingsMenu( - not_null parent, - std::shared_ptr show, - not_null peer, - rpl::producer<> triggers); - class TTLButton final { public: TTLButton( @@ -40,7 +34,7 @@ public: private: const not_null _peer; - Ui::IconButton _button; + Ui::IconButtonWithText _button; }; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index f30696161..f38ff4f00 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "mainwidget.h" #include "lang/lang_keys.h" +#include "styles/style_chat.h" // popupMenuExpandedSeparator #include "styles/style_info.h" #include "styles/style_profile.h" #include "styles/style_menu_icons.h" @@ -494,7 +495,7 @@ void WrapWidget::showTopBarMenu() { } _topBarMenu = base::make_unique_q( this, - st::popupMenuWithIcons); + st::popupMenuExpandedSeparator); _topBarMenu->setDestroyedCallback([this] { InvokeQueued(this, [this] { _topBarMenu = nullptr; }); @@ -506,6 +507,19 @@ void WrapWidget::showTopBarMenu() { const auto addAction = Window::PeerMenuCallback([=]( Window::PeerMenuCallback::Args a) { + if (a.isSeparator) { + return _topBarMenu->addSeparator(); + } else if (a.fillSubmenu) { + const auto action = _topBarMenu->addAction( + a.text, + std::move(a.handler), + a.icon); + // Dummy menu. + action->setMenu( + Ui::CreateChild(_topBarMenu->menu().get())); + a.fillSubmenu(_topBarMenu->ensureSubmenu(action)); + return action; + } return _topBarMenu->addAction(a.text, std::move(a.handler), a.icon); }); if (key().isDownloads()) { diff --git a/Telegram/SourceFiles/menu/menu_ttl.cpp b/Telegram/SourceFiles/menu/menu_ttl.cpp index 31ec538e4..f36337923 100644 --- a/Telegram/SourceFiles/menu/menu_ttl.cpp +++ b/Telegram/SourceFiles/menu/menu_ttl.cpp @@ -137,7 +137,7 @@ void TTLBox( ) | rpl::map([=](int seconds) { state->lastSeconds = seconds; return !seconds - ? tr::lng_manage_messages_ttl_never() + ? tr::lng_manage_messages_ttl_disable() : tr::lng_enable_auto_delete(); }) | rpl::flatten_latest(); const auto confirm = box->addButton(std::move(confirmText), [=] { @@ -178,7 +178,7 @@ void FillTTLMenu(not_null menu, Args args) { if (args.startTtl) { const auto disable = menu->addAction( - tr::lng_manage_messages_ttl_never(tr::now), + tr::lng_manage_messages_ttl_disable(tr::now), [=] { args.callback(0); }, &st::menuIconDisableAttention); disable->setData(st::menuIconAttentionColor->c); diff --git a/Telegram/SourceFiles/menu/menu_ttl_validator.cpp b/Telegram/SourceFiles/menu/menu_ttl_validator.cpp new file mode 100644 index 000000000..93779cdb7 --- /dev/null +++ b/Telegram/SourceFiles/menu/menu_ttl_validator.cpp @@ -0,0 +1,122 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "menu/menu_ttl_validator.h" + +#include "apiwrap.h" +#include "data/data_channel.h" +#include "data/data_chat.h" +#include "data/data_peer.h" +#include "lang/lang_keys.h" +#include "main/main_session.h" +#include "menu/menu_ttl.h" +#include "ui/layers/show.h" +#include "ui/text/text_utilities.h" +#include "ui/toast/toast.h" +#include "ui/toasts/common_toasts.h" +#include "styles/style_chat.h" +#include "styles/style_menu_icons.h" + +namespace TTLMenu { +namespace { + +constexpr auto kToastDuration = crl::time(3500); + +void ShowAutoDeleteToast( + not_null parent, + not_null peer) { + const auto period = peer->messagesTTL(); + if (!period) { + Ui::Toast::Show(parent, tr::lng_ttl_about_tooltip_off(tr::now)); + return; + } + + const auto duration = (period == 5) + ? u"5 seconds"_q + : (period < 2 * 86400) + ? tr::lng_ttl_about_duration1(tr::now) + : (period < 8 * 86400) + ? tr::lng_ttl_about_duration2(tr::now) + : tr::lng_ttl_about_duration3(tr::now); + const auto text = peer->isBroadcast() + ? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration) + : tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration); + Ui::ShowMultilineToast({ + .parentOverride = parent, + .text = { text }, + .duration = kToastDuration, + }); +} + +} // namespace + +TTLValidator::TTLValidator( + std::shared_ptr show, + not_null peer) +: _peer(peer) +, _show(std::move(show)) { +} + +Args TTLValidator::createArgs() const { + const auto peer = _peer; + const auto show = _show; + struct State { + TimeId savingPeriod = 0; + mtpRequestId savingRequestId = 0; + }; + const auto state = std::make_shared(); + auto callback = [=, toastParent = show->toastParent()](TimeId period) { + auto &api = peer->session().api(); + if (state->savingRequestId) { + if (period == state->savingPeriod) { + return; + } + api.request(state->savingRequestId).cancel(); + } + state->savingPeriod = period; + state->savingRequestId = api.request(MTPmessages_SetHistoryTTL( + peer->input, + MTP_int(period) + )).done([=](const MTPUpdates &result) { + peer->session().api().applyUpdates(result); + ShowAutoDeleteToast(toastParent, peer); + state->savingRequestId = 0; +#if 0 + if (const auto strong = state->weak.data()) { + strong->closeBox(); + } +#endif + }).fail([=] { + state->savingRequestId = 0; + }).send(); + }; + auto about = peer->isUser() + ? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName())) + : peer->isBroadcast() + ? tr::lng_ttl_edit_about_channel() + : tr::lng_ttl_edit_about_group(); + const auto ttl = peer->messagesTTL(); + return { std::move(show), ttl, std::move(about), std::move(callback) }; +} + +bool TTLValidator::can() const { + return _peer->isUser() + || (_peer->isChat() + && _peer->asChat()->canDeleteMessages()) + || (_peer->isChannel() + && _peer->asChannel()->canDeleteMessages()); +} + +void TTLValidator::showToast() const { + ShowAutoDeleteToast(_show->toastParent(), _peer); +} + +const style::icon *TTLValidator::icon() const { + return &st::menuIconTTL; +} + +} // namespace TTLMenu diff --git a/Telegram/SourceFiles/menu/menu_ttl_validator.h b/Telegram/SourceFiles/menu/menu_ttl_validator.h new file mode 100644 index 000000000..eb737baf3 --- /dev/null +++ b/Telegram/SourceFiles/menu/menu_ttl_validator.h @@ -0,0 +1,38 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#include "menu/menu_ttl.h" + +class PeerData; + +namespace Ui { +class Show; +class RpWidget; +} // namespace Ui + +namespace TTLMenu { + +class TTLValidator final { +public: + TTLValidator( + std::shared_ptr show, + not_null peer); + + [[nodiscard]] bool can() const; + [[nodiscard]] Args createArgs() const; + void showToast() const; + const style::icon *icon() const; + +private: + const not_null _peer; + const std::shared_ptr _show; + +}; + +} // namespace TTLMenu diff --git a/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp b/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp index 0818a1dee..d65417979 100644 --- a/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp +++ b/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp @@ -200,7 +200,7 @@ void AutoDeleteSettingsBox( }); const auto options = std::vector{ - tr::lng_manage_messages_ttl_never(tr::now), + tr::lng_manage_messages_ttl_disable(tr::now), //u"5 seconds"_q, AssertIsDebug() tr::lng_manage_messages_ttl_after1(tr::now), tr::lng_manage_messages_ttl_after2(tr::now), diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 6987ada8c..cec0536c8 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -311,14 +311,17 @@ historyAttachEmoji: IconButton(historyAttach) { icon: icon {{ "chat/input_smile_face", historyComposeIconFg }}; iconOver: icon {{ "chat/input_smile_face", historyComposeIconFgOver }}; } -historyMessagesTTL: IconButton(historyAttach) { - icon: icon {{ "chat/input_autodelete_1d", historyComposeIconFg }}; - iconOver: icon {{ "chat/input_autodelete_1d", historyComposeIconFgOver }}; +historyMessagesTTL: IconButtonWithText { + iconButton: IconButton(historyAttach) { + icon: icon {{ "chat/input_autodelete", historyComposeIconFg }}; + iconOver: icon {{ "chat/input_autodelete", historyComposeIconFgOver }}; + } + textFg: historyComposeIconFg; + textFgOver: historyComposeIconFgOver; + textPadding: margins(16px, 20px, 6px, 7px); + + font: font(10px semibold); } -historyMessagesTTL2Icon: icon {{ "chat/input_autodelete_7d", historyComposeIconFg }}; -historyMessagesTTL2IconOver: icon {{ "chat/input_autodelete_7d", historyComposeIconFgOver }}; -historyMessagesTTL3Icon: icon {{ "chat/input_autodelete_30d", historyComposeIconFg }}; -historyMessagesTTL3IconOver: icon {{ "chat/input_autodelete_30d", historyComposeIconFgOver }}; historyMessagesTTLLabel: FlatLabel(defaultFlatLabel) { minWidth: 200px; align: align(topleft); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 72c046dab..7dccca6f4 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "main/main_session_settings.h" #include "menu/menu_mute.h" +#include "menu/menu_ttl_validator.h" #include "apiwrap.h" #include "mainwidget.h" #include "mainwindow.h" @@ -191,6 +192,7 @@ private: void addBotToGroup(); void addNewMembers(); void addDeleteContact(); + void addTTLSubmenu(bool addSeparator); not_null _controller; Dialogs::EntryState _request; @@ -764,6 +766,26 @@ void Filler::addThemeEdit() { &st::menuIconChangeColors); } +void Filler::addTTLSubmenu(bool addSeparator) { + const auto validator = TTLMenu::TTLValidator( + std::make_shared(_controller), + _peer); + if (!validator.can()) { + return; + } + _addAction(PeerMenuCallback::Args{ + .text = tr::lng_manage_messages_ttl_menu(tr::now), + .handler = nullptr, + .icon = validator.icon(), + .fillSubmenu = [=](not_null menu) { + TTLMenu::FillTTLMenu(menu, validator.createArgs()); + }, + }); + if (addSeparator) { + _addAction(PeerMenuCallback::Args{ .isSeparator = true }); + } +} + void Filler::fill() { if (_folder) { fillArchiveActions(); @@ -808,6 +830,7 @@ void Filler::fillHistoryActions() { addThemeEdit(); addViewDiscussion(); addExportChat(); + addTTLSubmenu(false); addReport(); addClearHistory(); addDeleteChat(); @@ -816,6 +839,7 @@ void Filler::fillHistoryActions() { void Filler::fillProfileActions() { addSupportInfo(); + addTTLSubmenu(true); addNewContact(); addShareContact(); addEditContact();