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"
|
|
|
|
|
2021-05-26 23:20:27 +00:00
|
|
|
#include "window/window_adaptive.h"
|
2018-05-07 17:44:33 +00:00
|
|
|
#include "window/window_connecting_widget.h"
|
2020-06-10 14:52:44 +00:00
|
|
|
#include "window/window_session_controller.h"
|
|
|
|
#include "main/main_session.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#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,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> window,
|
2017-09-30 18:26:45 +00:00
|
|
|
Wrap wrap,
|
|
|
|
not_null<Memento*> memento)
|
2021-08-26 13:25:48 +00:00
|
|
|
: Window::SectionWidget(parent, window)
|
2017-10-31 18:25:22 +00:00
|
|
|
, _content(this, window, wrap, memento) {
|
2017-09-30 18:26:45 +00:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionWidget::SectionWidget(
|
|
|
|
QWidget *parent,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> window,
|
2017-09-30 18:26:45 +00:00
|
|
|
Wrap wrap,
|
|
|
|
not_null<MoveMemento*> memento)
|
2021-08-26 13:25:48 +00:00
|
|
|
: Window::SectionWidget(parent, window)
|
2017-09-30 18:26:45 +00:00
|
|
|
, _content(memento->takeContent(this, wrap)) {
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionWidget::init() {
|
2019-02-10 16:29:55 +00:00
|
|
|
Expects(_connecting == nullptr);
|
|
|
|
|
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());
|
2018-05-07 17:44:33 +00:00
|
|
|
|
2019-02-10 16:29:55 +00:00
|
|
|
_connecting = std::make_unique<Window::ConnectionState>(
|
2018-05-07 17:44:33 +00:00
|
|
|
_content.data(),
|
2020-06-10 14:52:44 +00:00
|
|
|
&controller()->session().account(),
|
2021-05-26 23:20:27 +00:00
|
|
|
controller()->adaptive().oneColumnValue());
|
2018-05-07 17:44:33 +00:00
|
|
|
|
|
|
|
_content->contentChanged(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
_connecting->raise();
|
2019-03-03 21:03:31 +00:00
|
|
|
}, _connecting->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
|
|
|
}
|
|
|
|
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> SectionWidget::createMemento() {
|
2017-10-31 18:25:22 +00:00
|
|
|
return _content->createMemento();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::LayerWidget> SectionWidget::moveContentToLayer(
|
2017-09-30 18:26:45 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
bool SectionWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
|
|
|
return _content->floatPlayerHandleWheelEvent(e);
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
QRect SectionWidget::floatPlayerAvailableRect() {
|
|
|
|
return _content->floatPlayerAvailableRect();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Info
|