2017-09-30 18:26:45 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-30 18:26:45 +00:00
|
|
|
*/
|
|
|
|
#include "info/info_section_widget.h"
|
|
|
|
|
|
|
|
#include "info/info_content_widget.h"
|
|
|
|
#include "info/info_wrap_widget.h"
|
|
|
|
#include "info/info_layer_widget.h"
|
|
|
|
#include "info/info_memento.h"
|
2017-10-31 18:25:22 +00:00
|
|
|
#include "info/info_controller.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
namespace Info {
|
|
|
|
|
|
|
|
SectionWidget::SectionWidget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Window::Controller*> window,
|
2017-09-30 18:26:45 +00:00
|
|
|
Wrap wrap,
|
|
|
|
not_null<Memento*> memento)
|
2017-10-31 18:25:22 +00:00
|
|
|
: Window::SectionWidget(parent, window)
|
|
|
|
, _content(this, window, wrap, memento) {
|
2017-09-30 18:26:45 +00:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionWidget::SectionWidget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Window::Controller*> window,
|
2017-09-30 18:26:45 +00:00
|
|
|
Wrap wrap,
|
|
|
|
not_null<MoveMemento*> memento)
|
2017-10-31 18:25:22 +00:00
|
|
|
: Window::SectionWidget(parent, window)
|
2017-09-30 18:26:45 +00:00
|
|
|
, _content(memento->takeContent(this, wrap)) {
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionWidget::init() {
|
2017-12-22 07:05:20 +00:00
|
|
|
sizeValue(
|
|
|
|
) | rpl::start_with_next([wrap = _content.data()](QSize size) {
|
|
|
|
auto wrapGeometry = QRect{ { 0, 0 }, size };
|
|
|
|
auto additionalScroll = 0;
|
|
|
|
wrap->updateGeometry(wrapGeometry, additionalScroll);
|
|
|
|
}, _content->lifetime());
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
Dialogs::RowDescriptor SectionWidget::activeChat() const {
|
|
|
|
return _content->activeChat();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SectionWidget::hasTopBarShadow() const {
|
|
|
|
return _content->hasTopBarShadow();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap SectionWidget::grabForShowAnimation(
|
|
|
|
const Window::SectionSlideParams ¶ms) {
|
|
|
|
return _content->grabForShowAnimation(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionWidget::doSetInnerFocus() {
|
|
|
|
_content->setInnerFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionWidget::showFinishedHook() {
|
2017-11-16 15:24:01 +00:00
|
|
|
_topBarSurrogate.destroy();
|
2017-10-03 14:57:11 +00:00
|
|
|
_content->showFast();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 15:24:01 +00:00
|
|
|
void SectionWidget::showAnimatedHook(
|
|
|
|
const Window::SectionSlideParams ¶ms) {
|
|
|
|
_topBarSurrogate = _content->createTopBarSurrogate(this);
|
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
bool SectionWidget::showInternal(
|
2017-10-03 13:05:58 +00:00
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) {
|
|
|
|
return _content->showInternal(memento, params);
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Window::SectionMemento> SectionWidget::createMemento() {
|
2017-10-31 18:25:22 +00:00
|
|
|
return _content->createMemento();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Window::LayerWidget> SectionWidget::moveContentToLayer(
|
|
|
|
QRect bodyGeometry) {
|
2017-11-05 09:56:43 +00:00
|
|
|
if (_content->controller()->wrap() != Wrap::Narrow
|
2017-09-30 18:26:45 +00:00
|
|
|
|| width() < LayerWidget::MinimalSupportedWidth()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return MoveMemento(
|
2017-10-31 18:25:22 +00:00
|
|
|
std::move(_content)).createLayer(
|
2017-11-05 09:56:43 +00:00
|
|
|
controller(),
|
2017-10-31 18:25:22 +00:00
|
|
|
bodyGeometry);
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SectionWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
|
|
|
return _content->wheelEventFromFloatPlayer(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect SectionWidget::rectForFloatPlayer() const {
|
|
|
|
return _content->rectForFloatPlayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Info
|