mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added ability to open context menu for active account from main menu.
This commit is contained in:
parent
183a9139f9
commit
bcd1d8461f
1 changed files with 35 additions and 28 deletions
|
@ -746,19 +746,22 @@ void SetupAccountsWrap(
|
||||||
} else if (which != Qt::RightButton) {
|
} else if (which != Qt::RightButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (session == &window->session() || state->menu) {
|
if (state->menu) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto isActive = session == &window->session();
|
||||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
raw,
|
raw,
|
||||||
st::popupMenuExpandedSeparator);
|
st::popupMenuExpandedSeparator);
|
||||||
const auto addAction = Ui::Menu::CreateAddActionCallback(
|
const auto addAction = Ui::Menu::CreateAddActionCallback(
|
||||||
state->menu);
|
state->menu);
|
||||||
addAction(tr::lng_context_new_window(tr::now), [=] {
|
if (!isActive) {
|
||||||
Ui::PreventDelayedActivation();
|
addAction(tr::lng_context_new_window(tr::now), [=] {
|
||||||
callback(Qt::ControlModifier);
|
Ui::PreventDelayedActivation();
|
||||||
}, &st::menuIconNewWindow);
|
callback(Qt::ControlModifier);
|
||||||
Window::AddSeparatorAndShiftUp(addAction);
|
}, &st::menuIconNewWindow);
|
||||||
|
Window::AddSeparatorAndShiftUp(addAction);
|
||||||
|
}
|
||||||
|
|
||||||
addAction(tr::lng_profile_copy_phone(tr::now), [=] {
|
addAction(tr::lng_profile_copy_phone(tr::now), [=] {
|
||||||
const auto phone = rpl::variable<TextWithEntities>(
|
const auto phone = rpl::variable<TextWithEntities>(
|
||||||
|
@ -767,35 +770,39 @@ void SetupAccountsWrap(
|
||||||
}, &st::menuIconCopy);
|
}, &st::menuIconCopy);
|
||||||
|
|
||||||
if (!locked) {
|
if (!locked) {
|
||||||
addAction(tr::lng_menu_activate(tr::now), [=] {
|
if (!isActive) {
|
||||||
callback({});
|
addAction(tr::lng_menu_activate(tr::now), [=] {
|
||||||
}, &st::menuIconProfile);
|
callback({});
|
||||||
|
}, &st::menuIconProfile);
|
||||||
|
}
|
||||||
Window::MenuAddMarkAsReadAllChatsAction(
|
Window::MenuAddMarkAsReadAllChatsAction(
|
||||||
session,
|
session,
|
||||||
window->uiShow(),
|
window->uiShow(),
|
||||||
addAction);
|
addAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto logoutCallback = [=] {
|
if (!isActive) {
|
||||||
const auto callback = [=](Fn<void()> &&close) {
|
auto logoutCallback = [=] {
|
||||||
close();
|
const auto callback = [=](Fn<void()> &&close) {
|
||||||
Core::App().logoutWithChecks(&session->account());
|
close();
|
||||||
|
Core::App().logoutWithChecks(&session->account());
|
||||||
|
};
|
||||||
|
window->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
|
.text = tr::lng_sure_logout(),
|
||||||
|
.confirmed = crl::guard(session, callback),
|
||||||
|
.confirmText = tr::lng_settings_logout(),
|
||||||
|
.confirmStyle = &st::attentionBoxButton,
|
||||||
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
};
|
};
|
||||||
window->show(
|
addAction({
|
||||||
Ui::MakeConfirmBox({
|
.text = tr::lng_settings_logout(tr::now),
|
||||||
.text = tr::lng_sure_logout(),
|
.handler = std::move(logoutCallback),
|
||||||
.confirmed = crl::guard(session, callback),
|
.icon = &st::menuIconLeaveAttention,
|
||||||
.confirmText = tr::lng_settings_logout(),
|
.isAttention = true,
|
||||||
.confirmStyle = &st::attentionBoxButton,
|
});
|
||||||
}),
|
}
|
||||||
Ui::LayerOption::CloseOther);
|
|
||||||
};
|
|
||||||
addAction({
|
|
||||||
.text = tr::lng_settings_logout(tr::now),
|
|
||||||
.handler = std::move(logoutCallback),
|
|
||||||
.icon = &st::menuIconLeaveAttention,
|
|
||||||
.isAttention = true,
|
|
||||||
});
|
|
||||||
state->menu->popup(QCursor::pos());
|
state->menu->popup(QCursor::pos());
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue