Add "Copy name" option (Requested in #1783)

Also add lng_profile_copy_fullname to lang.strings

Signed-off-by: Soltan Tekeev <stek29@yandex.ru> (github: stek29)
This commit is contained in:
Soltan Tekeev 2016-03-18 22:13:12 +03:00
parent ddc802c0af
commit 2ef06a0baa
3 changed files with 11 additions and 1 deletions

View File

@ -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";

View File

@ -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);
}

View File

@ -109,6 +109,7 @@ public slots:
void onMediaLinks();
void onMenuDestroy(QObject *obj);
void onCopyFullName();
void onCopyPhone();
void onCopyUsername();