fix: copy ID from main settings

This commit is contained in:
AlexeyZavar 2025-01-15 13:14:43 +03:00
parent efce0f2309
commit 4926735ae1
2 changed files with 21 additions and 23 deletions

View file

@ -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\\/(?<type>track|album|artist|user|playlist)\\/(?<identifier>[a-zA-Z0-9_\\/]+?)((\\?si=.+)?)$"_q,

View file

@ -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<Window::SessionController*> _controller;
@ -106,7 +106,7 @@ private:
object_ptr<Ui::UserpicButton> _userpic;
object_ptr<Ui::FlatLabel> _name = { nullptr };
object_ptr<Ui::FlatLabel> _phone = { nullptr };
object_ptr<Ui::FlatLabel> _id = { nullptr };
object_ptr<Ui::FlatLabel> _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<TextWithEntities>(
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) {