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 "window/section_widget.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
namespace Storage {
|
2018-03-09 20:48:47 +00:00
|
|
|
enum class SharedMediaType : signed char;
|
2018-01-11 19:33:26 +00:00
|
|
|
} // namespace Storage
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
namespace Ui {
|
|
|
|
class SettingsSlider;
|
2017-09-30 18:26:45 +00:00
|
|
|
class FadeShadow;
|
2017-10-03 14:57:11 +00:00
|
|
|
class PlainShadow;
|
2022-03-28 23:52:22 +00:00
|
|
|
class PopupMenu;
|
2017-11-07 15:12:54 +00:00
|
|
|
class IconButton;
|
2017-09-13 17:01:23 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
namespace Window {
|
|
|
|
enum class SlideDirection;
|
|
|
|
} // namespace Window
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
namespace Info {
|
|
|
|
namespace Profile {
|
|
|
|
class Widget;
|
|
|
|
} // namespace Profile
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
class Widget;
|
|
|
|
} // namespace Media
|
|
|
|
|
2018-01-22 19:51:38 +00:00
|
|
|
class Key;
|
2017-10-31 18:25:22 +00:00
|
|
|
class Controller;
|
2017-09-16 16:53:41 +00:00
|
|
|
class Section;
|
2017-09-13 17:01:23 +00:00
|
|
|
class Memento;
|
2017-09-15 17:34:41 +00:00
|
|
|
class MoveMemento;
|
2017-10-03 13:05:58 +00:00
|
|
|
class ContentMemento;
|
2017-09-13 17:01:23 +00:00
|
|
|
class ContentWidget;
|
2017-09-30 18:26:45 +00:00
|
|
|
class TopBar;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
enum class Wrap {
|
|
|
|
Layer,
|
|
|
|
Narrow,
|
|
|
|
Side,
|
|
|
|
};
|
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
struct SelectedItem {
|
2022-02-24 15:04:24 +00:00
|
|
|
explicit SelectedItem(GlobalMsgId globalId) : globalId(globalId) {
|
2017-10-20 16:19:42 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 15:04:24 +00:00
|
|
|
GlobalMsgId globalId;
|
2017-10-20 16:19:42 +00: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 11:14:39 +00:00
|
|
|
};
|
2017-10-20 16:19:42 +00:00
|
|
|
|
2022-02-27 11:14:39 +00:00
|
|
|
enum class SelectionAction {
|
|
|
|
Clear,
|
|
|
|
Forward,
|
|
|
|
Delete,
|
2017-10-20 16:19:42 +00:00
|
|
|
};
|
|
|
|
|
2017-10-03 14:57:11 +00:00
|
|
|
class WrapWidget final : public Window::SectionWidget {
|
2017-09-13 17:01:23 +00:00
|
|
|
public:
|
2017-09-30 18:26:45 +00:00
|
|
|
WrapWidget(
|
2017-09-13 17:01:23 +00:00
|
|
|
QWidget *parent,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> window,
|
2017-09-30 18:26:45 +00:00
|
|
|
Wrap wrap,
|
2017-09-15 17:34:41 +00:00
|
|
|
not_null<Memento*> memento);
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2018-01-22 19:51:38 +00:00
|
|
|
Key key() const;
|
2018-01-22 16:42:25 +00:00
|
|
|
Dialogs::RowDescriptor activeChat() const override;
|
2017-10-31 18:25:22 +00:00
|
|
|
Wrap wrap() const {
|
|
|
|
return _wrap.current();
|
|
|
|
}
|
2017-11-21 09:20:56 +00:00
|
|
|
rpl::producer<Wrap> wrapValue() const;
|
2017-11-03 12:03:00 +00:00
|
|
|
void setWrap(Wrap wrap);
|
2017-10-03 14:57:11 +00:00
|
|
|
|
2018-05-07 17:44:33 +00:00
|
|
|
rpl::producer<> contentChanged() const;
|
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Controller*> controller() {
|
|
|
|
return _controller.get();
|
|
|
|
}
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-10-03 14:57:11 +00:00
|
|
|
bool hasTopBarShadow() const override;
|
2017-09-13 17:01:23 +00:00
|
|
|
QPixmap grabForShowAnimation(
|
2017-10-03 14:57:11 +00:00
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
2017-11-16 15:24:01 +00:00
|
|
|
|
2017-10-04 10:27:21 +00:00
|
|
|
void forceContentRepaint();
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
bool showInternal(
|
2017-10-03 13:05:58 +00:00
|
|
|
not_null<Window::SectionMemento*> memento,
|
2017-10-03 14:57:11 +00:00
|
|
|
const Window::SectionShow ¶ms) override;
|
2017-12-04 07:33:33 +00:00
|
|
|
bool showBackFromStackInternal(const Window::SectionShow ¶ms);
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-10-10 08:01:19 +00:00
|
|
|
rpl::producer<int> desiredHeightValue() const override;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
void updateInternalState(not_null<Memento*> memento);
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
// Float player interface.
|
2020-06-25 14:17:37 +00:00
|
|
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
|
|
|
QRect floatPlayerAvailableRect() override;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-11-16 15:24:01 +00:00
|
|
|
object_ptr<Ui::RpWidget> createTopBarSurrogate(QWidget *parent);
|
|
|
|
|
2022-04-12 12:07:25 +00:00
|
|
|
[[nodiscard]] bool closeByOutsideClick() const;
|
2018-09-12 16:14:11 +00:00
|
|
|
|
2022-04-12 12:07:25 +00:00
|
|
|
void updateGeometry(
|
|
|
|
QRect newGeometry,
|
|
|
|
bool expanding,
|
|
|
|
int additionalScroll);
|
|
|
|
[[nodiscard]] int scrollTillBottom(int forHeight) const;
|
|
|
|
[[nodiscard]] rpl::producer<int> scrollTillBottomChanges() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> grabbingForExpanding() const;
|
2017-11-23 12:48:56 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
~WrapWidget();
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
protected:
|
2017-10-10 08:01:19 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2017-11-17 14:54:01 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-10-03 14:57:11 +00:00
|
|
|
void doSetInnerFocus() override;
|
|
|
|
void showFinishedHook() override;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-11-16 15:24:01 +00:00
|
|
|
void showAnimatedHook(
|
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
private:
|
2017-10-03 13:05:58 +00:00
|
|
|
using SlideDirection = Window::SlideDirection;
|
|
|
|
using SectionSlideParams = Window::SectionSlideParams;
|
2017-11-16 17:19:41 +00:00
|
|
|
//enum class Tab {
|
|
|
|
// Profile,
|
|
|
|
// Media,
|
|
|
|
// None,
|
|
|
|
//};
|
2017-10-03 13:05:58 +00:00
|
|
|
struct StackItem;
|
|
|
|
|
2017-11-16 17:19:41 +00:00
|
|
|
void startInjectingActivePeerProfiles();
|
2018-01-22 16:42:25 +00:00
|
|
|
void injectActiveProfile(Dialogs::Key key);
|
2017-11-16 17:19:41 +00:00
|
|
|
void injectActivePeerProfile(not_null<PeerData*> peer);
|
2018-01-22 19:51:38 +00:00
|
|
|
void injectActiveProfileMemento(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<ContentMemento> memento);
|
2018-09-11 07:46:07 +00:00
|
|
|
void checkBeforeClose(Fn<void()> close);
|
2017-11-03 18:26:14 +00:00
|
|
|
void restoreHistoryStack(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::vector<std::shared_ptr<ContentMemento>> stack);
|
2017-11-16 17:19:41 +00:00
|
|
|
bool hasStackHistory() const {
|
|
|
|
return !_historyStack.empty();
|
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
void showNewContent(not_null<ContentMemento*> memento);
|
|
|
|
void showNewContent(
|
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms);
|
2017-11-17 07:33:20 +00:00
|
|
|
bool returnToFirstStackFrame(
|
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms);
|
2017-10-31 18:25:22 +00:00
|
|
|
void setupTop();
|
2017-11-16 09:13:17 +00:00
|
|
|
//void setupTabbedTop();
|
|
|
|
//void setupTabs(Tab tab);
|
|
|
|
//void createTabs();
|
2017-10-31 18:25:22 +00:00
|
|
|
void createTopBar();
|
2017-11-16 09:13:17 +00:00
|
|
|
void highlightTopBar();
|
2019-03-09 18:44:46 +00:00
|
|
|
void setupShortcuts();
|
2017-10-03 13:05:58 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
not_null<RpWidget*> topWidget() const;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
QRect contentGeometry() const;
|
|
|
|
rpl::producer<int> desiredHeightForContent() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
void finishShowContent();
|
2017-10-03 13:05:58 +00:00
|
|
|
rpl::producer<bool> topShadowToggledValue() const;
|
2017-09-30 18:26:45 +00:00
|
|
|
void updateContentGeometry();
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-11-16 09:13:17 +00:00
|
|
|
//void showTab(Tab tab);
|
2017-09-15 17:34:41 +00:00
|
|
|
void showContent(object_ptr<ContentWidget> content);
|
2020-12-14 14:48:10 +00:00
|
|
|
//std::shared_ptr<ContentMemento> createTabMemento(Tab tab);
|
2017-10-03 13:05:58 +00:00
|
|
|
object_ptr<ContentWidget> createContent(
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
not_null<Controller*> controller);
|
|
|
|
std::unique_ptr<Controller> createController(
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> window,
|
2017-10-03 13:05:58 +00:00
|
|
|
not_null<ContentMemento*> memento);
|
2017-11-16 09:13:17 +00:00
|
|
|
//void convertProfileFromStackToTab();
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
rpl::producer<SelectedItems> selectedListValue() const;
|
2017-11-03 12:03:00 +00:00
|
|
|
bool requireTopBarSearch() const;
|
2017-10-20 16:19:42 +00:00
|
|
|
|
2018-09-06 15:24:24 +00:00
|
|
|
void addTopBarMenuButton();
|
2017-12-07 15:01:41 +00:00
|
|
|
void addProfileCallsButton();
|
2022-04-15 11:19:29 +00:00
|
|
|
void showTopBarMenu(bool check);
|
2022-03-10 14:02:38 +00:00
|
|
|
void deleteAllDownloads();
|
2017-11-07 15:12:54 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
rpl::variable<Wrap> _wrap;
|
2017-10-31 18:25:22 +00:00
|
|
|
std::unique_ptr<Controller> _controller;
|
2017-09-15 17:34:41 +00:00
|
|
|
object_ptr<ContentWidget> _content = { nullptr };
|
2017-11-23 12:48:56 +00:00
|
|
|
int _additionalScroll = 0;
|
2022-04-12 12:07:25 +00:00
|
|
|
bool _expanding = false;
|
|
|
|
rpl::variable<bool> _grabbingForExpanding = false;
|
2017-11-16 09:13:17 +00:00
|
|
|
//object_ptr<Ui::PlainShadow> _topTabsBackground = { nullptr };
|
|
|
|
//object_ptr<Ui::SettingsSlider> _topTabs = { nullptr };
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<TopBar> _topBar = { nullptr };
|
2017-11-16 15:24:01 +00:00
|
|
|
object_ptr<Ui::RpWidget> _topBarSurrogate = { nullptr };
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _topBarOverrideAnimation;
|
2017-11-24 14:12:23 +00:00
|
|
|
bool _topBarOverrideShown = false;
|
2017-12-07 15:01:41 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
object_ptr<Ui::FadeShadow> _topShadow;
|
2017-11-07 15:12:54 +00:00
|
|
|
base::unique_qptr<Ui::IconButton> _topBarMenuToggle;
|
2022-03-28 23:52:22 +00:00
|
|
|
base::unique_qptr<Ui::PopupMenu> _topBarMenu;
|
2017-11-07 15:12:54 +00:00
|
|
|
|
2017-11-16 17:19:41 +00:00
|
|
|
// Tab _tab = Tab::Profile;
|
2020-12-14 14:48:10 +00:00
|
|
|
// std::shared_ptr<ContentMemento> _anotherTabMemento;
|
2017-10-03 13:05:58 +00:00
|
|
|
std::vector<StackItem> _historyStack;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
rpl::event_stream<rpl::producer<int>> _desiredHeights;
|
2017-10-03 13:05:58 +00:00
|
|
|
rpl::event_stream<rpl::producer<bool>> _desiredShadowVisibilities;
|
2017-10-20 16:19:42 +00:00
|
|
|
rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;
|
2017-11-23 12:48:56 +00:00
|
|
|
rpl::event_stream<rpl::producer<int>> _scrollTillBottomChanges;
|
2018-05-07 17:44:33 +00:00
|
|
|
rpl::event_stream<> _contentChanges;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Info
|