diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index 996dd61f3..243083867 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -207,7 +207,6 @@ AyuGramSettings::AyuGramSettings() { disableNotificationsDelay = false; localPremium = false; - copyUsernameAsLink = true; // ~ Customization appIcon = AyuAssets::DEFAULT_ICON; @@ -341,10 +340,6 @@ void AyuGramSettings::set_localPremium(bool val) { localPremium = val; } -void AyuGramSettings::set_copyUsernameAsLink(bool val) { - copyUsernameAsLink = val; -} - void AyuGramSettings::set_appIcon(QString val) { appIcon = std::move(val); } diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index 53c086a9e..09b414291 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -39,7 +39,6 @@ public: bool disableNotificationsDelay; bool localPremium; - bool copyUsernameAsLink; QString appIcon; bool simpleQuotesAndReplies; @@ -98,7 +97,6 @@ public: void set_disableNotificationsDelay(bool val); void set_localPremium(bool val); - void set_copyUsernameAsLink(bool val); void set_appIcon(QString val); void set_simpleQuotesAndReplies(bool val); @@ -153,7 +151,6 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( hideSimilarChannels, disableNotificationsDelay, localPremium, - copyUsernameAsLink, appIcon, simpleQuotesAndReplies, deletedMark, diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp index f4c616da3..e674841d4 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp @@ -729,25 +729,6 @@ void SetupQoLToggles(not_null container) { AyuSettings::save(); }, container->lifetime()); - - AddButtonWithIcon( - container, - tr::ayu_CopyUsernameAsLink(), - st::settingsButtonNoIcon - )->toggleOn( - rpl::single(settings->copyUsernameAsLink) - )->toggledValue( - ) | rpl::filter( - [=](bool enabled) - { - return (enabled != settings->copyUsernameAsLink); - }) | start_with_next( - [=](bool enabled) - { - settings->set_copyUsernameAsLink(enabled); - AyuSettings::save(); - }, - container->lifetime()); } void SetupAppIcon(not_null container) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 99ebeeae4..12f41a836 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -132,8 +132,6 @@ base::options::toggle ShowPeerIdBelowAbout({ const QString &addToLink) { const auto weak = base::make_weak(controller); return [=](QString link) { - auto settings = &AyuSettings::getInstance(); - if (link.startsWith(u"internal:"_q)) { Core::App().openInternalUrl(link, QVariant::fromValue(ClickHandlerContext{ @@ -1218,6 +1216,37 @@ object_ptr DetailsFiller::setupInfo() { linkLine.text->overrideLinkClickHandler(linkCallback); linkLine.subtext->overrideLinkClickHandler(linkCallback); + const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) + { + if (!request.link) { + return; + } + const auto text = request.link->copyToClipboardContextItemText(); + if (text.isEmpty()) { + return; + } + const auto link = request.link->copyToClipboardText(); + request.menu->addAction( + text, + [=] { QGuiApplication::clipboard()->setText(link); }); + const auto last = link.lastIndexOf('/'); + if (last < 0) { + return; + } + const auto mention = '@' + link.mid(last + 1); + if (mention.size() < 2) { + return; + } + request.menu->addAction( + tr::lng_context_copy_mention(tr::now), + [=] { QGuiApplication::clipboard()->setText(mention); }); + }; + + if (!_topic) { + linkLine.text->setContextMenuHook(hook); + linkLine.subtext->setContextMenuHook(hook); + } + if (const auto channel = _topic ? nullptr : _peer->asChannel()) { auto locationText = LocationValue( channel diff --git a/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp b/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp index 5975303ee..4498becad 100644 --- a/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/collectible_info_box.cpp @@ -26,10 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -// AyuGram includes -#include "ayu/ayu_settings.h" - - namespace Ui { namespace { @@ -192,22 +188,11 @@ void CollectibleInfoBox( Ui::Text::Link(formatted), Ui::Text::WithEntities); const auto copyCallback = [box, type, formatted, text = info.copyText] { - auto toCopy = text.isEmpty() ? formatted : text; - const auto settings = &AyuSettings::getInstance(); - if (type == CollectibleType::Username) { - if (settings->copyUsernameAsLink && !text.startsWith("https://")) { - toCopy = "https://t.me/" + toCopy.replace("@", ""); - } else if (!settings->copyUsernameAsLink && !text.startsWith("@")) { - toCopy = "@" + toCopy.replace("https://t.me/", ""); - } - } - - QGuiApplication::clipboard()->setText(toCopy); + QGuiApplication::clipboard()->setText( + text.isEmpty() ? formatted : text); box->uiShow()->showToast((type == CollectibleType::Phone) ? tr::lng_text_copied(tr::now) - : settings->copyUsernameAsLink - ? tr::lng_username_copied(tr::now) // "Link copied to clipboard." - : tr::lng_text_copied(tr::now)); // "Text copied to clipboard." + : tr::lng_username_copied(tr::now)); }; box->addRow( object_ptr( diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 365acef6d..07cda692d 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 365acef6ddd58f7a19d82588ea986e23517861b7 +Subproject commit 07cda692d99a9acdea6406516fead0a1517ab032