From 4ed256814a54ecfbd4dd2b07ba2f3335e86443ff Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 13 Nov 2025 13:30:43 +0300 Subject: [PATCH] Added spoiler to box for rtmp calls. --- .../calls/group/calls_group_rtmp.cpp | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp b/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp index e62ec458d4..5d5dcc0979 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp @@ -231,7 +231,6 @@ void StartRtmpProcess::FillRtmpRows( const style::RoundButton *attentionButtonStyle, const style::PopupMenu *popupMenuStyle) { struct State { - rpl::variable hidden = true; rpl::variable key; rpl::variable url; bool warned = false; @@ -280,11 +279,11 @@ void StartRtmpProcess::FillRtmpRows( return weak; }; - const auto addLabel = [&](rpl::producer &&text) { + const auto addLabel = [&](v::text::data &&text) { const auto label = container->add( object_ptr( container, - std::move(text), + v::text::take_marked(std::move(text)), *labelStyle, *popupMenuStyle), st::boxRowPadding + QMargins(0, 0, showButtonStyle->width, 0)); @@ -319,47 +318,27 @@ void StartRtmpProcess::FillRtmpRows( st::groupCallRtmpSubsectionTitleAddPadding, subsectionTitleStyle); - auto keyLabelContent = rpl::combine( - state->hidden.value(), - state->key.value() - ) | rpl::map([passChar](bool hidden, const QString &key) { - return key.isEmpty() - ? QString() - : hidden - ? QString().fill(passChar, kPasswordCharAmount) - : key; + auto keyLabelContent = state->key.value( + ) | rpl::map([](const QString &key) { + const auto size = int(key.size()); + auto result = TextWithEntities{ key }; + if (size > 0) { + result.entities.push_back({ EntityType::Spoiler, 0, size }); + } + return result; }) | rpl::after_next([=] { container->resizeToWidth(container->widthNoMargins()); }); const auto streamKeyLabel = addLabel(std::move(keyLabelContent)); - streamKeyLabel->setSelectable(false); - const auto streamKeyButton = Ui::CreateChild( - container.get(), - *showButtonStyle); - - streamKeyLabel->topValue( - ) | rpl::start_with_next([=, right = rowPadding.right()](int top) { - streamKeyButton->moveToRight( - st::groupCallRtmpShowButtonPosition.x(), - top + st::groupCallRtmpShowButtonPosition.y()); - streamKeyButton->raise(); - }, container->lifetime()); - streamKeyButton->addClickHandler([=] { - const auto toggle = [=] { - const auto newValue = !state->hidden.current(); - state->hidden = newValue; - streamKeyLabel->setSelectable(!newValue); - streamKeyLabel->setAttribute( - Qt::WA_TransparentForMouseEvents, - newValue); - }; - if (!state->warned && state->hidden.current()) { + streamKeyLabel->setClickHandlerFilter([=]( + const ClickHandlerPtr &handler, + Qt::MouseButton button) { + if (button == Qt::LeftButton) { show->showBox(Ui::MakeConfirmBox({ .text = tr::lng_group_call_rtmp_key_warning( Ui::Text::RichLangValue), .confirmed = [=](Fn &&close) { - state->warned = true; - toggle(); + handler->onClick({}); close(); }, .confirmText = tr::lng_from_request_understand(), @@ -367,9 +346,8 @@ void StartRtmpProcess::FillRtmpRows( .confirmStyle = attentionButtonStyle, .labelStyle = labelStyle, })); - } else { - toggle(); } + return false; }); addButton(true, tr::lng_group_call_rtmp_key_copy());