From 596b3d559452c949dc91c9368e783879653e161a Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Tue, 30 Aug 2022 14:24:47 +0300 Subject: [PATCH] [Option][GUI] Profile pic rounding --- Telegram/Resources/icons/bubble_tail1.png | Bin 0 -> 1816 bytes Telegram/Resources/icons/bubble_tail1@2x.png | Bin 0 -> 1844 bytes Telegram/Resources/icons/bubble_tail1@3x.png | Bin 0 -> 1856 bytes Telegram/Resources/icons/bubble_tail2.png | Bin 0 -> 1837 bytes Telegram/Resources/icons/bubble_tail2@2x.png | Bin 0 -> 1875 bytes Telegram/Resources/icons/bubble_tail2@3x.png | Bin 0 -> 1910 bytes Telegram/Resources/langs/rewrites/en.json | 6 + Telegram/SourceFiles/api/api_chat_invite.cpp | 12 +- .../boxes/filters/edit_filter_chats_list.cpp | 19 +- Telegram/SourceFiles/boxes/peer_list_box.cpp | 19 +- Telegram/SourceFiles/calls/calls_top_bar.cpp | 4 +- Telegram/SourceFiles/calls/calls_userpic.cpp | 33 ++- Telegram/SourceFiles/data/data_folder.cpp | 20 +- Telegram/SourceFiles/data/data_peer.cpp | 73 ++++++- Telegram/SourceFiles/data/data_peer.h | 24 +++ .../SourceFiles/data/data_peer_values.cpp | 2 +- Telegram/SourceFiles/dialogs/dialogs_row.cpp | 17 +- .../SourceFiles/history/history_widget.cpp | 8 +- .../history_view_compose_controls.cpp | 3 +- .../view/history_view_context_menu.cpp | 4 +- .../view/history_view_group_call_bar.cpp | 20 +- .../view/media/history_view_contact.cpp | 20 +- .../history/view/media/history_view_poll.cpp | 19 +- .../SourceFiles/kotato/kotato_settings.cpp | 4 + .../kotato/kotato_settings_menu.cpp | 52 +++++ .../win/notifications_manager_win.cpp | 3 +- Telegram/SourceFiles/ui/chat/chat.style | 18 ++ .../SourceFiles/ui/chat/group_call_bar.cpp | 6 +- Telegram/SourceFiles/ui/chat/group_call_bar.h | 3 +- .../ui/chat/group_call_userpics.cpp | 22 +- .../SourceFiles/ui/chat/group_call_userpics.h | 4 +- Telegram/SourceFiles/ui/chat/requests_bar.cpp | 6 +- Telegram/SourceFiles/ui/chat/requests_bar.h | 3 +- .../ui/controls/peer_list_dummy.cpp | 39 +++- .../ui/controls/send_as_button.cpp | 28 ++- .../SourceFiles/ui/controls/send_as_button.h | 3 +- .../controls/who_reacted_context_action.cpp | 15 +- .../ui/controls/who_reacted_context_action.h | 3 +- .../SourceFiles/ui/effects/round_checkbox.cpp | 21 +- Telegram/SourceFiles/ui/empty_userpic.cpp | 190 +++++++++++++++++- Telegram/SourceFiles/ui/empty_userpic.h | 62 ++++++ Telegram/SourceFiles/ui/image/image.cpp | 19 ++ Telegram/SourceFiles/ui/image/image.h | 3 + Telegram/SourceFiles/ui/special_buttons.cpp | 89 ++++++-- .../SourceFiles/ui/widgets/multi_select.cpp | 39 +++- 45 files changed, 854 insertions(+), 81 deletions(-) create mode 100644 Telegram/Resources/icons/bubble_tail1.png create mode 100644 Telegram/Resources/icons/bubble_tail1@2x.png create mode 100644 Telegram/Resources/icons/bubble_tail1@3x.png create mode 100644 Telegram/Resources/icons/bubble_tail2.png create mode 100644 Telegram/Resources/icons/bubble_tail2@2x.png create mode 100644 Telegram/Resources/icons/bubble_tail2@3x.png diff --git a/Telegram/Resources/icons/bubble_tail1.png b/Telegram/Resources/icons/bubble_tail1.png new file mode 100644 index 0000000000000000000000000000000000000000..65d577e9541a61caa442c0a16f800b73df524dcb GIT binary patch literal 1816 zcmb_dO>f*p7&cUjLQy4DE(ocTnRY0b z6VX|wIiNM|&ek%g>_}AlL`;(`GXDPcH$zW&WIXUjc$D|VEE${?;{Mt0n4KN5kQ-Z{ z>UWj|2vSi|eVNX)k}M;m<|QyzuT4X*A=Oc2Y%4+iaI~lQWFd5~<0EFdp56^RmhZS> z_=#>~D==|jS`M;&;$mXkdh;_tt>7`)?|=hxYSFUwi0Eva{^&B3Aq$q zj!$!8?u$|$7fkG&fX&+~nw<0sK`U8|rJSz|wYRpc_j;-@q5k26B;#^Xesp1u=+jC> zhK+5EFjUPN<1TS5V!Iz>hhV&djwDaw(`TUe7+b^%iQ_y4g|6YWqOSyVMq*i{6k<+N zIu&M~O%1)xB(j~&s|rn z+3pnyEHyg6$f{g%U<|vAyCDB-C8V=usQ$S24ZPJm+S+K4)gBB+Yv__heT6sozh^}PFlxGwBD>wbJq_YFOp(QGPU z2Q`h?kLPOLd1*Y)udn|#9#id|t5!3g?ZW!og?$#vS-*nKTMgS&10LFQM`Vzy0#215 z?*5^Uv|Gde_IUFa`$juBIM~=cKRg*cs?Dl{8 I?BTcn0)ziB%m4rY literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail1@2x.png b/Telegram/Resources/icons/bubble_tail1@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ebeca1511c8b6e018059ae7ea40a8baf2b9dba14 GIT binary patch literal 1844 zcmb_dO>f*p7~UdLl|@w#p;E=AmLnmmGVAfTXXw(VyMe6K4N=td zwacBg_9nb9R?nrk;9nh%ufyw|Z0(DpR(p4;dM?zy`~DgLeu#V9<#zWTqFfHh~sZV$*jH_is*Cvp1r>U=02DR<(hSpNK)ZB)Lxaqi>Pa39YJA{0s zS=bB=92lmJOpiL4T9!8Z>0m7v5#4NmI5IhU(@Aal9$CZnxfvQp(erH1oFZOkQWtyYy7qJ6j(r$UX28z=V2HY;UQ zx3Gl~hOC)A>{HvMmU9!^6yqtht3({_pMqLFY*L3%$9xV7RU=r*{ueAbjZ~g6@HtLc zUm983*R@3?X-f@N4u(OUJyFr^(oR~GEakG(ZtCE6BaQ|2ZQmC`$Ptgs06C!}QGlh3 zEG#TP5HNSl`Tn-zyH#?l{nI)ZiUY?ptHflH=>S{k`vhU`1Skw6f|%BXVDU zH5(0MZBiDL@v7XLI<#MGDu{%$F886dc zu)SBS$8LZlB0}UyJ3tY0EW~WikmtL$?O8JL8JT6|P<^R9-ATLUJGdq<`asvK^W z!)rG^xRFSwz0$k%Eq{3D?R$5={@}-_PoFg2TUvVj`__X8M@RpD{K!~dE{^{B>-hNi maZs<dUXFQAm literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail1@3x.png b/Telegram/Resources/icons/bubble_tail1@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..e11ccb08b4c48a9856959adfc7c18f3630853477 GIT binary patch literal 1856 zcmb_d&2QX96n9ZowP_=S;6RZgxvoGU@Xq*icSdzfSf|ZOb%>I!8o0oCJl?f-?Qv~y zb~i`Ffx-dtacRYYORpdfJ#iqYQpH~Y9H@kZIHL#&u8jA?>PK3ls4ICrGyctczxUp6 z-dtZ_yR^9Q(t;#Oi>+06L%dIv&+%u(KmYr)OXVb8eJ7Wslh2pW5$WbvFG|v}FQWEV zvE^OHl*cs^aG%viaVpS~bne0^CA7y1*=L<7ag@Kl|3Q(Xz)`MR9`w>C>qe_P8Qa`h zYtx+`MS*hRynJqig@KqAL>|TcB*!C1nb^f*TrLAeo+lMdI^8;V6RXG=w;<%qICPO(J1n zL{gyDU>VW`7|;rr4zm8lc|ZZ{vzR4CF0fjKO}o6{d6z%NboKcG2O_neSNYhNOB`1& z@?vFMgfUCVzUaI?P8rx>IUi({t!xXLXUk|(+{_p$c-H2;KQGk!oU+_(mW4s`t5>5W z;KTg2`}Q!G6wFa{s6!Qss%dRl$A*S=^L1!o2&Yhw2T?eF2&%WChAoJ-`U6m*nt&AK zf58F8AeB|&k#5@cfX?^3oDRz3&i4mmKdRHfM3ku}L7{5fW~ib7G8IB% zLCx@4XjT5-&LVNRNdM4w$|F~*0+f?+fQZ>tp*HH;HxGx8fr*PT_px3 zs$I7X!`4}&PS8C1N7*;9X^Jj0SKuMp&yq{KBfU;Xo zr3M~W;pE$WomG@`vLxDdIjrspF{y4EmWWhk;vV_)pP!x;chF|bU2Y#=8vOX(;;ww^ z=IGkzIbKtlNbSq( w`qB@t-MN0_mv{GeZ~c4z?)sJCr+1FMdD>jNee;M1& literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail2.png b/Telegram/Resources/icons/bubble_tail2.png new file mode 100644 index 0000000000000000000000000000000000000000..3b661456056c1abdea4bfc9be167dddb6439b60d GIT binary patch literal 1837 zcmb_dL2ukd6m|hsB~>IOB!oCwE{7KIdS>jkcSbc;x|=jBu^~zpC8$#Acs$;IB?|5U*LJyyQFE_Mir~IJsyAa-uK@7X5MGp zTX$AhUR%*LZMD1E*@5Q^a9zIg9NZ7?erv$v#ccEaLes9kTwRy6ufBd20N=#@{c^we z4ihSA@K6P^F-bB&Yue3QlZ=Z4S?Ylt#Hnxm^UJS>9*4fM*X*HQ)|SI~^Ej8g$6I}I zd?09O+msTD~mi(hox@-(|HI= zZk$>pJG_*>K@dSEf~w&@@|aEF|0c2-LUU+Og>f`J10{WgnS)sqJp={SguLWW1&4w~ zDo;4X94CArtt=fF`ZANOtwt&b$H2~>vFPYK|`nk?SCBVjiUWssc!~IlwRQr0IH|?Ye}}D0C}9&osg| z;{vKTt+&Xo{IDL4VtpnH#ziG}-w;)uWoXpX@j3apkmq{+cqqZ>6N*3gUZ|)X^IWbC zAa@thm-RUQ1wVQ+doQrL<5Jg*Z0?z!1Ign-RSqddhyv0gE?q?bDEk(3T!!dEkI%@y zPL3GzbRgjbwTx$v=VI!d6Fn2pqx;CXE7et7@z*ZOzROvkl1Qb~IBsr8F_A66B40Lj+N%6v{JuQrzCib%Lz zEZB(ZR#A4`f^M6Z>%Jr#nqE@1lB%0Xx3Q&R!;nXp0&EHM@pAQ*5f^-wm3EfJSXH~- zZlP-yMAA}q*L79RPz?hC0;T;ZBRv$QhsGAFJf%qxXMu?1+#>PBMpjlp>ClBRo|ui& zQJ5fLYLCRKUeI!v20%t9xOgM!49FQ(d54EQ%2L4U6KvcTnMm8>E~Y2H?;wECHX0L- zUA2Vagd)urHo=WiKz2o^&3??)WuA(Sgz|+=ka;NgCdQS7lT0K{Av)tkEsZ71l}er% zSAJn7h?wZ6hquk)Rg&?tVrYhjG{~CX)EsOYaKEUTSks2khG2o;-vKq6nvRS59XKc% zMl!NDl2Po7BqZQ%5Rw*GmS;#M1W|0s^HActttAcLiY0c*kE1U@mHvVNbiR-{b9r?_&ki#qw zdAesH(}V#|Jd5bY*xGAJ0E>)twp-0rF|cTvF4Z*8My6{~q-&OrJkR0Cb{x~T4a4=B zotN^UI&dvWA#eTB;yB6Q8udDXJSYfEXkO@Lh2|ONOc@OayToH(%%l0;HV317qfk$Kl`iBq0k-v>{waecz??7_2FE>2&TpML1_BlhO0Pt2*?XKs|f z|Ml6&Z_Hfy-HA^>KQ~wV;@ju`e*MJFZ`}9JfAHj)6Ni5~NUINCI%n43?%n!&cJAVj yYk&OGzjAHu=e6G+_;U9A`|-O^9Q*w2$J6QcV;!(p85wkrc#9f literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail2@3x.png b/Telegram/Resources/icons/bubble_tail2@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..aa368174bdb98b8a259854bcfc66bed194caef02 GIT binary patch literal 1910 zcmb_dO>Epm6n0yFvZX~4aEK5G$GIec*W;hH*P|?Hx*NJ%aEOwXk_c27k7w6b)*jb( zvbzyNr~;`KNQjmbM2G`LfS?jcQHuakQ7M;7s3%nQfZ%{Q0XH}xRgCvf{Ygs{v0B^X z@i*^%?|pCPotm3Ha&Z5n`#Fv~SSgq0+4BIq9va%q?mu7t_<8oogyrR!;~sc8z4mbL zZj5l;eP_JtQnF+{3o-Sx$e}jLw)~KxIc{>Q6(YPs65b|tFDM9qe*K-mdrm=E%vrz+ zi^TQH>k(O4pRMBc6>K`f)KmOq3o-*fNf6)i8$k?P1)*aXvT-^s348~VtQ3Ul)FHoQ z&GAJV5k8mIMJ#JM-Y~PWu4<w!4M0WVdq07Bi<}yqFFoD!#oh{n znA`vBxYE7fDK)m(AcGSFg^Hu zlLMAo%NqFDmW%HXT*S%D8VjSBkZsX%wH*>^p2T!D!enNR(Hu*o31KlJD4|i6(nepX zxjtpSSWJa6`SC?BaA-50xM2+`p@b9!1t>rSOf|U*45%vX{{&DW09~j>9k15D1*%km z40AG6!A($BH4aM9e}WwhYc%o^i`ny0ok(F&7x+OYVUady#2hnrYKMho!AcM(D8Qsr zDhMp>tmiop=W;ouszl6b1{QTiQ^h=X6w$P0HgB6qk+uH%62+^jxc&7GTd%1m2Ef)u z)zq*k15Flf+aRKD7^%cWHT%U;a%YWFt90y*9rH9Wpk z2oT}4zzYISl_ieQoA$QJz|JD*nr*s-8NG|#U06(ONfSk6y3Vq-lZuk=#6L!BcV}MH zXZ5(P8n^GL|1};dJuSPXCf!oUe`r5^l@q=Udz?4bz{$moA1Ya$G3*~t*ayZ4o#f3ULIZfJ$vl! zcfQ>G>-F)on?DvOwan3`2>9t4F P&RCh5EuB03(uscokegZ_ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index a5c1e466a..665304725 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -80,6 +80,12 @@ "ktg_settings_recent_stickers_limit_none": "Recent stickers: hide all", "ktg_settings_filters": "Folders", "ktg_settings_messages": "Messages", + "ktg_settings_userpic_rounding": "Profile pictures rounding", + "ktg_settings_userpic_rounding_none": "Square", + "ktg_settings_userpic_rounding_small": "Small", + "ktg_settings_userpic_rounding_big": "Big", + "ktg_settings_userpic_rounding_full": "Circle", + "ktg_settings_userpic_rounding_desc": "You'll need to restart app to save changes.", "ktg_settings_chat_id": "Chat ID in profile", "ktg_settings_chat_id_desc": "You can choose desired format here.\n\nTelegram API uses IDs as-is, but Bot API adds minus in the beginning for groups, and -100 for channels and supergroups to fit it in one field.\n\nIf you have profile panel opened, re-open it to see changes.", "ktg_settings_chat_id_disable": "Hide", diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index 3e96bf20f..0b4b3a498 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -345,13 +345,15 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) { if (_photo) { if (const auto image = _photo->image(Data::PhotoSize::Small)) { - const auto size = st::confirmInvitePhotoSize; + auto source = [=] { + const auto size = st::confirmInvitePhotoSize; + const auto roundOption = KotatoImageRoundOption(); + return image->pix(size, size, { .options = roundOption }); + }(); p.drawPixmap( - (width() - size) / 2, + (width() - st::confirmInvitePhotoSize) / 2, st::confirmInvitePhotoTop, - image->pix( - { size, size }, - { .options = Images::Option::RoundCircle })); + source); } } else if (_photoEmpty) { _photoEmpty->paint( diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp index 7642c050a..32c3aa1cb 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp @@ -277,7 +277,24 @@ void PaintFilterChatsTypeIcon( auto hq = PainterHighQualityEnabler(p); p.setBrush(color->b); p.setPen(Qt::NoPen); - p.drawEllipse(rect); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + p.drawRoundedRect(rect, 0, 0); + break; + + case ImageRoundRadius::Small: + p.drawRoundedRect(rect, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + p.drawRoundedRect(rect, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(rect); + } icon.paintInCenter(p, rect); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index d81ba849e..e28acd10f 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -769,7 +769,24 @@ void PeerListRow::paintDisabledCheckUserpic( p.setPen(userpicBorderPen); p.setBrush(Qt::NoBrush); - p.drawEllipse(userpicEllipse); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + p.drawRoundedRect(userpicEllipse, 0, 0); + break; + + case ImageRoundRadius::Small: + p.drawRoundedRect(userpicEllipse, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + p.drawRoundedRect(userpicEllipse, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(userpicEllipse); + } p.setPen(iconBorderPen); p.setBrush(st.disabledCheckFg); diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index da26bc1be..0e02f46e7 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "calls/calls_top_bar.h" +#include "kotato/kotato_settings.h" #include "ui/effects/cross_line.h" #include "ui/paint/blobs_linear.h" #include "ui/widgets/buttons.h" @@ -253,7 +254,8 @@ TopBar::TopBar( : std::make_unique( st::groupCallTopBarUserpics, rpl::single(true), - [=] { updateUserpics(); })) + [=] { updateUserpics(); }, + ::Kotato::JsonSettings::GetInt("userpic_corner_type"))) , _durationLabel(_call ? object_ptr(this, st::callBarLabel) : object_ptr(nullptr)) diff --git a/Telegram/SourceFiles/calls/calls_userpic.cpp b/Telegram/SourceFiles/calls/calls_userpic.cpp index cca9a096c..8d3a28d46 100644 --- a/Telegram/SourceFiles/calls/calls_userpic.cpp +++ b/Telegram/SourceFiles/calls/calls_userpic.cpp @@ -16,8 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo_media.h" #include "data/data_file_origin.h" #include "ui/empty_userpic.h" +#include "ui/rect_part.h" #include "apiwrap.h" // requestFullPeer. #include "styles/style_calls.h" +#include "styles/style_widgets.h" namespace Calls { namespace { @@ -104,7 +106,25 @@ void Userpic::paint() { _mutePosition.y() - _muteSize / 2, _muteSize, _muteSize); - p.drawEllipse(rect); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + p.drawRoundedRect(rect, 0, 0); + break; + + case ImageRoundRadius::Small: + p.drawRoundedRect(rect, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + p.drawRoundedRect(rect, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(rect); + } + st::callMutedPeerIcon.paintInCenter(p, rect); } } @@ -180,13 +200,10 @@ void Userpic::createCache(Image *image) { height = qMax((height * real) / width, 1); width = real; } - _userPhoto = image->pixNoCache( - { width, height }, - { - .options = Images::Option::RoundCircle, - .outer = { size, size }, - }); - _userPhoto.setDevicePixelRatio(cRetinaFactor()); + const auto roundOption = KotatoImageRoundOption(); + _userPhoto = image->pix(size, size, { + .options = roundOption, + .outer = { size, size }}); } else { auto filled = QImage( QSize(real, real), diff --git a/Telegram/SourceFiles/data/data_folder.cpp b/Telegram/SourceFiles/data/data_folder.cpp index cb3f51a60..fe0344598 100644 --- a/Telegram/SourceFiles/data/data_folder.cpp +++ b/Telegram/SourceFiles/data/data_folder.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "mainwidget.h" #include "styles/style_dialogs.h" +#include "styles/style_widgets.h" namespace Data { namespace { @@ -252,7 +253,24 @@ void Folder::paintUserpic( p.setBrush(overrideBg ? *overrideBg : st::historyPeerArchiveUserpicBg); { PainterHighQualityEnabler hq(p); - p.drawEllipse(x, y, size, size); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + p.drawRoundedRect(QRect{ x, y, size, size }, 0, 0); + break; + + case ImageRoundRadius::Small: + p.drawRoundedRect(QRect{ x, y, size, size }, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + p.drawRoundedRect(QRect{ x, y, size, size }, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(x, y, size, size); + } } if (size == st::dialogsPhotoSize) { const auto rect = QRect{ x, y, size, size }; diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 18433abed..359067fc7 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -271,6 +271,30 @@ void PeerData::paintUserpic( int x, int y, int size) const { + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + paintUserpicSquare(p, view, x, y, size); + break; + + case ImageRoundRadius::Small: + paintUserpicRounded(p, view, x, y, size); + break; + + case ImageRoundRadius::Large: + paintUserpicRoundedLarge(p, view, x, y, size); + break; + + default: + paintUserpicCircled(p, view, x, y, size); + } +} + +void PeerData::paintUserpicCircled( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const { if (const auto userpic = currentUserpic(view)) { const auto circled = Images::Option::RoundCircle; p.drawPixmap( @@ -282,6 +306,47 @@ void PeerData::paintUserpic( } } +void PeerData::paintUserpicRoundedLarge( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const { + if (const auto userpic = currentUserpic(view)) { + const auto rounded = Images::Option::RoundLarge; + p.drawPixmap(x, y, userpic->pix(size, size, { .options = rounded })); + } else { + ensureEmptyUserpic()->paintRoundedLarge(p, x, y, x + size + x, size); + } +} + +void PeerData::paintUserpicRounded( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const { + if (const auto userpic = currentUserpic(view)) { + const auto rounded = Images::Option::RoundSmall; + p.drawPixmap(x, y, userpic->pix(size, size, { .options = rounded })); + } else { + ensureEmptyUserpic()->paintRounded(p, x, y, x + size + x, size); + } +} + +void PeerData::paintUserpicSquare( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const { + if (const auto userpic = currentUserpic(view)) { + p.drawPixmap(x, y, userpic->pix(size, size)); + } else { + ensureEmptyUserpic()->paintSquare(p, x, y, x + size + x, size); + } +} + void PeerData::loadUserpic() { _userpic.load(&session(), userpicOrigin()); } @@ -336,7 +401,7 @@ QPixmap PeerData::genUserpic( std::shared_ptr &view, int size) const { if (const auto userpic = currentUserpic(view)) { - const auto circle = Images::Option::RoundCircle; + const auto circle = KotatoImageRoundOption(); return userpic->pix(size, size, { .options = circle }); } const auto ratio = style::DevicePixelRatio(); @@ -355,7 +420,7 @@ QPixmap PeerData::genUserpic( QImage PeerData::generateUserpicImage( std::shared_ptr &view, int size) const { - return generateUserpicImage(view, size, ImageRoundRadius::Ellipse); + return generateUserpicImage(view, size, KotatoImageRoundRadius()); } QImage PeerData::generateUserpicImage( @@ -365,6 +430,8 @@ QImage PeerData::generateUserpicImage( if (const auto userpic = currentUserpic(view)) { const auto options = (radius == ImageRoundRadius::Ellipse) ? Images::Option::RoundCircle + : (radius == ImageRoundRadius::Large) + ? Images::Option::RoundLarge : (radius == ImageRoundRadius::None) ? Images::Option() : Images::Option::RoundSmall; @@ -380,6 +447,8 @@ QImage PeerData::generateUserpicImage( Painter p(&result); if (radius == ImageRoundRadius::Ellipse) { ensureEmptyUserpic()->paint(p, 0, 0, size, size); + } else if (radius == ImageRoundRadius::Large) { + ensureEmptyUserpic()->paintRoundedLarge(p, 0, 0, size, size); } else if (radius == ImageRoundRadius::None) { ensureEmptyUserpic()->paintSquare(p, 0, 0, size, size); } else { diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 27ec1c03b..633fb2500 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -274,6 +274,30 @@ public: int size) const { paintUserpic(p, view, rtl() ? (w - x - size) : x, y, size); } + void paintUserpicCircled( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const; + void paintUserpicRoundedLarge( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const; + void paintUserpicRounded( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const; + void paintUserpicSquare( + Painter &p, + std::shared_ptr &view, + int x, + int y, + int size) const; void loadUserpic(); [[nodiscard]] bool hasUserpic() const; [[nodiscard]] std::shared_ptr activeUserpicView(); diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index b9e15930c..5f7030013 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -469,7 +469,7 @@ bool ChannelHasActiveCall(not_null channel) { rpl::producer PeerUserpicImageValue( not_null peer, int size) { - return PeerUserpicImageValue(peer, size, ImageRoundRadius::Ellipse); + return PeerUserpicImageValue(peer, size, KotatoImageRoundRadius()); } rpl::producer PeerUserpicImageValue( diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index 5d8937217..02d814ab2 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -282,8 +282,12 @@ void Row::PaintCornerBadgeFrame( ? st::dialogsOnlineBadgeFgActive : st::dialogsOnlineBadgeFg); q.drawEllipse(QRectF( - st::dialogsPhotoSize - skip.x() - size, - st::dialogsPhotoSize - skip.y() - size, + st::dialogsPhotoSize - size - + (KotatoImageRoundRadius() == ImageRoundRadius::Ellipse + ? skip.x() : -(stroke / 2)), + st::dialogsPhotoSize - size - + (KotatoImageRoundRadius() == ImageRoundRadius::Ellipse + ? skip.y() : -(stroke / 2)), size, size ).marginsRemoved({ shrink, shrink, shrink, shrink })); @@ -358,12 +362,17 @@ void Row::paintUserpic( : st::dialogsBg; const auto size = st::dialogsCallBadgeSize; const auto skip = st::dialogsCallBadgeSkip; + const auto stroke = st::dialogsOnlineBadgeStroke; p.setOpacity(shown); p.translate(st::dialogsPadding); actionPainter->paintSpeaking( p, - st::dialogsPhotoSize - skip.x() - size, - st::dialogsPhotoSize - skip.y() - size, + st::dialogsPhotoSize - size - + (KotatoImageRoundRadius() == ImageRoundRadius::Ellipse + ? skip.x() : -(stroke / 2)), + st::dialogsPhotoSize - size - + (KotatoImageRoundRadius() == ImageRoundRadius::Ellipse + ? skip.y() : -(stroke / 2)), fullWidth, bg, now); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index ad0555171..66f112501 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2668,7 +2668,7 @@ void HistoryWidget::refreshSendAsToggle() { } else if (_sendAs) { return; } - _sendAs.create(this, st::sendAsButton); + _sendAs.create(this, st::sendAsButton, ::Kotato::JsonSettings::GetInt("userpic_corner_type")); Ui::SetupSendAsButton(_sendAs.data(), controller()); } @@ -6660,7 +6660,8 @@ void HistoryWidget::setupGroupCallBar() { HistoryView::GroupCallBarContentByPeer( peer, st::historyGroupCallUserpics.size), - Core::App().appDeactivatedValue()); + Core::App().appDeactivatedValue(), + ::Kotato::JsonSettings::GetInt("userpic_corner_type")); controller()->adaptive().oneColumnValue( ) | rpl::start_with_next([=](bool one) { @@ -6711,7 +6712,8 @@ void HistoryWidget::setupRequestsBar() { this, HistoryView::RequestsBarContentByPeer( peer, - st::historyRequestsUserpics.size)); + st::historyRequestsUserpics.size), + ::Kotato::JsonSettings::GetInt("userpic_corner_type")); controller()->adaptive().oneColumnValue( ) | rpl::start_with_next([=](bool one) { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 6e33846c7..f11d7d957 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -2245,7 +2245,8 @@ bool ComposeControls::updateSendAsButton() { } _sendAs = std::make_unique( _wrap.get(), - st::sendAsButton); + st::sendAsButton, + ::Kotato::JsonSettings::GetInt("userpic_corner_type")); Ui::SetupSendAsButton( _sendAs.get(), rpl::single(peer.get()), diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index b2da03677..1a03959e8 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/history_view_context_menu.h" +#include "kotato/kotato_settings.h" #include "api/api_attached_stickers.h" #include "api/api_editing.h" #include "api/api_polls.h" @@ -1164,7 +1165,8 @@ void AddWhoReactedAction( menu.get(), Api::WhoReacted(item, context, st::defaultWhoRead, whoReadIds), participantChosen, - showAllChosen)); + showAllChosen, + ::Kotato::JsonSettings::GetInt("userpic_corner_type"))); } void ShowWhoReactedMenu( diff --git a/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp b/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp index 03a1fbe6d..b524da2d8 100644 --- a/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "calls/calls_instance.h" #include "core/application.h" #include "styles/style_chat.h" +#include "styles/style_widgets.h" namespace HistoryView { @@ -57,7 +58,24 @@ void GenerateUserpicsInRow( q.setCompositionMode(QPainter::CompositionMode_Source); q.setBrush(Qt::NoBrush); q.setPen(pen); - q.drawEllipse(x, 0, single, single); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + q.drawRoundedRect(QRect{ x, 0, single, single }, 0, 0); + break; + + case ImageRoundRadius::Small: + q.drawRoundedRect(QRect{ x, 0, single, single }, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + q.drawRoundedRect(QRect{ x, 0, single, single }, + st::dateRadius, st::dateRadius); + break; + + default: + q.drawEllipse(x, 0, single, single); + } x -= single - shift; } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp index 3222bf47a..b31d3c78d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp @@ -188,7 +188,25 @@ void Contact::draw(Painter &p, const PaintContext &context) const { PainterHighQualityEnabler hq(p); p.setBrush(p.textPalette().selectOverlay); p.setPen(Qt::NoPen); - p.drawEllipse(rthumb); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + p.drawRoundedRect(rthumb, 0, 0); + break; + + case ImageRoundRadius::Small: + p.drawRoundedRect(rthumb, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + p.drawRoundedRect(rthumb, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(rthumb); + } + } bool over = ClickHandler::showAsActive(_linkl); diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp index 516634307..f6a76e555 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp @@ -894,7 +894,24 @@ void Poll::paintRecentVoters( p.setPen(pen); p.setBrush(Qt::NoBrush); PainterHighQualityEnabler hq(p); - p.drawEllipse(x, y, size, size); + switch (KotatoImageRoundRadius()) { + case ImageRoundRadius::None: + p.drawRoundedRect(QRect{ x, y, size, size }, 0, 0); + break; + + case ImageRoundRadius::Small: + p.drawRoundedRect(QRect{ x, y, size, size }, + st::buttonRadius, st::buttonRadius); + break; + + case ImageRoundRadius::Large: + p.drawRoundedRect(QRect{ x, y, size, size }, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(x, y, size, size); + } }; if (usesBubblePattern(context)) { const auto add = st::lineWidth * 2; diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 6d69c1acb..becff9495 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -363,6 +363,10 @@ const std::map> DefinitionMap { .type = SettingType::IntSetting, .defaultValue = 20, .limitHandler = IntLimit(0, 200, 20), }}, + { "userpic_corner_type", { + .type = SettingType::IntSetting, + .defaultValue = 3, + .limitHandler = IntLimit(0, 3, 3), }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index 44bf9a196..c4140ea49 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -66,6 +66,26 @@ QString NetBoostLabel(int boost) { return QString(); } +QString UserpicRoundingLabel(int rounding) { + switch (rounding) { + case 0: + return ktr("ktg_settings_userpic_rounding_none"); + + case 1: + return ktr("ktg_settings_userpic_rounding_small"); + + case 2: + return ktr("ktg_settings_userpic_rounding_big"); + + case 3: + return ktr("ktg_settings_userpic_rounding_full"); + + default: + Unexpected("Rounding in Settings::UserpicRoundingLabel."); + } + return QString(); +} + QString ChatIdLabel(int option) { switch (option) { case 0: @@ -176,6 +196,38 @@ void SetupKotatoChats( Ui::show(Box()); }); + const auto userpicCornerButton = container->add( + object_ptr