diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index e754c328db..8f570fe5b2 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -123,16 +123,17 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) { const auto use = controller ? &controller->window() : Core::App().activeWindow(); - if (use) { - use->show( - Ui::MakeConfirmBox({ - .text = (tr::lng_open_this_link(tr::now) - + qsl("\n\n") - + displayUrl), - .confirmed = [=](Fn hide) { hide(); open(); }, - .confirmText = tr::lng_open_link(), - }), - Ui::LayerOption::KeepOther); + auto box = Ui::MakeConfirmBox({ + .text = (tr::lng_open_this_link(tr::now) + + qsl("\n\n") + + displayUrl), + .confirmed = [=](Fn hide) { hide(); open(); }, + .confirmText = tr::lng_open_link(), + }); + if (my.show) { + my.show->showBox(std::move(box)); + } else if (use) { + use->show(std::move(box), Ui::LayerOption::KeepOther); } } else { open(); diff --git a/Telegram/SourceFiles/core/click_handler_types.h b/Telegram/SourceFiles/core/click_handler_types.h index b4d352325f..69960c4086 100644 --- a/Telegram/SourceFiles/core/click_handler_types.h +++ b/Telegram/SourceFiles/core/click_handler_types.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "ui/basic_click_handlers.h" +#include "data/data_msg_id.h" constexpr auto kPeerLinkPeerIdProperty = 0x01; constexpr auto kPhotoLinkMediaProperty = 0x02; @@ -15,6 +16,10 @@ constexpr auto kDocumentLinkMediaProperty = 0x03; constexpr auto kSendReactionEmojiProperty = 0x04; constexpr auto kReactionsCountEmojiProperty = 0x05; +namespace Ui { +class Show; +} // namespace Ui + namespace Main { class Session; } // namespace Main @@ -35,6 +40,7 @@ struct ClickHandlerContext { // Is filled from sections. Fn elementDelegate; base::weak_ptr sessionWindow; + std::shared_ptr show; bool skipBotAutoLogin = false; bool botStartAutoSubmit = false; // Is filled from peer info. diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.cpp b/Telegram/SourceFiles/payments/payments_checkout_process.cpp index 8f3bf7fbd5..c64908ebd9 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.cpp +++ b/Telegram/SourceFiles/payments/payments_checkout_process.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/local_url_handlers.h" // TryConvertUrlToLocal. #include "core/file_utilities.h" // File::OpenUrl. #include "core/core_cloud_password.h" // Core::CloudPasswordState +#include "core/click_handler_types.h" #include "lang/lang_keys.h" #include "apiwrap.h" #include "api/api_cloud_password.h" @@ -808,6 +809,12 @@ void CheckoutProcess::panelShowBox(object_ptr box) { _panel->showBox(std::move(box)); } +QVariant CheckoutProcess::panelClickHandlerContext() { + return QVariant::fromValue(ClickHandlerContext{ + .show = _panel->uiShow(), + }); +} + void CheckoutProcess::performInitialSilentValidation() { const auto &invoice = _form->invoice(); const auto &saved = _form->information(); diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.h b/Telegram/SourceFiles/payments/payments_checkout_process.h index 121d15a037..aaa8055103 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.h +++ b/Telegram/SourceFiles/payments/payments_checkout_process.h @@ -147,6 +147,7 @@ private: Ui::UncheckedCardDetails data, bool saveInformation) override; void panelShowBox(object_ptr box) override; + QVariant panelClickHandlerContext(); QString panelWebviewDataPath() override; diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index ba36f22c3f..18e5a7cdc0 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/format_values.h" #include "ui/text/text_utilities.h" #include "ui/effects/radial_animation.h" +#include "ui/click_handler.h" #include "lang/lang_keys.h" #include "webview/webview_embed.h" #include "webview/webview_interface.h" @@ -679,6 +680,17 @@ void Panel::requestTermsAcceptance( st::boxRowPadding.right(), st::defaultBoxCheckbox.margin.bottom(), }); + row->setAllowTextLines(5); + row->setClickHandlerFilter([=]( + const ClickHandlerPtr &link, + Qt::MouseButton button) { + ActivateClickHandler(_widget.get(), link, ClickContext{ + .button = button, + .other = _delegate->panelClickHandlerContext(), + }); + return false; + }); + (*update) = [=] { row->update(); }; struct State { @@ -830,6 +842,10 @@ void Panel::showCriticalError(const TextWithEntities &text) { } } +std::shared_ptr Panel::uiShow() { + return _widget->uiShow(); +} + void Panel::showWebviewError( const QString &text, const Webview::Available &information) { diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.h b/Telegram/SourceFiles/payments/ui/payments_panel.h index d484592ec2..d44351c84c 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/object_ptr.h" namespace Ui { +class Show; class RpWidget; class SeparatePanel; class BoxContent; @@ -85,6 +86,7 @@ public: void showBox(object_ptr box); void showToast(const TextWithEntities &text); void showCriticalError(const TextWithEntities &text); + [[nodiscard]] std::shared_ptr uiShow(); [[nodiscard]] rpl::lifetime &lifetime(); diff --git a/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h b/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h index e147c67f23..d65bc81a74 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h @@ -53,6 +53,7 @@ public: Ui::UncheckedCardDetails data, bool saveInformation) = 0; virtual void panelShowBox(object_ptr box) = 0; + virtual QVariant panelClickHandlerContext() = 0; virtual QString panelWebviewDataPath() = 0; }; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 6f856ce495..b305df8cc5 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 6f856ce495872bb202be03c056fdbcd13ec162f3 +Subproject commit b305df8cc5c853b564ec0fe0b8b121c2a4e10b19