mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
fix: copy ID from main settings
This commit is contained in:
parent
efce0f2309
commit
4926735ae1
2 changed files with 21 additions and 23 deletions
|
@ -79,7 +79,7 @@ bool TryHandleSpotify(const QString &url) {
|
||||||
// https://www.iana.org/assignments/uri-schemes/prov/spotify
|
// https://www.iana.org/assignments/uri-schemes/prov/spotify
|
||||||
|
|
||||||
using namespace qthelp;
|
using namespace qthelp;
|
||||||
const auto matchOptions = RegExOption::CaseInsensitive;
|
constexpr auto matchOptions = RegExOption::CaseInsensitive;
|
||||||
// https://regex101.com/r/l4Ogzf/2
|
// https://regex101.com/r/l4Ogzf/2
|
||||||
const auto match = regex_match(
|
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,
|
u"^(https?:\\/\\/)?([a-zA-Z0-9_]+)\\.spotify\\.com\\/(?<type>track|album|artist|user|playlist)\\/(?<identifier>[a-zA-Z0-9_\\/]+?)((\\?si=.+)?)$"_q,
|
||||||
|
|
|
@ -96,7 +96,7 @@ private:
|
||||||
void initViewers();
|
void initViewers();
|
||||||
void refreshStatusText();
|
void refreshStatusText();
|
||||||
void refreshNameGeometry(int newWidth);
|
void refreshNameGeometry(int newWidth);
|
||||||
void refreshPhoneGeometry(int newWidth);
|
void refreshIdGeometry(int newWidth);
|
||||||
void refreshUsernameGeometry(int newWidth);
|
void refreshUsernameGeometry(int newWidth);
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
@ -106,7 +106,7 @@ private:
|
||||||
|
|
||||||
object_ptr<Ui::UserpicButton> _userpic;
|
object_ptr<Ui::UserpicButton> _userpic;
|
||||||
object_ptr<Ui::FlatLabel> _name = { nullptr };
|
object_ptr<Ui::FlatLabel> _name = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _phone = { nullptr };
|
object_ptr<Ui::FlatLabel> _id = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _username = { nullptr };
|
object_ptr<Ui::FlatLabel> _username = { nullptr };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -141,29 +141,27 @@ Cover::Cover(
|
||||||
Ui::UserpicButton::Source::PeerPhoto,
|
Ui::UserpicButton::Source::PeerPhoto,
|
||||||
st::infoProfileCover.photo)
|
st::infoProfileCover.photo)
|
||||||
, _name(this, st::infoProfileCover.name)
|
, _name(this, st::infoProfileCover.name)
|
||||||
, _phone(this, st::defaultFlatLabel)
|
, _id(this, st::defaultFlatLabel)
|
||||||
, _username(this, st::infoProfileMegagroupCover.status) {
|
, _username(this, st::infoProfileMegagroupCover.status) {
|
||||||
_user->updateFull();
|
_user->updateFull();
|
||||||
|
|
||||||
_name->setSelectable(true);
|
_name->setSelectable(true);
|
||||||
_name->setContextCopyText(tr::lng_profile_copy_fullname(tr::now));
|
_name->setContextCopyText(tr::lng_profile_copy_fullname(tr::now));
|
||||||
|
|
||||||
_phone->setSelectable(true);
|
_id->setSelectable(true);
|
||||||
_phone->setContextCopyText(tr::ayu_ContextCopyID(tr::now));
|
_id->setContextCopyText(tr::ayu_ContextCopyID(tr::now));
|
||||||
const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) {
|
const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) {
|
||||||
if (request.selection.empty()) {
|
if (request.selection.empty()) {
|
||||||
const auto c = [=] {
|
const auto c = [=] {
|
||||||
auto phone = rpl::variable<TextWithEntities>(
|
auto id = IDString(_user);
|
||||||
Info::Profile::PhoneValue(_user)).current().text;
|
TextUtilities::SetClipboardText({ id });
|
||||||
phone.replace(' ', QString()).replace('-', QString());
|
|
||||||
TextUtilities::SetClipboardText({ phone });
|
|
||||||
};
|
};
|
||||||
request.menu->addAction(tr::lng_profile_copy_phone(tr::now), c);
|
request.menu->addAction(tr::ayu_ContextCopyID(tr::now), c);
|
||||||
} else {
|
} else {
|
||||||
_phone->fillContextMenu(request);
|
_id->fillContextMenu(request);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_phone->setContextMenuHook(hook);
|
_id->setContextMenuHook(hook);
|
||||||
|
|
||||||
initViewers();
|
initViewers();
|
||||||
setupChildGeometry();
|
setupChildGeometry();
|
||||||
|
@ -203,7 +201,7 @@ void Cover::setupChildGeometry() {
|
||||||
st::settingsPhotoTop,
|
st::settingsPhotoTop,
|
||||||
newWidth);
|
newWidth);
|
||||||
refreshNameGeometry(newWidth);
|
refreshNameGeometry(newWidth);
|
||||||
refreshPhoneGeometry(newWidth);
|
refreshIdGeometry(newWidth);
|
||||||
refreshUsernameGeometry(newWidth);
|
refreshUsernameGeometry(newWidth);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
@ -219,8 +217,8 @@ void Cover::initViewers() {
|
||||||
IDValue(
|
IDValue(
|
||||||
_user
|
_user
|
||||||
) | rpl::start_with_next([=](const TextWithEntities &value) {
|
) | rpl::start_with_next([=](const TextWithEntities &value) {
|
||||||
_phone->setText(value.text);
|
_id->setText(value.text);
|
||||||
refreshPhoneGeometry(width());
|
refreshIdGeometry(width());
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
Info::Profile::UsernameValue(
|
Info::Profile::UsernameValue(
|
||||||
|
@ -261,14 +259,14 @@ void Cover::refreshNameGeometry(int newWidth) {
|
||||||
_badge.move(badgeLeft, badgeTop, badgeBottom);
|
_badge.move(badgeLeft, badgeTop, badgeBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cover::refreshPhoneGeometry(int newWidth) {
|
void Cover::refreshIdGeometry(int newWidth) {
|
||||||
const auto phoneLeft = st::settingsPhoneLeft;
|
const auto idLeft = st::settingsPhoneLeft;
|
||||||
const auto phoneTop = st::settingsPhoneTop;
|
const auto idTop = st::settingsPhoneTop;
|
||||||
const auto phoneWidth = newWidth
|
const auto idWidth = newWidth
|
||||||
- phoneLeft
|
- idLeft
|
||||||
- st::infoProfileCover.rightSkip;
|
- st::infoProfileCover.rightSkip;
|
||||||
_phone->resizeToWidth(phoneWidth);
|
_id->resizeToWidth(idWidth);
|
||||||
_phone->moveToLeft(phoneLeft, phoneTop, newWidth);
|
_id->moveToLeft(idLeft, idTop, newWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cover::refreshUsernameGeometry(int newWidth) {
|
void Cover::refreshUsernameGeometry(int newWidth) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue