Set fixed position of mute menu in profile top bar.

This commit is contained in:
23rd
2025-10-24 12:46:51 +03:00
parent 65604add65
commit 4b67c8f4bb
3 changed files with 15 additions and 6 deletions

View File

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

View File

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