diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 3b939b3d72..36eddd08eb 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -1138,7 +1138,7 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) { SendMenu::DefaultSilentCallback(send), SendMenu::DefaultScheduleCallback(this, type, send)); - if (!_menu->actions().empty()) { + if (!_menu->empty()) { _menu->popup(QCursor::pos()); } } diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index cc0330d844..9b9a929107 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -594,7 +594,7 @@ bool TabbedSelector::preventAutoHide() const { } bool TabbedSelector::hasMenu() const { - return (_menu && !_menu->actions().empty()); + return (_menu && !_menu->empty()); } QImage TabbedSelector::grabForAnimation() { @@ -881,7 +881,7 @@ void TabbedSelector::showMenuWithType(SendMenu::Type type) { _menu = base::make_unique_q(this); currentTab()->widget()->fillContextMenu(_menu, type); - if (!_menu->actions().empty()) { + if (!_menu->empty()) { _menu->popup(QCursor::pos()); } } diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 67adfa4f3e..90da5d83fe 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -1841,7 +1841,7 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) { selectByMouse(globalPosition); } }); - if (_menu->actions().empty()) { + if (_menu->empty()) { _menu = nullptr; } else { _menu->popup(e->globalPos()); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 923b8d3160..f96a4e4760 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1177,7 +1177,7 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } - if (_menu->actions().empty()) { + if (_menu->empty()) { _menu = nullptr; } else { _menu->popup(e->globalPos()); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index e70464ef0a..755dd33870 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1851,7 +1851,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } - if (_menu->actions().empty()) { + if (_menu->empty()) { _menu = nullptr; } else { _menu->popup(e->globalPos()); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index dc07f3a48d..e75789e2af 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -1832,7 +1832,7 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { _overState)); _menu = FillContextMenu(this, request); - if (_menu && !_menu->actions().empty()) { + if (_menu && !_menu->empty()) { _menu->popup(e->globalPos()); e->accept(); } else if (_menu) { diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index a681768bf6..1a654ee208 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -256,7 +256,7 @@ void TopBarWidget::showMenu() { _controller, _activeChat, addAction); - if (_menu->actions().empty()) { + if (_menu->empty()) { _menu.destroy(); } else { _menu->moveToRight((parentWidget()->width() - width()) + st::topBarMenuPosition.x(), st::topBarMenuPosition.y()); diff --git a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp index 4507e698aa..e44caf6fe8 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp @@ -305,7 +305,7 @@ void Inner::contextMenuEvent(QContextMenuEvent *e) { SendMenu::DefaultSilentCallback(send), SendMenu::DefaultScheduleCallback(this, type, send)); - if (!_menu->actions().empty()) { + if (!_menu->empty()) { _menu->popup(QCursor::pos()); } } diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 0c36684e65..a59bd03423 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/menu/menu.h" #include "ui/widgets/menu/menu_common.h" +#include "ui/widgets/menu/menu_toggle.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/scroll_area.h" #include "ui/widgets/shadow.h" @@ -905,7 +906,8 @@ void MainMenu::refreshMenu() { }, &st::mainMenuSettings, &st::mainMenuSettingsOver); _nightThemeAction = std::make_shared>(); - auto action = _menu->addAction(tr::lng_menu_night_mode(tr::now), [=] { + + auto nightCallback = [=] { if (Window::Theme::Background()->editingTheme()) { Ui::show(Box( tr::lng_theme_editor_cant_change_theme(tr::now))); @@ -924,7 +926,17 @@ void MainMenu::refreshMenu() { Window::Theme::ToggleNightModeWithConfirmation( &_controller->window(), toggle); - }, &st::mainMenuNightMode, &st::mainMenuNightModeOver); + }; + + auto item = base::make_unique_q( + _menu, + st::mainMenu, + tr::lng_menu_night_mode(tr::now), + std::move(nightCallback), + &st::mainMenuNightMode, + &st::mainMenuNightModeOver); + + auto action = _menu->addAction(std::move(item)); *_nightThemeAction = action; action->setCheckable(true); action->setChecked(Window::Theme::IsNightMode());