/* 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 */ #include "info/downloads/info_downloads_widget.h" #include "info/downloads/info_downloads_inner_widget.h" #include "info/info_controller.h" #include "info/info_memento.h" #include "ui/search_field_controller.h" #include "ui/widgets/scroll_area.h" #include "data/data_download_manager.h" #include "data/data_user.h" #include "core/application.h" #include "styles/style_info.h" namespace Info::Downloads { Memento::Memento(not_null controller) : ContentMemento(Tag{}) , _media(controller) { } Memento::Memento(not_null self) : ContentMemento(Downloads::Tag{}) , _media(self, 0, Media::Type::File) { } Memento::~Memento() = default; Section Memento::section() const { return Section(Section::Type::Downloads); } object_ptr Memento::createWidget( QWidget *parent, not_null controller, const QRect &geometry) { auto result = object_ptr(parent, controller); result->setInternalState(geometry, this); return result; } Widget::Widget( QWidget *parent, not_null controller) : ContentWidget(parent, controller) { _inner = setInnerWidget(object_ptr( this, controller)); } bool Widget::showInternal(not_null memento) { if (!controller()->validateMementoPeer(memento)) { return false; } if (auto downloadsMemento = dynamic_cast(memento.get())) { restoreState(downloadsMemento); return true; } return false; } void Widget::setInternalState( const QRect &geometry, not_null memento) { setGeometry(geometry); Ui::SendPendingMoveResizeEvents(this); restoreState(memento); } std::shared_ptr Widget::doCreateMemento() { auto result = std::make_shared(controller()); saveState(result.get()); return result; } void Widget::saveState(not_null memento) { memento->setScrollTop(scrollTopSave()); _inner->saveState(memento); } void Widget::restoreState(not_null memento) { _inner->restoreState(memento); scrollTopRestore(memento->scrollTop()); } std::shared_ptr Make(not_null self) { return std::make_shared( std::vector>( 1, std::make_shared(self))); } } // namespace Info::Downloads