mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Changed behavior to copy phone number from profile sections as trimmed.
This commit is contained in:
parent
d85b668d4f
commit
e5886862c3
2 changed files with 28 additions and 1 deletions
|
@ -1150,7 +1150,19 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
PhoneOrHiddenValue(user),
|
||||
tr::lng_profile_copy_phone(tr::now)).text;
|
||||
const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) {
|
||||
phoneLabel->fillContextMenu(request);
|
||||
if (request.selection.empty()) {
|
||||
const auto callback = [=] {
|
||||
auto phone = rpl::variable<TextWithEntities>(
|
||||
PhoneOrHiddenValue(user)).current().text;
|
||||
phone.replace(' ', QString()).replace('-', QString());
|
||||
TextUtilities::SetClipboardText({ phone });
|
||||
};
|
||||
request.menu->addAction(
|
||||
tr::lng_profile_copy_phone(tr::now),
|
||||
callback);
|
||||
} else {
|
||||
phoneLabel->fillContextMenu(request);
|
||||
}
|
||||
AddPhoneMenu(request.menu, user);
|
||||
};
|
||||
phoneLabel->setContextMenuHook(hook);
|
||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "ui/widgets/continuous_sliders.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/new_badges.h"
|
||||
|
@ -144,6 +145,20 @@ Cover::Cover(
|
|||
|
||||
_phone->setSelectable(true);
|
||||
_phone->setContextCopyText(tr::lng_profile_copy_phone(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 });
|
||||
};
|
||||
request.menu->addAction(tr::lng_profile_copy_phone(tr::now), c);
|
||||
} else {
|
||||
_phone->fillContextMenu(request);
|
||||
}
|
||||
};
|
||||
_phone->setContextMenuHook(hook);
|
||||
|
||||
initViewers();
|
||||
setupChildGeometry();
|
||||
|
|
Loading…
Add table
Reference in a new issue