Added ability to copy phone number from main menu.
This commit is contained in:
parent
1878061c9a
commit
3bdf1634a9
|
@ -223,7 +223,7 @@ void ShowMenu(
|
|||
QWidget *parent,
|
||||
const QString ©Button,
|
||||
const QString &text) {
|
||||
const auto menu = new Ui::PopupMenu(parent);
|
||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(parent);
|
||||
|
||||
menu->addAction(copyButton, [=] {
|
||||
QGuiApplication::clipboard()->setText(text);
|
||||
|
@ -568,6 +568,12 @@ void SetupAccountsWrap(
|
|||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
raw,
|
||||
st::popupMenuWithIcons);
|
||||
addAction(tr::lng_profile_copy_phone(tr::now), [=] {
|
||||
const auto phone = rpl::variable<TextWithEntities>(
|
||||
Info::Profile::PhoneValue(session->user()));
|
||||
QGuiApplication::clipboard()->setText(phone.current().text);
|
||||
}, &st::menuIconCopy);
|
||||
|
||||
addAction(tr::lng_menu_activate(tr::now), [=] {
|
||||
Core::App().domain().activate(&session->account());
|
||||
}, &st::menuIconProfile);
|
||||
|
|
|
@ -65,6 +65,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QScreen>
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
|
||||
namespace Window {
|
||||
namespace {
|
||||
|
||||
|
@ -568,7 +571,20 @@ void MainMenu::setupAccounts() {
|
|||
|
||||
void MainMenu::setupAccountsToggle() {
|
||||
_toggleAccounts->show();
|
||||
_toggleAccounts->setClickedCallback([=] { toggleAccounts(); });
|
||||
_toggleAccounts->setAcceptBoth();
|
||||
_toggleAccounts->addClickHandler([=](Qt::MouseButton button) {
|
||||
if (button == Qt::LeftButton) {
|
||||
toggleAccounts();
|
||||
} else if (button == Qt::RightButton) {
|
||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
||||
_toggleAccounts.data());
|
||||
|
||||
menu->addAction(tr::lng_profile_copy_phone(tr::now), [=] {
|
||||
QGuiApplication::clipboard()->setText(_phoneText);
|
||||
});
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainMenu::parentResized() {
|
||||
|
|
Loading…
Reference in New Issue