mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 15:05:56 +00:00
Changed behavior to copy phone number from profile sections as trimmed.
This commit is contained in:
@@ -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) {
|
||||
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();
|
||||
|
Reference in New Issue
Block a user