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;
|
|
|
|
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<int> TypeToTabIndex(Type type);
|
2017-11-03 12:03:00 +00:00
|
|
|
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);
|
2020-06-08 09:06:50 +00:00
|
|
|
Memento(not_null<PeerData*> peer, 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;
|
|
|
|
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] Section section() const override;
|
2017-10-03 13:05:58 +00:00
|
|
|
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] Type type() const {
|
2017-09-13 17:01:23 +00:00
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
|
2022-02-24 15:04:24 +00:00
|
|
|
// Only for media, not for downloads.
|
2017-10-27 17:41:38 +00:00
|
|
|
void setAroundId(FullMsgId aroundId) {
|
|
|
|
_aroundId = aroundId;
|
|
|
|
}
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] FullMsgId aroundId() const {
|
2017-10-27 17:41:38 +00:00
|
|
|
return _aroundId;
|
|
|
|
}
|
|
|
|
void setIdsLimit(int limit) {
|
|
|
|
_idsLimit = limit;
|
|
|
|
}
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] int idsLimit() const {
|
2017-10-27 17:41:38 +00:00
|
|
|
return _idsLimit;
|
|
|
|
}
|
2022-02-24 15:04:24 +00:00
|
|
|
|
|
|
|
void setScrollTopItem(GlobalMsgId item) {
|
2017-10-27 17:41:38 +00:00
|
|
|
_scrollTopItem = item;
|
|
|
|
}
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] GlobalMsgId scrollTopItem() const {
|
2017-10-27 17:41:38 +00:00
|
|
|
return _scrollTopItem;
|
|
|
|
}
|
2022-02-27 17:19:16 +00:00
|
|
|
void setScrollTopItemPosition(int64 position) {
|
|
|
|
_scrollTopItemPosition = position;
|
|
|
|
}
|
|
|
|
[[nodiscard]] int64 scrollTopItemPosition() const {
|
|
|
|
return _scrollTopItemPosition;
|
|
|
|
}
|
2017-10-27 17:41:38 +00:00
|
|
|
void setScrollTopShift(int shift) {
|
|
|
|
_scrollTopShift = shift;
|
|
|
|
}
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] int scrollTopShift() const {
|
2017-10-27 17:41:38 +00:00
|
|
|
return _scrollTopShift;
|
|
|
|
}
|
2017-11-03 15:47:08 +00:00
|
|
|
void setSearchState(SearchState &&state) {
|
|
|
|
_searchState = std::move(state);
|
|
|
|
}
|
2022-02-27 17:19:16 +00:00
|
|
|
[[nodiscard]] SearchState searchState() {
|
2017-11-03 15:47:08 +00:00
|
|
|
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;
|
2022-02-27 17:19:16 +00:00
|
|
|
int64 _scrollTopItemPosition = 0;
|
2022-02-24 15:04:24 +00:00
|
|
|
GlobalMsgId _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;
|
2022-02-27 11:14:39 +00:00
|
|
|
void selectionAction(SelectionAction action) override;
|
2017-10-20 16:19:42 +00:00
|
|
|
|
2022-04-04 06:36:45 +00:00
|
|
|
rpl::producer<QString> title() 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
|
|
|
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_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
|