From 027340a8e0434c46c28afef7386d25d750c5ca63 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 27 Jul 2017 14:24:37 +0300 Subject: [PATCH] Copy public channel link instead of following it. --- .../SourceFiles/profile/profile_block_info.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Telegram/SourceFiles/profile/profile_block_info.cpp b/Telegram/SourceFiles/profile/profile_block_info.cpp index 7f0be6082..d638790b4 100644 --- a/Telegram/SourceFiles/profile/profile_block_info.cpp +++ b/Telegram/SourceFiles/profile/profile_block_info.cpp @@ -29,6 +29,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "observer_peer.h" #include "apiwrap.h" #include "lang/lang_keys.h" +#include "ui/toast/toast.h" #include "messenger.h" namespace Profile { @@ -215,8 +216,21 @@ void InfoWidget::refreshChannelLink() { } setSingleLineLabeledText(nullptr, lang(lng_profile_link), &_channelLink, channelLinkText, QString()); setSingleLineLabeledText(&_channelLinkLabel, lang(lng_profile_link), &_channelLinkShort, channelLinkTextShort, QString()); + auto copyLinkHandlerHook = [this](const ClickHandlerPtr &handler, Qt::MouseButton button) { + if (auto channel = peer()->asChannel()) { + auto link = Messenger::Instance().createInternalLinkFull(channel->username); + QGuiApplication::clipboard()->setText(link); + Ui::Toast::Show(lang(lng_create_channel_link_copied)); + return false; + } + return true; + }; + if (_channelLink) { + _channelLink->setClickHandlerHook(copyLinkHandlerHook); + } if (_channelLinkShort) { _channelLinkShort->setExpandLinksMode(ExpandLinksUrlOnly); + _channelLinkShort->setClickHandlerHook(copyLinkHandlerHook); } }