tdesktop/Telegram/SourceFiles/info/info_memento.h

136 lines
3.4 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/rp_widget.h"
#include "info/info_wrap_widget.h"
2018-01-22 19:51:38 +00:00
#include "dialogs/dialogs_key.h"
#include "window/section_memento.h"
2019-09-13 12:22:54 +00:00
#include "base/object_ptr.h"
namespace Storage {
enum class SharedMediaType : signed char;
} // namespace Storage
2022-09-27 12:05:47 +00:00
namespace Data {
class ForumTopic;
} // namespace Data
namespace Ui {
class ScrollArea;
struct ScrollToRequest;
} // namespace Ui
namespace Info {
2018-09-05 19:05:49 +00:00
namespace Settings {
struct Tag;
} // namespace Settings
namespace Downloads {
struct Tag;
} // namespace Downloads
class ContentMemento;
class WrapWidget;
class Memento final : public Window::SectionMemento {
public:
2020-06-08 09:06:50 +00:00
explicit Memento(not_null<PeerData*> peer);
Memento(not_null<PeerData*> peer, Section section);
2022-09-27 12:05:47 +00:00
explicit Memento(not_null<Data::ForumTopic*> topic);
Memento(not_null<Data::ForumTopic*> topic, Section section);
2018-09-05 19:05:49 +00:00
Memento(Settings::Tag settings, Section section);
Memento(not_null<PollData*> poll, FullMsgId contextId);
2020-12-14 14:48:10 +00:00
explicit Memento(std::vector<std::shared_ptr<ContentMemento>> stack);
object_ptr<Window::SectionWidget> createWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::Column column,
const QRect &geometry) override;
2019-09-18 11:19:05 +00:00
object_ptr<Ui::LayerWidget> createLayer(
not_null<Window::SessionController*> controller,
const QRect &geometry) override;
rpl::producer<> removeRequests() const override {
return _removeRequests.events();
}
int stackSize() const {
return int(_stack.size());
}
2020-12-14 14:48:10 +00:00
std::vector<std::shared_ptr<ContentMemento>> takeStack();
not_null<ContentMemento*> content() {
Expects(!_stack.empty());
2018-09-05 19:05:49 +00:00
return _stack.back().get();
}
2019-04-15 11:54:03 +00:00
static Section DefaultSection(not_null<PeerData*> peer);
2020-12-14 14:48:10 +00:00
static std::shared_ptr<Memento> Default(not_null<PeerData*> peer);
~Memento();
private:
2020-12-14 14:48:10 +00:00
static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
2020-06-08 09:06:50 +00:00
not_null<PeerData*> peer,
Section section);
2022-09-27 12:05:47 +00:00
static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
not_null<Data::ForumTopic*> topic,
Section section);
2020-12-14 14:48:10 +00:00
static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
2018-09-05 19:05:49 +00:00
Settings::Tag settings,
Section section);
2020-12-14 14:48:10 +00:00
static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
not_null<PollData*> poll,
FullMsgId contextId);
2020-12-14 14:48:10 +00:00
static std::shared_ptr<ContentMemento> DefaultContent(
2020-06-08 09:06:50 +00:00
not_null<PeerData*> peer,
Section section);
2022-09-27 12:05:47 +00:00
static std::shared_ptr<ContentMemento> DefaultContent(
not_null<Data::ForumTopic*> topic,
Section section);
2020-12-14 14:48:10 +00:00
std::vector<std::shared_ptr<ContentMemento>> _stack;
rpl::event_stream<> _removeRequests;
rpl::lifetime _lifetime;
};
class MoveMemento final : public Window::SectionMemento {
public:
MoveMemento(object_ptr<WrapWidget> content);
object_ptr<Window::SectionWidget> createWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::Column column,
const QRect &geometry) override;
2019-09-18 11:19:05 +00:00
object_ptr<Ui::LayerWidget> createLayer(
not_null<Window::SessionController*> controller,
const QRect &geometry) override;
bool instant() const override {
return true;
}
object_ptr<WrapWidget> takeContent(
QWidget *parent,
Wrap wrap);
private:
object_ptr<WrapWidget> _content;
};
} // namespace Info