2017-09-13 20:01:23 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-13 20:01:23 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "window/section_widget.h"
|
2019-04-02 13:13:30 +04:00
|
|
|
#include "ui/effects/animations.h"
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2018-01-11 22:33:26 +03:00
|
|
|
namespace Storage {
|
2018-03-09 21:48:47 +01:00
|
|
|
enum class SharedMediaType : signed char;
|
2018-01-11 22:33:26 +03:00
|
|
|
} // namespace Storage
|
|
|
|
|
2017-09-13 20:01:23 +03:00
|
|
|
namespace Ui {
|
|
|
|
class SettingsSlider;
|
2017-09-30 21:26:45 +03:00
|
|
|
class FadeShadow;
|
2017-10-03 15:57:11 +01:00
|
|
|
class PlainShadow;
|
2022-03-29 02:52:22 +03:00
|
|
|
class PopupMenu;
|
2017-11-07 19:12:54 +04:00
|
|
|
class IconButton;
|
2022-05-31 21:11:59 +04:00
|
|
|
class RoundRect;
|
2017-09-13 20:01:23 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-10-03 14:05:58 +01:00
|
|
|
namespace Window {
|
|
|
|
enum class SlideDirection;
|
|
|
|
} // namespace Window
|
|
|
|
|
2017-09-13 20:01:23 +03:00
|
|
|
namespace Info {
|
|
|
|
namespace Profile {
|
|
|
|
class Widget;
|
|
|
|
} // namespace Profile
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
class Widget;
|
|
|
|
} // namespace Media
|
|
|
|
|
2018-01-22 22:51:38 +03:00
|
|
|
class Key;
|
2017-10-31 22:25:22 +04:00
|
|
|
class Controller;
|
2017-09-16 19:53:41 +03:00
|
|
|
class Section;
|
2017-09-13 20:01:23 +03:00
|
|
|
class Memento;
|
2017-09-15 20:34:41 +03:00
|
|
|
class MoveMemento;
|
2017-10-03 14:05:58 +01:00
|
|
|
class ContentMemento;
|
2017-09-13 20:01:23 +03:00
|
|
|
class ContentWidget;
|
2017-09-30 21:26:45 +03:00
|
|
|
class TopBar;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-09-30 21:26:45 +03:00
|
|
|
enum class Wrap {
|
|
|
|
Layer,
|
|
|
|
Narrow,
|
|
|
|
Side,
|
|
|
|
};
|
|
|
|
|
2017-10-20 19:19:42 +03:00
|
|
|
struct SelectedItem {
|
2022-02-24 18:04:24 +03:00
|
|
|
explicit SelectedItem(GlobalMsgId globalId) : globalId(globalId) {
|
2017-10-20 19:19:42 +03:00
|
|
|
}
|
|
|
|
|
2022-02-24 18:04:24 +03:00
|
|
|
GlobalMsgId globalId;
|
2017-10-20 19:19:42 +03:00
|
|
|
bool canDelete = false;
|
|
|
|
bool canForward = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SelectedItems {
|
|
|
|
explicit SelectedItems(Storage::SharedMediaType type)
|
|
|
|
: type(type) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Storage::SharedMediaType type;
|
|
|
|
std::vector<SelectedItem> list;
|
2022-02-27 14:14:39 +03:00
|
|
|
};
|
2017-10-20 19:19:42 +03:00
|
|
|
|
2022-02-27 14:14:39 +03:00
|
|
|
enum class SelectionAction {
|
|
|
|
Clear,
|
|
|
|
Forward,
|
|
|
|
Delete,
|
2017-10-20 19:19:42 +03:00
|
|
|
};
|
|
|
|
|
2017-10-03 15:57:11 +01:00
|
|
|
class WrapWidget final : public Window::SectionWidget {
|
2017-09-13 20:01:23 +03:00
|
|
|
public:
|
2017-09-30 21:26:45 +03:00
|
|
|
WrapWidget(
|
2017-09-13 20:01:23 +03:00
|
|
|
QWidget *parent,
|
2019-06-06 13:21:40 +03:00
|
|
|
not_null<Window::SessionController*> window,
|
2017-09-30 21:26:45 +03:00
|
|
|
Wrap wrap,
|
2017-09-15 20:34:41 +03:00
|
|
|
not_null<Memento*> memento);
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2018-01-22 22:51:38 +03:00
|
|
|
Key key() const;
|
2018-01-22 19:42:25 +03:00
|
|
|
Dialogs::RowDescriptor activeChat() const override;
|
2017-10-31 22:25:22 +04:00
|
|
|
Wrap wrap() const {
|
|
|
|
return _wrap.current();
|
|
|
|
}
|
2017-11-21 13:20:56 +04:00
|
|
|
rpl::producer<Wrap> wrapValue() const;
|
2017-11-03 16:03:00 +04:00
|
|
|
void setWrap(Wrap wrap);
|
2017-10-03 15:57:11 +01:00
|
|
|
|
2018-05-07 20:44:33 +03:00
|
|
|
rpl::producer<> contentChanged() const;
|
|
|
|
|
2017-10-31 22:25:22 +04:00
|
|
|
not_null<Controller*> controller() {
|
|
|
|
return _controller.get();
|
|
|
|
}
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-10-03 15:57:11 +01:00
|
|
|
bool hasTopBarShadow() const override;
|
2017-09-13 20:01:23 +03:00
|
|
|
QPixmap grabForShowAnimation(
|
2017-10-03 15:57:11 +01:00
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
2017-11-16 19:24:01 +04:00
|
|
|
|
2017-10-04 11:27:21 +01:00
|
|
|
void forceContentRepaint();
|
2017-09-13 20:01:23 +03:00
|
|
|
|
|
|
|
bool showInternal(
|
2017-10-03 14:05:58 +01:00
|
|
|
not_null<Window::SectionMemento*> memento,
|
2017-10-03 15:57:11 +01:00
|
|
|
const Window::SectionShow ¶ms) override;
|
2017-12-04 11:33:33 +04:00
|
|
|
bool showBackFromStackInternal(const Window::SectionShow ¶ms);
|
2022-05-03 07:02:51 +03:00
|
|
|
void removeFromStack(const std::vector<Section> §ions);
|
2020-12-14 18:48:10 +04:00
|
|
|
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-10-10 09:01:19 +01:00
|
|
|
rpl::producer<int> desiredHeightValue() const override;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
|
|
|
// Float player interface.
|
2020-06-25 18:17:37 +04:00
|
|
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
|
|
|
QRect floatPlayerAvailableRect() override;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-11-16 19:24:01 +04:00
|
|
|
object_ptr<Ui::RpWidget> createTopBarSurrogate(QWidget *parent);
|
|
|
|
|
2022-04-12 16:07:25 +04:00
|
|
|
[[nodiscard]] bool closeByOutsideClick() const;
|
2018-09-12 19:14:11 +03:00
|
|
|
|
2022-04-12 16:07:25 +04:00
|
|
|
void updateGeometry(
|
|
|
|
QRect newGeometry,
|
|
|
|
bool expanding,
|
|
|
|
int additionalScroll);
|
2022-05-23 12:04:31 +04:00
|
|
|
[[nodiscard]] int scrollBottomSkip() const;
|
2022-04-12 16:07:25 +04:00
|
|
|
[[nodiscard]] int scrollTillBottom(int forHeight) const;
|
|
|
|
[[nodiscard]] rpl::producer<int> scrollTillBottomChanges() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> grabbingForExpanding() const;
|
2022-05-31 21:11:59 +04:00
|
|
|
[[nodiscard]] const Ui::RoundRect *bottomSkipRounding() const;
|
2017-11-23 16:48:56 +04:00
|
|
|
|
2022-10-14 23:24:46 +04:00
|
|
|
[[nodiscard]] rpl::producer<> removeRequests() const override {
|
2022-10-12 16:57:17 +04:00
|
|
|
return _removeRequests.events();
|
|
|
|
}
|
|
|
|
|
2017-10-03 14:05:58 +01:00
|
|
|
~WrapWidget();
|
|
|
|
|
2017-09-13 20:01:23 +03:00
|
|
|
protected:
|
2017-10-10 09:01:19 +01:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2017-11-17 18:54:01 +04:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-10-03 15:57:11 +01:00
|
|
|
void doSetInnerFocus() override;
|
|
|
|
void showFinishedHook() override;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-11-16 19:24:01 +04:00
|
|
|
void showAnimatedHook(
|
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
|
|
|
|
2017-09-13 20:01:23 +03:00
|
|
|
private:
|
2017-10-03 14:05:58 +01:00
|
|
|
using SlideDirection = Window::SlideDirection;
|
|
|
|
using SectionSlideParams = Window::SectionSlideParams;
|
|
|
|
struct StackItem;
|
|
|
|
|
2017-11-16 21:19:41 +04:00
|
|
|
void startInjectingActivePeerProfiles();
|
2018-01-22 19:42:25 +03:00
|
|
|
void injectActiveProfile(Dialogs::Key key);
|
2017-11-16 21:19:41 +04:00
|
|
|
void injectActivePeerProfile(not_null<PeerData*> peer);
|
2018-01-22 22:51:38 +03:00
|
|
|
void injectActiveProfileMemento(
|
2020-12-14 18:48:10 +04:00
|
|
|
std::shared_ptr<ContentMemento> memento);
|
2018-09-11 10:46:07 +03:00
|
|
|
void checkBeforeClose(Fn<void()> close);
|
2017-11-03 22:26:14 +04:00
|
|
|
void restoreHistoryStack(
|
2020-12-14 18:48:10 +04:00
|
|
|
std::vector<std::shared_ptr<ContentMemento>> stack);
|
2017-11-16 21:19:41 +04:00
|
|
|
bool hasStackHistory() const {
|
|
|
|
return !_historyStack.empty();
|
|
|
|
}
|
2017-10-03 14:05:58 +01:00
|
|
|
void showNewContent(not_null<ContentMemento*> memento);
|
|
|
|
void showNewContent(
|
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms);
|
2017-11-17 11:33:20 +04:00
|
|
|
bool returnToFirstStackFrame(
|
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms);
|
2017-10-31 22:25:22 +04:00
|
|
|
void setupTop();
|
|
|
|
void createTopBar();
|
2017-11-16 13:13:17 +04:00
|
|
|
void highlightTopBar();
|
2019-03-09 21:44:46 +03:00
|
|
|
void setupShortcuts();
|
2017-10-03 14:05:58 +01:00
|
|
|
|
2022-05-23 02:06:35 +03:00
|
|
|
[[nodiscard]] bool hasBackButton() const;
|
|
|
|
|
2017-09-30 21:26:45 +03:00
|
|
|
not_null<RpWidget*> topWidget() const;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-09-15 20:34:41 +03:00
|
|
|
QRect contentGeometry() const;
|
|
|
|
rpl::producer<int> desiredHeightForContent() const;
|
2017-09-30 21:26:45 +03:00
|
|
|
void finishShowContent();
|
2017-10-03 14:05:58 +01:00
|
|
|
rpl::producer<bool> topShadowToggledValue() const;
|
2017-09-30 21:26:45 +03:00
|
|
|
void updateContentGeometry();
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-09-15 20:34:41 +03:00
|
|
|
void showContent(object_ptr<ContentWidget> content);
|
2017-10-03 14:05:58 +01:00
|
|
|
object_ptr<ContentWidget> createContent(
|
2017-10-31 22:25:22 +04:00
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
not_null<Controller*> controller);
|
|
|
|
std::unique_ptr<Controller> createController(
|
2019-06-06 13:21:40 +03:00
|
|
|
not_null<Window::SessionController*> window,
|
2017-10-03 14:05:58 +01:00
|
|
|
not_null<ContentMemento*> memento);
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-10-20 19:19:42 +03:00
|
|
|
rpl::producer<SelectedItems> selectedListValue() const;
|
2017-11-03 16:03:00 +04:00
|
|
|
bool requireTopBarSearch() const;
|
2017-10-20 19:19:42 +03:00
|
|
|
|
2018-09-06 18:24:24 +03:00
|
|
|
void addTopBarMenuButton();
|
2017-12-07 19:01:41 +04:00
|
|
|
void addProfileCallsButton();
|
2022-04-15 14:19:29 +03:00
|
|
|
void showTopBarMenu(bool check);
|
2022-03-10 18:02:38 +04:00
|
|
|
void deleteAllDownloads();
|
2017-11-07 19:12:54 +04:00
|
|
|
|
2017-10-03 14:05:58 +01:00
|
|
|
rpl::variable<Wrap> _wrap;
|
2017-10-31 22:25:22 +04:00
|
|
|
std::unique_ptr<Controller> _controller;
|
2017-09-15 20:34:41 +03:00
|
|
|
object_ptr<ContentWidget> _content = { nullptr };
|
2017-11-23 16:48:56 +04:00
|
|
|
int _additionalScroll = 0;
|
2022-04-12 16:07:25 +04:00
|
|
|
bool _expanding = false;
|
|
|
|
rpl::variable<bool> _grabbingForExpanding = false;
|
2017-09-30 21:26:45 +03:00
|
|
|
object_ptr<TopBar> _topBar = { nullptr };
|
2017-11-16 19:24:01 +04:00
|
|
|
object_ptr<Ui::RpWidget> _topBarSurrogate = { nullptr };
|
2019-04-02 13:13:30 +04:00
|
|
|
Ui::Animations::Simple _topBarOverrideAnimation;
|
2017-11-24 18:12:23 +04:00
|
|
|
bool _topBarOverrideShown = false;
|
2017-12-07 19:01:41 +04:00
|
|
|
|
2017-10-03 14:05:58 +01:00
|
|
|
object_ptr<Ui::FadeShadow> _topShadow;
|
2022-05-19 03:16:05 +03:00
|
|
|
object_ptr<Ui::FadeShadow> _bottomShadow;
|
2017-11-07 19:12:54 +04:00
|
|
|
base::unique_qptr<Ui::IconButton> _topBarMenuToggle;
|
2022-03-29 02:52:22 +03:00
|
|
|
base::unique_qptr<Ui::PopupMenu> _topBarMenu;
|
2017-11-07 19:12:54 +04:00
|
|
|
|
2017-10-03 14:05:58 +01:00
|
|
|
std::vector<StackItem> _historyStack;
|
2022-10-12 16:57:17 +04:00
|
|
|
rpl::event_stream<> _removeRequests;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
|
|
|
rpl::event_stream<rpl::producer<int>> _desiredHeights;
|
2017-10-03 14:05:58 +01:00
|
|
|
rpl::event_stream<rpl::producer<bool>> _desiredShadowVisibilities;
|
2022-05-19 03:16:05 +03:00
|
|
|
rpl::event_stream<rpl::producer<bool>> _desiredBottomShadowVisibilities;
|
2017-10-20 19:19:42 +03:00
|
|
|
rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;
|
2017-11-23 16:48:56 +04:00
|
|
|
rpl::event_stream<rpl::producer<int>> _scrollTillBottomChanges;
|
2018-05-07 20:44:33 +03:00
|
|
|
rpl::event_stream<> _contentChanges;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Info
|