2017-09-13 17:01:23 +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-13 17:01:23 +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-13 17:01:23 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <rpl/producer.h>
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "info/info_content_widget.h"
|
2017-09-13 17:01:23 +00:00
|
|
|
#include "storage/storage_shared_media.h"
|
2017-11-06 07:31:18 +00:00
|
|
|
#include "data/data_search_controller.h"
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
namespace Info {
|
|
|
|
namespace Media {
|
|
|
|
|
2017-11-03 12:03:00 +00:00
|
|
|
using Type = Storage::SharedMediaType;
|
|
|
|
|
|
|
|
base::optional<int> TypeToTabIndex(Type type);
|
|
|
|
Type TabIndexToType(int index);
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
class InnerWidget;
|
|
|
|
|
|
|
|
class Memento final : public ContentMemento {
|
|
|
|
public:
|
2017-10-31 18:25:22 +00:00
|
|
|
Memento(not_null<Controller*> controller);
|
2017-11-03 15:47:08 +00:00
|
|
|
Memento(PeerId peerId, PeerId migratedPeerId, Type type);
|
2017-10-31 18:25:22 +00:00
|
|
|
|
2017-11-03 15:47:08 +00:00
|
|
|
using SearchState = Api::DelayedSearchController::SavedState;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
object_ptr<ContentWidget> createWidget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Controller*> controller,
|
2017-09-13 17:01:23 +00:00
|
|
|
const QRect &geometry) override;
|
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
Section section() const override;
|
2017-10-03 13:05:58 +00:00
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
Type type() const {
|
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
|
2017-10-27 17:41:38 +00:00
|
|
|
void setAroundId(FullMsgId aroundId) {
|
|
|
|
_aroundId = aroundId;
|
|
|
|
}
|
|
|
|
FullMsgId aroundId() const {
|
|
|
|
return _aroundId;
|
|
|
|
}
|
|
|
|
void setIdsLimit(int limit) {
|
|
|
|
_idsLimit = limit;
|
|
|
|
}
|
|
|
|
int idsLimit() const {
|
|
|
|
return _idsLimit;
|
|
|
|
}
|
|
|
|
void setScrollTopItem(FullMsgId item) {
|
|
|
|
_scrollTopItem = item;
|
|
|
|
}
|
|
|
|
FullMsgId scrollTopItem() const {
|
|
|
|
return _scrollTopItem;
|
|
|
|
}
|
|
|
|
void setScrollTopShift(int shift) {
|
|
|
|
_scrollTopShift = shift;
|
|
|
|
}
|
|
|
|
int scrollTopShift() const {
|
|
|
|
return _scrollTopShift;
|
|
|
|
}
|
2017-11-03 15:47:08 +00:00
|
|
|
void setSearchState(SearchState &&state) {
|
|
|
|
_searchState = std::move(state);
|
|
|
|
}
|
|
|
|
SearchState searchState() {
|
|
|
|
return std::move(_searchState);
|
|
|
|
}
|
2017-10-27 17:41:38 +00:00
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
private:
|
|
|
|
Type _type = Type::Photo;
|
2017-10-27 17:41:38 +00:00
|
|
|
FullMsgId _aroundId;
|
|
|
|
int _idsLimit = 0;
|
|
|
|
FullMsgId _scrollTopItem;
|
2017-11-03 15:47:08 +00:00
|
|
|
int _scrollTopShift = 0;
|
|
|
|
SearchState _searchState;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Widget final : public ContentWidget {
|
|
|
|
public:
|
|
|
|
Widget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Controller*> controller);
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-12-05 12:23:08 +00:00
|
|
|
void setIsStackBottom(bool isStackBottom) override;
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
bool showInternal(
|
|
|
|
not_null<ContentMemento*> memento) override;
|
|
|
|
|
|
|
|
void setInternalState(
|
|
|
|
const QRect &geometry,
|
|
|
|
not_null<Memento*> memento);
|
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
rpl::producer<SelectedItems> selectedListValue() const override;
|
|
|
|
void cancelSelection() override;
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
private:
|
|
|
|
void saveState(not_null<Memento*> memento);
|
|
|
|
void restoreState(not_null<Memento*> memento);
|
2017-10-31 18:25:22 +00:00
|
|
|
|
2017-11-03 18:26:14 +00:00
|
|
|
std::unique_ptr<ContentMemento> doCreateMemento() override;
|
2017-11-03 12:03:00 +00:00
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
InnerWidget *_inner = nullptr;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Media
|
|
|
|
} // namespace Info
|