From 38f7f48c178ed2ef6a5cde4f3a08e33798246c03 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 11 Dec 2017 12:56:43 +0400 Subject: [PATCH] Open links in AboutBox without confirmation. Fixes #4148. --- Telegram/SourceFiles/boxes/about_box.cpp | 12 ++++++++++++ Telegram/SourceFiles/core/click_handler_types.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index 2e235a760..bb5b27edc 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -30,6 +30,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "ui/widgets/labels.h" #include "styles/style_boxes.h" #include "platform/platform_file_utilities.h" +#include "core/click_handler_types.h" AboutBox::AboutBox(QWidget *parent) : _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (cAlphaVersion() ? " alpha" : "") + (cBetaVersion() ? qsl(" beta %1").arg(cBetaVersion()) : QString())), st::aboutVersionLink) @@ -43,7 +44,18 @@ void AboutBox::prepare() { addButton(langFactory(lng_close), [this] { closeBox(); }); + const auto linkHook = [](const ClickHandlerPtr &link, auto button) { + if (const auto url = dynamic_cast(link.data())) { + url->UrlClickHandler::onClick(button); + return false; + } + return true; + }; + _text3->setRichText(lng_about_text_3(lt_faq_open, qsl("[a href=\"%1\"]").arg(telegramFaqLink()), lt_faq_close, qsl("[/a]"))); + _text1->setClickHandlerHook(linkHook); + _text2->setClickHandlerHook(linkHook); + _text3->setClickHandlerHook(linkHook); _version->setClickedCallback([this] { showVersionHistory(); }); diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index cf7d14aa9..c77be53c5 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -143,7 +143,7 @@ void HiddenUrlClickHandler::doOpen(QString url) { Ui::show(Box(lang(lng_open_this_link) + qsl("\n\n") + displayUrl, lang(lng_open_link), [urlText] { Ui::hideLayer(); UrlClickHandler::doOpen(urlText); - })); + }), LayerOption::KeepOther); } else { UrlClickHandler::doOpen(urlText); }