From 4926735ae12fe7d2b83c4549b5ac6825109916cc Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Wed, 15 Jan 2025 13:14:43 +0300 Subject: [PATCH] fix: copy ID from main settings --- Telegram/SourceFiles/ayu/ayu_url_handlers.cpp | 2 +- .../SourceFiles/settings/settings_main.cpp | 42 +++++++++---------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Telegram/SourceFiles/ayu/ayu_url_handlers.cpp b/Telegram/SourceFiles/ayu/ayu_url_handlers.cpp index 446b5a323..b9ba6b942 100644 --- a/Telegram/SourceFiles/ayu/ayu_url_handlers.cpp +++ b/Telegram/SourceFiles/ayu/ayu_url_handlers.cpp @@ -79,7 +79,7 @@ bool TryHandleSpotify(const QString &url) { // https://www.iana.org/assignments/uri-schemes/prov/spotify using namespace qthelp; - const auto matchOptions = RegExOption::CaseInsensitive; + constexpr auto matchOptions = RegExOption::CaseInsensitive; // https://regex101.com/r/l4Ogzf/2 const auto match = regex_match( u"^(https?:\\/\\/)?([a-zA-Z0-9_]+)\\.spotify\\.com\\/(?track|album|artist|user|playlist)\\/(?[a-zA-Z0-9_\\/]+?)((\\?si=.+)?)$"_q, diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 4a51ca7de..4b9232aac 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -96,7 +96,7 @@ private: void initViewers(); void refreshStatusText(); void refreshNameGeometry(int newWidth); - void refreshPhoneGeometry(int newWidth); + void refreshIdGeometry(int newWidth); void refreshUsernameGeometry(int newWidth); const not_null _controller; @@ -106,7 +106,7 @@ private: object_ptr _userpic; object_ptr _name = { nullptr }; - object_ptr _phone = { nullptr }; + object_ptr _id = { nullptr }; object_ptr _username = { nullptr }; }; @@ -141,29 +141,27 @@ Cover::Cover( Ui::UserpicButton::Source::PeerPhoto, st::infoProfileCover.photo) , _name(this, st::infoProfileCover.name) -, _phone(this, st::defaultFlatLabel) +, _id(this, st::defaultFlatLabel) , _username(this, st::infoProfileMegagroupCover.status) { _user->updateFull(); _name->setSelectable(true); _name->setContextCopyText(tr::lng_profile_copy_fullname(tr::now)); - _phone->setSelectable(true); - _phone->setContextCopyText(tr::ayu_ContextCopyID(tr::now)); + _id->setSelectable(true); + _id->setContextCopyText(tr::ayu_ContextCopyID(tr::now)); const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) { if (request.selection.empty()) { const auto c = [=] { - auto phone = rpl::variable( - Info::Profile::PhoneValue(_user)).current().text; - phone.replace(' ', QString()).replace('-', QString()); - TextUtilities::SetClipboardText({ phone }); + auto id = IDString(_user); + TextUtilities::SetClipboardText({ id }); }; - request.menu->addAction(tr::lng_profile_copy_phone(tr::now), c); + request.menu->addAction(tr::ayu_ContextCopyID(tr::now), c); } else { - _phone->fillContextMenu(request); + _id->fillContextMenu(request); } }; - _phone->setContextMenuHook(hook); + _id->setContextMenuHook(hook); initViewers(); setupChildGeometry(); @@ -203,7 +201,7 @@ void Cover::setupChildGeometry() { st::settingsPhotoTop, newWidth); refreshNameGeometry(newWidth); - refreshPhoneGeometry(newWidth); + refreshIdGeometry(newWidth); refreshUsernameGeometry(newWidth); }, lifetime()); } @@ -219,8 +217,8 @@ void Cover::initViewers() { IDValue( _user ) | rpl::start_with_next([=](const TextWithEntities &value) { - _phone->setText(value.text); - refreshPhoneGeometry(width()); + _id->setText(value.text); + refreshIdGeometry(width()); }, lifetime()); Info::Profile::UsernameValue( @@ -261,14 +259,14 @@ void Cover::refreshNameGeometry(int newWidth) { _badge.move(badgeLeft, badgeTop, badgeBottom); } -void Cover::refreshPhoneGeometry(int newWidth) { - const auto phoneLeft = st::settingsPhoneLeft; - const auto phoneTop = st::settingsPhoneTop; - const auto phoneWidth = newWidth - - phoneLeft +void Cover::refreshIdGeometry(int newWidth) { + const auto idLeft = st::settingsPhoneLeft; + const auto idTop = st::settingsPhoneTop; + const auto idWidth = newWidth + - idLeft - st::infoProfileCover.rightSkip; - _phone->resizeToWidth(phoneWidth); - _phone->moveToLeft(phoneLeft, phoneTop, newWidth); + _id->resizeToWidth(idWidth); + _id->moveToLeft(idLeft, idTop, newWidth); } void Cover::refreshUsernameGeometry(int newWidth) {