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
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
#include <rpl/variable.h>
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "ui/rp_widget.h"
|
|
|
|
#include "info/info_wrap_widget.h"
|
|
|
|
|
2023-06-20 15:31:40 +00:00
|
|
|
namespace Dialogs::Stories {
|
|
|
|
struct Content;
|
|
|
|
} // namespace Dialogs::Stories
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
namespace Storage {
|
2018-03-09 20:48:47 +00:00
|
|
|
enum class SharedMediaType : signed char;
|
2017-09-30 18:26:45 +00:00
|
|
|
} // namespace Storage
|
|
|
|
|
|
|
|
namespace Ui {
|
2022-05-31 17:11:59 +00:00
|
|
|
class RoundRect;
|
2017-09-30 18:26:45 +00:00
|
|
|
class ScrollArea;
|
2017-12-08 08:22:02 +00:00
|
|
|
class InputField;
|
2017-09-30 18:26:45 +00:00
|
|
|
struct ScrollToRequest;
|
2017-11-23 12:48:56 +00:00
|
|
|
template <typename Widget>
|
|
|
|
class PaddingWrap;
|
2017-09-30 18:26:45 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2024-02-28 10:55:28 +00:00
|
|
|
namespace Ui::Menu {
|
|
|
|
struct MenuCallback;
|
|
|
|
} // namespace Ui::Menu
|
|
|
|
|
2023-06-05 16:31:15 +00:00
|
|
|
namespace Info::Settings {
|
|
|
|
struct Tag;
|
|
|
|
} // namespace Info::Settings
|
|
|
|
|
|
|
|
namespace Info::Downloads {
|
2018-09-05 19:05:49 +00:00
|
|
|
struct Tag;
|
2023-06-05 16:31:15 +00:00
|
|
|
} // namespace Info::Downloads
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2023-06-05 16:31:15 +00:00
|
|
|
namespace Info::Stories {
|
2022-02-24 15:04:24 +00:00
|
|
|
struct Tag;
|
2023-06-05 16:31:15 +00:00
|
|
|
enum class Tab;
|
|
|
|
} // namespace Info::Stories
|
|
|
|
|
2023-10-08 20:17:45 +00:00
|
|
|
namespace Info::Statistics {
|
|
|
|
struct Tag;
|
|
|
|
} // namespace Info::Statistics
|
|
|
|
|
2023-06-05 16:31:15 +00:00
|
|
|
namespace Info {
|
2022-02-24 15:04:24 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
class ContentMemento;
|
2017-10-31 18:25:22 +00:00
|
|
|
class Controller;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
class ContentWidget : public Ui::RpWidget {
|
|
|
|
public:
|
|
|
|
ContentWidget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Controller*> controller);
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
virtual bool showInternal(
|
|
|
|
not_null<ContentMemento*> memento) = 0;
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<ContentMemento> createMemento();
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2022-04-04 06:36:45 +00:00
|
|
|
virtual void setIsStackBottom(bool isStackBottom);
|
|
|
|
[[nodiscard]] bool isStackBottom() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-11-14 17:22:44 +00:00
|
|
|
rpl::producer<int> scrollHeightValue() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
rpl::producer<int> desiredHeightValue() const override;
|
2018-09-13 20:09:26 +00:00
|
|
|
virtual rpl::producer<bool> desiredShadowVisibility() const;
|
2017-10-03 14:57:11 +00:00
|
|
|
bool hasTopBarShadow() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-11-23 12:48:56 +00:00
|
|
|
virtual void setInnerFocus();
|
2022-04-13 08:05:10 +00:00
|
|
|
virtual void showFinished() {
|
|
|
|
}
|
2022-05-22 23:06:35 +00:00
|
|
|
virtual void enableBackButton() {
|
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
// When resizing the widget with top edge moved up or down and we
|
|
|
|
// want to add this top movement to the scroll position, so inner
|
|
|
|
// content will not move.
|
|
|
|
void setGeometryWithTopMoved(
|
|
|
|
const QRect &newGeometry,
|
|
|
|
int topDelta);
|
2017-11-23 12:48:56 +00:00
|
|
|
void applyAdditionalScroll(int additionalScroll);
|
2024-02-23 17:23:15 +00:00
|
|
|
void applyMaxVisibleHeight(int maxVisibleHeight);
|
2017-11-23 12:48:56 +00:00
|
|
|
int scrollTillBottom(int forHeight) const;
|
2022-05-31 17:11:59 +00:00
|
|
|
[[nodiscard]] rpl::producer<int> scrollTillBottomChanges() const;
|
|
|
|
[[nodiscard]] virtual const Ui::RoundRect *bottomSkipRounding() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
// Float player interface.
|
2020-06-25 14:17:37 +00:00
|
|
|
bool floatPlayerHandleWheelEvent(QEvent *e);
|
|
|
|
QRect floatPlayerAvailableRect() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
virtual rpl::producer<SelectedItems> selectedListValue() const;
|
2022-02-27 11:14:39 +00:00
|
|
|
virtual void selectionAction(SelectionAction action) {
|
2017-10-20 16:19:42 +00:00
|
|
|
}
|
2024-02-28 10:55:28 +00:00
|
|
|
virtual void fillTopBarMenu(const Ui::Menu::MenuCallback &addAction);
|
2017-10-20 16:19:42 +00:00
|
|
|
|
2024-03-07 13:02:32 +00:00
|
|
|
[[nodiscard]] virtual bool closeByOutsideClick() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
virtual void checkBeforeClose(Fn<void()> close) {
|
|
|
|
close();
|
|
|
|
}
|
2022-04-04 06:36:45 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> title() = 0;
|
2023-12-30 15:04:43 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> subtitle() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2023-06-20 15:31:40 +00:00
|
|
|
[[nodiscard]] virtual auto titleStories()
|
|
|
|
-> rpl::producer<Dialogs::Stories::Content>;
|
2022-04-04 06:36:45 +00:00
|
|
|
|
2018-09-09 17:38:08 +00:00
|
|
|
virtual void saveChanges(FnMut<void()> done);
|
|
|
|
|
2022-05-19 00:16:05 +00:00
|
|
|
[[nodiscard]] int scrollBottomSkip() const;
|
2022-06-09 07:00:29 +00:00
|
|
|
[[nodiscard]] rpl::producer<int> scrollBottomSkipValue() const;
|
2022-05-19 00:16:05 +00:00
|
|
|
[[nodiscard]] rpl::producer<bool> desiredBottomShadowVisibility() const;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
protected:
|
|
|
|
template <typename Widget>
|
2017-11-03 18:26:14 +00:00
|
|
|
Widget *setInnerWidget(object_ptr<Widget> inner) {
|
2017-09-30 18:26:45 +00:00
|
|
|
return static_cast<Widget*>(
|
2017-11-03 18:26:14 +00:00
|
|
|
doSetInnerWidget(std::move(inner)));
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 17:23:15 +00:00
|
|
|
[[nodiscard]] not_null<Controller*> controller() const {
|
2017-09-30 18:26:45 +00:00
|
|
|
return _controller;
|
|
|
|
}
|
2024-02-23 17:23:15 +00:00
|
|
|
[[nodiscard]] not_null<Ui::ScrollArea*> scroll() const;
|
|
|
|
[[nodiscard]] int maxVisibleHeight() const {
|
|
|
|
return _maxVisibleHeight;
|
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
2017-11-03 12:03:00 +00:00
|
|
|
void setScrollTopSkip(int scrollTopSkip);
|
2022-05-03 15:43:04 +00:00
|
|
|
void setScrollBottomSkip(int scrollBottomSkip);
|
2017-09-30 18:26:45 +00:00
|
|
|
int scrollTopSave() const;
|
|
|
|
void scrollTopRestore(int scrollTop);
|
|
|
|
void scrollTo(const Ui::ScrollToRequest &request);
|
2022-05-21 03:25:01 +00:00
|
|
|
[[nodiscard]] rpl::producer<int> scrollTopValue() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2022-05-21 06:11:24 +00:00
|
|
|
void setPaintPadding(const style::margins &padding);
|
|
|
|
|
2022-05-24 00:27:36 +00:00
|
|
|
void setViewport(rpl::producer<not_null<QEvent*>> &&events) const;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
private:
|
2017-11-03 18:26:14 +00:00
|
|
|
RpWidget *doSetInnerWidget(object_ptr<RpWidget> inner);
|
2017-10-27 17:41:38 +00:00
|
|
|
void updateControlsGeometry();
|
2017-11-03 18:26:14 +00:00
|
|
|
void refreshSearchField(bool shown);
|
|
|
|
|
2020-12-14 14:48:10 +00:00
|
|
|
virtual std::shared_ptr<ContentMemento> doCreateMemento() = 0;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
const not_null<Controller*> _controller;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
style::color _bg;
|
2017-11-03 12:03:00 +00:00
|
|
|
rpl::variable<int> _scrollTopSkip = -1;
|
2022-05-23 08:04:31 +00:00
|
|
|
rpl::variable<int> _scrollBottomSkip = 0;
|
2017-11-23 12:48:56 +00:00
|
|
|
rpl::event_stream<int> _scrollTillBottomChanges;
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
2017-11-23 12:48:56 +00:00
|
|
|
Ui::PaddingWrap<Ui::RpWidget> *_innerWrap = nullptr;
|
2017-12-08 08:14:30 +00:00
|
|
|
base::unique_qptr<Ui::RpWidget> _searchWrap = nullptr;
|
2017-12-08 08:22:02 +00:00
|
|
|
QPointer<Ui::InputField> _searchField;
|
2017-11-23 12:48:56 +00:00
|
|
|
int _innerDesiredHeight = 0;
|
2024-02-23 17:23:15 +00:00
|
|
|
int _maxVisibleHeight = 0;
|
2022-04-04 06:36:45 +00:00
|
|
|
bool _isStackBottom = false;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
// Saving here topDelta in setGeometryWithTopMoved() to get it passed to resizeEvent().
|
|
|
|
int _topDelta = 0;
|
|
|
|
|
2022-05-21 06:11:24 +00:00
|
|
|
// To paint round edges from content.
|
|
|
|
style::margins _paintPadding;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ContentMemento {
|
|
|
|
public:
|
2022-10-12 12:57:17 +00:00
|
|
|
ContentMemento(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Data::ForumTopic *topic,
|
|
|
|
PeerId migratedPeerId);
|
2018-09-05 19:05:49 +00:00
|
|
|
explicit ContentMemento(Settings::Tag settings);
|
2022-02-24 15:04:24 +00:00
|
|
|
explicit ContentMemento(Downloads::Tag downloads);
|
2023-06-05 16:31:15 +00:00
|
|
|
explicit ContentMemento(Stories::Tag stories);
|
2023-10-08 20:17:45 +00:00
|
|
|
explicit ContentMemento(Statistics::Tag statistics);
|
2020-01-15 11:53:42 +00:00
|
|
|
ContentMemento(not_null<PollData*> poll, FullMsgId contextId)
|
|
|
|
: _poll(poll)
|
|
|
|
, _pollContextId(contextId) {
|
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
virtual object_ptr<ContentWidget> createWidget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Controller*> controller,
|
2017-09-30 18:26:45 +00:00
|
|
|
const QRect &geometry) = 0;
|
|
|
|
|
2020-06-08 09:06:50 +00:00
|
|
|
PeerData *peer() const {
|
|
|
|
return _peer;
|
2017-10-03 13:05:58 +00:00
|
|
|
}
|
2017-10-31 18:25:22 +00:00
|
|
|
PeerId migratedPeerId() const {
|
|
|
|
return _migratedPeerId;
|
|
|
|
}
|
2022-09-27 12:05:47 +00:00
|
|
|
Data::ForumTopic *topic() const {
|
|
|
|
return _topic;
|
|
|
|
}
|
2018-09-05 19:05:49 +00:00
|
|
|
UserData *settingsSelf() const {
|
|
|
|
return _settingsSelf;
|
|
|
|
}
|
2023-06-05 16:31:15 +00:00
|
|
|
PeerData *storiesPeer() const {
|
|
|
|
return _storiesPeer;
|
|
|
|
}
|
|
|
|
Stories::Tab storiesTab() const {
|
|
|
|
return _storiesTab;
|
|
|
|
}
|
2023-10-08 20:17:45 +00:00
|
|
|
PeerData *statisticsPeer() const {
|
|
|
|
return _statisticsPeer;
|
|
|
|
}
|
|
|
|
FullMsgId statisticsContextId() const {
|
|
|
|
return _statisticsContextId;
|
|
|
|
}
|
2023-11-17 01:59:20 +00:00
|
|
|
FullStoryId statisticsStoryId() const {
|
|
|
|
return _statisticsStoryId;
|
|
|
|
}
|
2020-01-15 11:53:42 +00:00
|
|
|
PollData *poll() const {
|
|
|
|
return _poll;
|
|
|
|
}
|
|
|
|
FullMsgId pollContextId() const {
|
|
|
|
return _pollContextId;
|
|
|
|
}
|
2018-09-05 19:05:49 +00:00
|
|
|
Key key() const;
|
2017-10-31 18:25:22 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
virtual Section section() const = 0;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
virtual ~ContentMemento() = default;
|
|
|
|
|
|
|
|
void setScrollTop(int scrollTop) {
|
|
|
|
_scrollTop = scrollTop;
|
|
|
|
}
|
|
|
|
int scrollTop() const {
|
|
|
|
return _scrollTop;
|
|
|
|
}
|
2017-11-03 15:47:08 +00:00
|
|
|
void setSearchFieldQuery(const QString &query) {
|
|
|
|
_searchFieldQuery = query;
|
|
|
|
}
|
|
|
|
QString searchFieldQuery() const {
|
|
|
|
return _searchFieldQuery;
|
|
|
|
}
|
2017-11-03 18:26:14 +00:00
|
|
|
void setSearchEnabledByContent(bool enabled) {
|
|
|
|
_searchEnabledByContent = enabled;
|
|
|
|
}
|
|
|
|
bool searchEnabledByContent() const {
|
|
|
|
return _searchEnabledByContent;
|
|
|
|
}
|
2017-12-08 08:14:30 +00:00
|
|
|
void setSearchStartsFocused(bool focused) {
|
|
|
|
_searchStartsFocused = focused;
|
|
|
|
}
|
|
|
|
bool searchStartsFocused() const {
|
|
|
|
return _searchStartsFocused;
|
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
private:
|
2020-06-08 09:06:50 +00:00
|
|
|
PeerData * const _peer = nullptr;
|
2017-10-31 18:25:22 +00:00
|
|
|
const PeerId _migratedPeerId = 0;
|
2022-10-04 15:34:45 +00:00
|
|
|
Data::ForumTopic *_topic = nullptr;
|
2018-09-05 19:05:49 +00:00
|
|
|
UserData * const _settingsSelf = nullptr;
|
2023-06-05 16:31:15 +00:00
|
|
|
PeerData * const _storiesPeer = nullptr;
|
|
|
|
Stories::Tab _storiesTab = {};
|
2023-10-08 20:17:45 +00:00
|
|
|
PeerData * const _statisticsPeer = nullptr;
|
|
|
|
const FullMsgId _statisticsContextId;
|
2023-11-17 01:59:20 +00:00
|
|
|
const FullStoryId _statisticsStoryId;
|
2020-01-15 11:53:42 +00:00
|
|
|
PollData * const _poll = nullptr;
|
|
|
|
const FullMsgId _pollContextId;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
int _scrollTop = 0;
|
2017-11-03 15:47:08 +00:00
|
|
|
QString _searchFieldQuery;
|
2017-11-03 18:26:14 +00:00
|
|
|
bool _searchEnabledByContent = false;
|
2017-12-08 08:14:30 +00:00
|
|
|
bool _searchStartsFocused = false;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2022-10-04 15:34:45 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Info
|