Set fixed position of mute menu in profile top bar.
This commit is contained in:
@@ -368,7 +368,8 @@ void SetupMuteMenu(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<> triggers,
|
||||
Fn<std::optional<Descriptor>()> makeDescriptor,
|
||||
std::shared_ptr<Ui::Show> show) {
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
Fn<QPoint()> positionCallback) {
|
||||
struct State {
|
||||
base::unique_qptr<Ui::PopupMenu> menu;
|
||||
};
|
||||
@@ -383,7 +384,9 @@ void SetupMuteMenu(
|
||||
parent,
|
||||
st::popupMenuWithIcons);
|
||||
FillMuteMenu(state->menu.get(), *descriptor, show);
|
||||
state->menu->popup(QCursor::pos());
|
||||
state->menu->popup(positionCallback
|
||||
? positionCallback()
|
||||
: QCursor::pos());
|
||||
}
|
||||
}, parent->lifetime());
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ void SetupMuteMenu(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<> triggers,
|
||||
Fn<std::optional<Descriptor>()> makeDescriptor,
|
||||
std::shared_ptr<Ui::Show> show);
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
Fn<QPoint()> positionCallback = nullptr);
|
||||
|
||||
inline void FillMuteMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
@@ -64,13 +65,14 @@ inline void SetupMuteMenu(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<> triggers,
|
||||
Fn<Data::Thread*()> makeThread,
|
||||
std::shared_ptr<Ui::Show> show) {
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
Fn<QPoint()> positionCallback = nullptr) {
|
||||
SetupMuteMenu(parent, std::move(triggers), [=] {
|
||||
const auto thread = makeThread();
|
||||
return thread
|
||||
? ThreadDescriptor(thread)
|
||||
: std::optional<Descriptor>();
|
||||
}, std::move(show));
|
||||
}, std::move(show), positionCallback);
|
||||
}
|
||||
|
||||
} // namespace MuteMenu
|
||||
|
||||
Reference in New Issue
Block a user