From 2ef06a0baacf789a0930bd8816ad3e3eacd2547e Mon Sep 17 00:00:00 2001 From: Soltan Tekeev Date: Fri, 18 Mar 2016 22:13:12 +0300 Subject: [PATCH] Add "Copy name" option (Requested in #1783) Also add lng_profile_copy_fullname to lang.strings Signed-off-by: Soltan Tekeev (github: stek29) --- Telegram/Resources/lang.strings | 1 + Telegram/SourceFiles/profilewidget.cpp | 10 +++++++++- Telegram/SourceFiles/profilewidget.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/lang.strings b/Telegram/Resources/lang.strings index 9039db9024..8552a51da7 100644 --- a/Telegram/Resources/lang.strings +++ b/Telegram/Resources/lang.strings @@ -455,6 +455,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org "lng_profile_shared_links" = "{count:_not_used_|# shared link|# shared links} ยป"; "lng_profile_shared_links_header" = "Shared links overview"; "lng_profile_copy_phone" = "Copy phone number"; +"lng_profile_copy_fullname" = "Copy name"; "lng_channel_add_admins" = "New administrator"; "lng_channel_add_members" = "Add members"; diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index c28c5fba1a..b74ff68905 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -1503,10 +1503,13 @@ void ProfileInner::contextMenuEvent(QContextMenuEvent *e) { _menu->deleteLater(); _menu = 0; } - if (!_phoneText.isEmpty() || (_peerUser && !_peerUser->username.isEmpty())) { + if (!_phoneText.isEmpty() || _peerUser) { QRect info(_left + st::profilePhotoSize + st::profilePhoneLeft, st::profilePadding.top(), _width - st::profilePhotoSize - st::profilePhoneLeft, st::profilePhotoSize); if (info.contains(mapFromGlobal(e->globalPos()))) { _menu = new PopupMenu(); + if (_peerUser) { + _menu->addAction(lang(lng_profile_copy_fullname), this, SLOT(onCopyFullName()))->setEnabled(true); + } if (!_phoneText.isEmpty()) { _menu->addAction(lang(lng_profile_copy_phone), this, SLOT(onCopyPhone()))->setEnabled(true); } @@ -1526,6 +1529,11 @@ void ProfileInner::onMenuDestroy(QObject *obj) { } } +void ProfileInner::onCopyFullName() { + if (!_peerUser) return; + QApplication::clipboard()->setText(lng_full_name(lt_first_name, _peerUser->firstName, lt_last_name, _peerUser->lastName)); +} + void ProfileInner::onCopyPhone() { QApplication::clipboard()->setText(_phoneText); } diff --git a/Telegram/SourceFiles/profilewidget.h b/Telegram/SourceFiles/profilewidget.h index 23b6fcd029..0587884ff1 100644 --- a/Telegram/SourceFiles/profilewidget.h +++ b/Telegram/SourceFiles/profilewidget.h @@ -109,6 +109,7 @@ public slots: void onMediaLinks(); void onMenuDestroy(QObject *obj); + void onCopyFullName(); void onCopyPhone(); void onCopyUsername();