From f1bf8e554ebb56709ae055d755dd3ffa8c1375fd Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 3 Mar 2026 14:44:56 +0300 Subject: [PATCH] Fixed display of show original button in translate box. --- .../boxes/translate_box_content.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/boxes/translate_box_content.cpp b/Telegram/SourceFiles/boxes/translate_box_content.cpp index daf204eee3..1e86c1d585 100644 --- a/Telegram/SourceFiles/boxes/translate_box_content.cpp +++ b/Telegram/SourceFiles/boxes/translate_box_content.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/loading_element.h" #include "ui/layers/generic_box.h" #include "ui/painter.h" +#include "ui/rect.h" #include "ui/power_saving.h" #include "ui/vertical_list.h" #include "ui/widgets/buttons.h" @@ -84,14 +85,16 @@ void TranslateBoxContent( const auto text = std::move(args.text); const auto hasCopyRestriction = args.hasCopyRestriction; const auto textContext = std::move(args.textContext); - const auto chooseTo = std::make_shared>(std::move(args.chooseTo)); + const auto chooseTo = std::make_shared>( + std::move(args.chooseTo)); const auto request = std::make_shared< Fn)>>( std::move(args.request)); auto to = std::move(args.to) | rpl::start_spawning(box->lifetime()); const auto toTitle = rpl::duplicate(to) | rpl::map(LanguageName); - const auto toDirection = rpl::duplicate(to) | rpl::map([=](LanguageId id) { + const auto toDirection = rpl::duplicate(to) | rpl::map([=]( + LanguageId id) { return id.locale().textDirection() == Qt::RightToLeft; }); @@ -133,11 +136,12 @@ void TranslateBoxContent( width - show->width() - st::boxRowPadding.right(), rect.y() + std::abs(lineHeight - show->height()) / 2); }, show->lifetime()); - original->entity()->heightValue( - ) | rpl::filter([](int height) { - return height > 0; - }) | rpl::take(1) | rpl::on_next([=](int height) { - if (height > lineHeight) { + container->widthValue( + ) | rpl::filter([](int width) { + return width > 0; + }) | rpl::take(1) | rpl::on_next([=](int width) { + if (original->entity()->textMaxWidth() + > (width - rect::m::sum::h(st::boxRowPadding))) { show->show(anim::type::instant); } }, show->lifetime());