mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Detach ComposeControls from SessionController.
This commit is contained in:
@@ -322,12 +322,12 @@ std::unique_ptr<Ui::TabbedSearch> MakeSearch(
|
||||
|
||||
TabbedSelector::TabbedSelector(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Window::GifPauseReason level,
|
||||
std::shared_ptr<Show> show,
|
||||
PauseReason level,
|
||||
Mode mode)
|
||||
: RpWidget(parent)
|
||||
, _st((mode == Mode::EmojiStatus) ? st::statusEmojiPan : st::defaultEmojiPan)
|
||||
, _controller(controller)
|
||||
, _show(std::move(show))
|
||||
, _level(level)
|
||||
, _mode(mode)
|
||||
, _panelRounding(Ui::PrepareCornerPixmaps(st::emojiPanRadius, _st.bg))
|
||||
@@ -470,38 +470,59 @@ TabbedSelector::TabbedSelector(
|
||||
TabbedSelector::~TabbedSelector() = default;
|
||||
|
||||
Main::Session &TabbedSelector::session() const {
|
||||
return _controller->session();
|
||||
return _show->session();
|
||||
}
|
||||
|
||||
Window::GifPauseReason TabbedSelector::level() const {
|
||||
PauseReason TabbedSelector::level() const {
|
||||
return _level;
|
||||
}
|
||||
|
||||
TabbedSelector::Tab TabbedSelector::createTab(SelectorTab type, int index) {
|
||||
auto createWidget = [&]() -> object_ptr<Inner> {
|
||||
const auto paused = [show = _show, level = _level] {
|
||||
return show->paused(level);
|
||||
};
|
||||
switch (type) {
|
||||
case SelectorTab::Emoji:
|
||||
case SelectorTab::Emoji: {
|
||||
using EmojiMode = EmojiListWidget::Mode;
|
||||
using Descriptor = EmojiListDescriptor;
|
||||
return object_ptr<EmojiListWidget>(this, Descriptor{
|
||||
.session = &_controller->session(),
|
||||
.show = _show,
|
||||
.mode = (_mode == Mode::EmojiStatus
|
||||
? EmojiMode::EmojiStatus
|
||||
: EmojiMode::Full),
|
||||
.controller = _controller,
|
||||
.paused = Window::PausedIn(_controller, _level),
|
||||
.paused = paused,
|
||||
.st = &_st,
|
||||
});
|
||||
case SelectorTab::Stickers:
|
||||
return object_ptr<StickersListWidget>(this, _controller, _level);
|
||||
case SelectorTab::Gifs:
|
||||
return object_ptr<GifsListWidget>(this, _controller, _level);
|
||||
case SelectorTab::Masks:
|
||||
return object_ptr<StickersListWidget>(
|
||||
this,
|
||||
_controller,
|
||||
_level,
|
||||
StickersListWidget::Mode::Masks);
|
||||
}
|
||||
case SelectorTab::Stickers: {
|
||||
using StickersMode = StickersListWidget::Mode;
|
||||
using Descriptor = StickersListDescriptor;
|
||||
return object_ptr<StickersListWidget>(this, Descriptor{
|
||||
.show = _show,
|
||||
.mode = StickersMode::Full,
|
||||
.paused = paused,
|
||||
.st = &_st,
|
||||
});
|
||||
}
|
||||
case SelectorTab::Gifs: {
|
||||
using Descriptor = GifsListDescriptor;
|
||||
return object_ptr<GifsListWidget>(this, Descriptor{
|
||||
.show = _show,
|
||||
.paused = paused,
|
||||
.st = &_st,
|
||||
});
|
||||
}
|
||||
case SelectorTab::Masks: {
|
||||
using StickersMode = StickersListWidget::Mode;
|
||||
using Descriptor = StickersListDescriptor;
|
||||
return object_ptr<StickersListWidget>(this, Descriptor{
|
||||
.show = _show,
|
||||
.mode = StickersMode::Masks,
|
||||
.paused = paused,
|
||||
.st = &_st,
|
||||
});
|
||||
}
|
||||
}
|
||||
Unexpected("Type in TabbedSelector::createTab.");
|
||||
};
|
||||
@@ -1237,23 +1258,24 @@ not_null<const TabbedSelector::Tab*> TabbedSelector::currentTab() const {
|
||||
|
||||
TabbedSelector::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Window::GifPauseReason level)
|
||||
std::shared_ptr<Show> show,
|
||||
PauseReason level)
|
||||
: Inner(
|
||||
parent,
|
||||
st::defaultEmojiPan,
|
||||
&controller->session(),
|
||||
Window::PausedIn(controller, level)) {
|
||||
show,
|
||||
[show, level] { return show->paused(level); }) {
|
||||
}
|
||||
|
||||
TabbedSelector::Inner::Inner(
|
||||
QWidget *parent,
|
||||
const style::EmojiPan &st,
|
||||
not_null<Main::Session*> session,
|
||||
std::shared_ptr<Show> show,
|
||||
Fn<bool()> paused)
|
||||
: RpWidget(parent)
|
||||
, _st(st)
|
||||
, _session(session)
|
||||
, _show(std::move(show))
|
||||
, _session(&_show->session())
|
||||
, _paused(paused) {
|
||||
}
|
||||
|
||||
@@ -1273,12 +1295,15 @@ void TabbedSelector::Inner::disableScroll(bool disabled) {
|
||||
_disableScrollRequests.fire_copy(disabled);
|
||||
}
|
||||
|
||||
void TabbedSelector::Inner::checkHideWithBox(QPointer<Ui::BoxContent> box) {
|
||||
if (!box) {
|
||||
void TabbedSelector::Inner::checkHideWithBox(
|
||||
object_ptr<Ui::BoxContent> box) {
|
||||
const auto raw = QPointer<Ui::BoxContent>(box.data());
|
||||
_show->showBox(std::move(box));
|
||||
if (!raw) {
|
||||
return;
|
||||
}
|
||||
_preventHideWithBox = true;
|
||||
connect(box, &QObject::destroyed, this, [=] {
|
||||
connect(raw, &QObject::destroyed, this, [=] {
|
||||
_preventHideWithBox = false;
|
||||
_checkForHide.fire({});
|
||||
});
|
||||
|
Reference in New Issue
Block a user