From 8bc2d3184a631cea181ff9b635449aeb0a40b6fe Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 30 Aug 2025 22:39:46 +0300 Subject: [PATCH] Added lottie icon to transcribe voices while loading. --- .../animations/transcribe_loading.tgs | Bin 0 -> 1343 bytes .../Resources/qrc/telegram/animations.qrc | 1 + .../view/media/history_view_document.cpp | 22 ++++++++++++++---- Telegram/SourceFiles/ui/chat/chat.style | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 Telegram/Resources/animations/transcribe_loading.tgs diff --git a/Telegram/Resources/animations/transcribe_loading.tgs b/Telegram/Resources/animations/transcribe_loading.tgs new file mode 100644 index 0000000000000000000000000000000000000000..f63b6e9a0282ce376f89348b9f7477b725c0bfd0 GIT binary patch literal 1343 zcmV-F1;F|riwFp_wn1b717vS>b6;$4VPt7;XD(`UZ*BnX9LtWIKfjBoP!y}L0 z`c`k1TJ=(`Dw<82Xp;~DeW}`iFEf)87~3!dWS_$!0-G7zV|#4uz~2kUaeunc9XIl3 z9&?}Z>s49+CS!5FITYveG&!8WzlzgvCQjEU=zhm%S}fw%NuJ5MuCA`i3F0hU7VziJ zm*UEC{)%5t<4O!mc89NHF-kz?WUmUS!%ol&Z{m6z|5>J|Iji#ue1(1q+w3`v)nNG_ zE>R668TgQF_IZT^fyz=a!8K>1N}8`20P$5&`H{oMbe9l#LXbhEwic5E*|EvA$4 z;ZrpjpC3iuoYI9qjSO{RYJy-ZY6cHsd;^f|Y;jyg;jk*=$e!+^K){O1@Br9$w;b9S zGh(yA1mz#Gv5&bSqAgWeLJSzK+Qop8-B1i9u+u<2Il#`1$x*qg$>hcfNQ$y`d{{y& z1agZ+$^D+Xkgwbz?(acbrclV%fPx%}YEht&6s*Ld>iR#99CnNnxMT8z#&F}EdXs5@ z6O{+%q4GfYwRW0>h&6_Wrg`7QY?G3}kgT|L{Nl%BTAFSoAD*Ebo50T=y8s@-Dt83_ z;2N2d*{eJT*GIdUXONNwVP`RoO<+-&K%V|sqIfhVFHD_^50N$xpc++TzU{~~OWNAo&33DAYwyzdu-+^RYvbe2Y-~Bq zF$ET@L>*DX8=JZ5=zBZ%cvL~%wIKQ>jvje8B?##o*fWwm8im1<0os{53e)J$lY6kG zO!ZYtKNR&_2K}8i>){^*ZLD&S{FKJ~Y?Y)t7w%{Z1U{|HDMWBa_E~p-Kx-=tqUM6{ z=TvC}+rY6Tf!edH($yrZw1rBLXb-WOQdP*oeNu!HQdxM-#!YQi+8Q^$ZQR(#O)D8- zr6s1RE_)|k8|FLj#%fc4v46mJss1{h23N9uG~G!(VxdCd9Mh zBd?F!HyUh>Tp4L=#&4BglSy4T3>;)RAj|Mc%j@%G#>SwC{ z+ksj~S3gZ9W5)@Ne-kTRuHK`c(5lzd)oKFpOlXIg7lPV(#n`}hLrjTHh&CNScqAsQ zZ@j*eMu*CiTy@92gsjwGFsWCes=TQlt;d^MeFlIQ?wBTbY8cbvZtf}nS_Xi6yh8Y! zH1T(#@Tt`8#CPSQ(../../animations/edit_peers/topics_list.tgs ../../animations/edit_peers/direct_messages.tgs ../../animations/no_chats.tgs + ../../animations/transcribe_loading.tgs ../../animations/dice/dice_idle.tgs ../../animations/dice/dart_idle.tgs diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index 2f0030cdec..2a14dd78e6 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "lottie/lottie_icon.h" #include "storage/localstorage.h" +#include "lottie/lottie_icon.h" #include "main/main_session.h" #include "media/player/media_player_float.h" // Media::Player::RoundPainter. #include "media/audio/media_audio.h" @@ -25,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/media/history_view_media_common.h" #include "ui/text/format_values.h" #include "ui/text/format_song_document_name.h" +#include "ui/text/text_lottie_custom_emoji.h" #include "ui/text/text_utilities.h" #include "ui/chat/chat_style.h" #include "ui/painter.h" @@ -440,15 +442,23 @@ QSize Document::countOptimalSize() { voice->transcribe->setLoading( entry.shown && (entry.requestId || entry.pending), update); + const auto pending = entry.pending; + auto descriptor = pending + ? Lottie::IconDescriptor{ + .name = u"transcribe_loading"_q, + .sizeOverride = Size(st::historyTranscribeLoadingSize), + } + : Lottie::IconDescriptor(); auto text = (entry.requestId || !entry.shown) ? TextWithEntities() : entry.toolong ? Ui::Text::Italic(tr::lng_audio_transcribe_long(tr::now)) : entry.failed ? Ui::Text::Italic(tr::lng_attach_failed(tr::now)) - : TextWithEntities{ - entry.result + (entry.pending ? " [...]" : ""), - }; + : TextWithEntities(entry.result).append( + pending + ? Ui::Text::LottieEmoji(descriptor) + : TextWithEntities()); voice->transcribe->setOpened( !text.empty(), creating ? Fn() : update); @@ -461,7 +471,11 @@ QSize Document::countOptimalSize() { voice->transcribeText = Ui::Text::String(minResizeWidth); voice->transcribeText.setMarkedText( st::messageTextStyle, - text); + text, + kMarkupTextOptions, + pending + ? Ui::Text::LottieEmojiContext(std::move(descriptor)) + : Ui::Text::MarkedContext()); hasTranscribe = true; if (const auto skipBlockWidth = _parent->hasVisibleText() ? 0 diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index a2ed0b4544..dd4c670b74 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -528,6 +528,7 @@ historyVoiceMessageOutTTLSelected: icon {{ "chat/mini_media_once", historyFileOu historyTranscribeSkip: 10px; historyTranscribeSize: size(28px, 22px); historyTranscribeRadius: 4px; +historyTranscribeLoadingSize: 24px; historyTranscribeInIcon: icon {{ "chat/voice_to_text", msgFileInBg }}; historyTranscribeInIconSelected: icon {{ "chat/voice_to_text", msgFileInBgSelected }}; historyTranscribeOutIcon: icon {{ "chat/voice_to_text", msgFileOutBg }};