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"
|
2022-05-23 08:04:31 +00:00
|
|
|
#include "styles/style_layers.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);
|
|
|
|
|
2022-05-23 08:04:31 +00:00
|
|
|
rpl::combine(
|
|
|
|
sizeValue(),
|
|
|
|
_content->desiredHeightValue()
|
2022-05-23 10:35:39 +00:00
|
|
|
) | rpl::filter([=] {
|
|
|
|
return (_content != nullptr);
|
|
|
|
}) | rpl::start_with_next([=](QSize size, int) {
|
2022-04-12 12:07:25 +00:00
|
|
|
const auto expanding = false;
|
2022-05-23 08:04:31 +00:00
|
|
|
const auto additionalScroll = st::boxRadius;
|
2022-05-23 10:35:39 +00:00
|
|
|
const auto full = !_content->scrollBottomSkip();
|
2022-05-23 08:04:31 +00:00
|
|
|
const auto height = size.height() - (full ? 0 : st::boxRadius);
|
|
|
|
const auto wrapGeometry = QRect{ 0, 0, size.width(), height };
|
2022-05-23 10:35:39 +00:00
|
|
|
_content->updateGeometry(wrapGeometry, expanding, additionalScroll);
|
|
|
|
}, 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);
|
|
|
|
}
|
|
|
|
|
2022-05-23 08:04:31 +00:00
|
|
|
void SectionWidget::paintEvent(QPaintEvent *e) {
|
|
|
|
Window::SectionWidget::paintEvent(e);
|
|
|
|
if (!animatingShow()) {
|
|
|
|
QPainter(this).fillRect(e->rect(), st::windowBg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
rpl::producer<> SectionWidget::removeRequests() const {
|
|
|
|
return _content->removeRequests();
|
|
|
|
}
|
|
|
|
|
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
|