mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Replaced Calls box with GenericBox.
This commit is contained in:
parent
23a1f7b83c
commit
0c17bdc783
1 changed files with 31 additions and 15 deletions
|
@ -94,19 +94,36 @@ constexpr auto kPlayStatusLimit = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowCallsBox(not_null<Window::SessionController*> window) {
|
void ShowCallsBox(not_null<Window::SessionController*> window) {
|
||||||
auto controller = std::make_unique<Calls::BoxController>(window);
|
struct State {
|
||||||
const auto initBox = [
|
State(not_null<Window::SessionController*> window)
|
||||||
window,
|
: callsController(window) {
|
||||||
controller = controller.get()
|
}
|
||||||
](not_null<PeerListBox*> box) {
|
Calls::BoxController callsController;
|
||||||
|
PeerListContentDelegateSimple callsDelegate;
|
||||||
|
|
||||||
|
base::unique_qptr<Ui::PopupMenu> menu;
|
||||||
|
};
|
||||||
|
|
||||||
|
window->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
const auto state = box->lifetime().make_state<State>(window);
|
||||||
|
const auto content = box->addRow(
|
||||||
|
object_ptr<PeerListContent>(box, &state->callsController),
|
||||||
|
{});
|
||||||
|
state->callsDelegate.setContent(content);
|
||||||
|
state->callsController.setDelegate(&state->callsDelegate);
|
||||||
|
|
||||||
|
box->setWidth(state->callsController.contentWidth());
|
||||||
|
state->callsController.boxHeightValue(
|
||||||
|
) | rpl::start_with_next([=](int height) {
|
||||||
|
box->setMinHeight(height);
|
||||||
|
}, box->lifetime());
|
||||||
|
box->setTitle(tr::lng_call_box_title());
|
||||||
box->addButton(tr::lng_close(), [=] {
|
box->addButton(tr::lng_close(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
using MenuPointer = base::unique_qptr<Ui::PopupMenu>;
|
|
||||||
const auto menu = std::make_shared<MenuPointer>();
|
|
||||||
const auto menuButton = box->addTopButton(st::infoTopBarMenu);
|
const auto menuButton = box->addTopButton(st::infoTopBarMenu);
|
||||||
menuButton->setClickedCallback([=] {
|
menuButton->setClickedCallback([=] {
|
||||||
*menu = base::make_unique_q<Ui::PopupMenu>(
|
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
menuButton,
|
menuButton,
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
const auto showSettings = [=] {
|
const auto showSettings = [=] {
|
||||||
|
@ -115,23 +132,22 @@ void ShowCallsBox(not_null<Window::SessionController*> window) {
|
||||||
Window::SectionShow(anim::type::instant));
|
Window::SectionShow(anim::type::instant));
|
||||||
};
|
};
|
||||||
const auto clearAll = crl::guard(box, [=] {
|
const auto clearAll = crl::guard(box, [=] {
|
||||||
box->getDelegate()->show(Box(Calls::ClearCallsBox, window));
|
Ui::BoxShow(box).showBox(Box(Calls::ClearCallsBox, window));
|
||||||
});
|
});
|
||||||
(*menu)->addAction(
|
state->menu->addAction(
|
||||||
tr::lng_settings_section_call_settings(tr::now),
|
tr::lng_settings_section_call_settings(tr::now),
|
||||||
showSettings,
|
showSettings,
|
||||||
&st::menuIconSettings);
|
&st::menuIconSettings);
|
||||||
if (controller->delegate()->peerListFullRowsCount() > 0) {
|
if (state->callsDelegate.peerListFullRowsCount() > 0) {
|
||||||
(*menu)->addAction(
|
state->menu->addAction(
|
||||||
tr::lng_call_box_clear_all(tr::now),
|
tr::lng_call_box_clear_all(tr::now),
|
||||||
clearAll,
|
clearAll,
|
||||||
&st::menuIconDelete);
|
&st::menuIconDelete);
|
||||||
}
|
}
|
||||||
(*menu)->popup(QCursor::pos());
|
state->menu->popup(QCursor::pos());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
};
|
}));
|
||||||
window->show(Box<PeerListBox>(std::move(controller), initBox));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> SetStatusLabel(
|
[[nodiscard]] rpl::producer<TextWithEntities> SetStatusLabel(
|
||||||
|
|
Loading…
Add table
Reference in a new issue