Updated code to be consistent with lib_ui.

This commit is contained in:
23rd 2021-01-13 04:10:25 +03:00 committed by John Preston
parent 97e8c0956f
commit 1ccfcc824c
9 changed files with 23 additions and 11 deletions

View file

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

View file

@ -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<Ui::PopupMenu>(this);
currentTab()->widget()->fillContextMenu(_menu, type);
if (!_menu->actions().empty()) {
if (!_menu->empty()) {
_menu->popup(QCursor::pos());
}
}

View file

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

View file

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

View file

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

View file

@ -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) {

View file

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

View file

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

View file

@ -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<QPointer<QAction>>();
auto action = _menu->addAction(tr::lng_menu_night_mode(tr::now), [=] {
auto nightCallback = [=] {
if (Window::Theme::Background()->editingTheme()) {
Ui::show(Box<InformBox>(
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<Ui::Menu::Toggle>(
_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());