mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-05-09 11:39:52 +00:00
Replaced dropdown menu with popup in box for revenue sponsored messages.
This commit is contained in:
parent
3895e6d958
commit
e25cf27ba5
@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/vertical_list.h"
|
#include "ui/vertical_list.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/dropdown_menu.h"
|
|
||||||
#include "ui/widgets/label_with_custom_emoji.h"
|
#include "ui/widgets/label_with_custom_emoji.h"
|
||||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||||
@ -241,28 +240,18 @@ void AboutBox(
|
|||||||
width - top->width() - st::defaultScrollArea.width,
|
width - top->width() - st::defaultScrollArea.width,
|
||||||
0);
|
0);
|
||||||
}, top->lifetime());
|
}, top->lifetime());
|
||||||
using MenuPtr = base::unique_qptr<Ui::DropdownMenu>;
|
using MenuPtr = base::unique_qptr<Ui::PopupMenu>;
|
||||||
const auto menu = top->lifetime().make_state<MenuPtr>();
|
const auto menu = top->lifetime().make_state<MenuPtr>();
|
||||||
top->setClickedCallback([=] {
|
top->setClickedCallback([=] {
|
||||||
if (const auto raw = menu->get()) {
|
*menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
raw->hideAnimated();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*menu = base::make_unique_q<Ui::DropdownMenu>(
|
|
||||||
box->window(),
|
box->window(),
|
||||||
st::dropdownMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
const auto raw = menu->get();
|
const auto raw = menu->get();
|
||||||
top->installEventFilter(raw);
|
raw->animatePhaseValue(
|
||||||
raw->setHiddenCallback([=] {
|
) | rpl::start_with_next([=](Ui::PopupMenu::AnimatePhase phase) {
|
||||||
raw->deleteLater();
|
top->setForceRippled(phase == Ui::PopupMenu::AnimatePhase::Shown
|
||||||
top->setForceRippled(false);
|
|| phase == Ui::PopupMenu::AnimatePhase::StartShow);
|
||||||
});
|
}, top->lifetime());
|
||||||
raw->setShowStartCallback([=] {
|
|
||||||
top->setForceRippled(true);
|
|
||||||
});
|
|
||||||
raw->setHideStartCallback([=] {
|
|
||||||
top->setForceRippled(false);
|
|
||||||
});
|
|
||||||
FillSponsored(
|
FillSponsored(
|
||||||
top,
|
top,
|
||||||
Ui::Menu::CreateAddActionCallback(menu->get()),
|
Ui::Menu::CreateAddActionCallback(menu->get()),
|
||||||
@ -270,14 +259,13 @@ void AboutBox(
|
|||||||
fullId,
|
fullId,
|
||||||
false,
|
false,
|
||||||
true);
|
true);
|
||||||
const auto global = box->mapToGlobal(
|
const auto global = top->mapToGlobal(
|
||||||
|
QPoint(top->width() / 4 * 3, top->height() / 2));
|
||||||
|
raw->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight);
|
||||||
|
raw->popup(
|
||||||
QPoint(
|
QPoint(
|
||||||
st::defaultScrollArea.width - st::lineWidth * 2,
|
global.x(),
|
||||||
top->height() / 2));
|
std::max(global.y(), QCursor::pos().y())));
|
||||||
const auto local = box->window()->mapFromGlobal(global);
|
|
||||||
raw->moveToRight(local.x(), local.y());
|
|
||||||
raw->raise();
|
|
||||||
raw->showAnimated(Ui::PanelAnimation::Origin::TopRight);
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user