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;
|
2017-11-07 19:12:54 +04:00
|
|
|
class DropdownMenu;
|
|
|
|
class IconButton;
|
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 {
|
|
|
|
explicit SelectedItem(FullMsgId msgId) : msgId(msgId) {
|
|
|
|
}
|
|
|
|
|
|
|
|
FullMsgId msgId;
|
|
|
|
bool canDelete = false;
|
|
|
|
bool canForward = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SelectedItems {
|
|
|
|
explicit SelectedItems(Storage::SharedMediaType type)
|
|
|
|
: type(type) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Storage::SharedMediaType type;
|
|
|
|
std::vector<SelectedItem> list;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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,
|
2017-10-31 22:25:22 +04:00
|
|
|
not_null<Window::Controller*> 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);
|
2017-10-03 15:57:11 +01:00
|
|
|
std::unique_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
|
|
|
|
2017-09-30 21:26:45 +03:00
|
|
|
void updateInternalState(not_null<Memento*> memento);
|
2017-09-13 20:01:23 +03:00
|
|
|
|
|
|
|
// Float player interface.
|
2017-10-03 15:57:11 +01:00
|
|
|
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
|
|
|
QRect rectForFloatPlayer() const override;
|
2017-09-13 20:01:23 +03:00
|
|
|
|
2017-11-16 19:24:01 +04:00
|
|
|
object_ptr<Ui::RpWidget> createTopBarSurrogate(QWidget *parent);
|
|
|
|
|
2018-09-12 19:14:11 +03:00
|
|
|
bool closeByOutsideClick() const;
|
|
|
|
|
2017-11-23 16:48:56 +04:00
|
|
|
void updateGeometry(QRect newGeometry, int additionalScroll);
|
|
|
|
int scrollTillBottom(int forHeight) const;
|
|
|
|
rpl::producer<int> scrollTillBottomChanges() const;
|
|
|
|
|
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;
|
2017-11-16 21:19:41 +04:00
|
|
|
//enum class Tab {
|
|
|
|
// Profile,
|
|
|
|
// Media,
|
|
|
|
// None,
|
|
|
|
//};
|
2017-10-03 14:05:58 +01:00
|
|
|
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);
|
2019-04-15 15:54:03 +04:00
|
|
|
//void injectActiveFeedProfile(not_null<Data::Feed*> feed); // #feed
|
2018-01-22 22:51:38 +03:00
|
|
|
void injectActiveProfileMemento(
|
|
|
|
std::unique_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(
|
|
|
|
std::vector<std::unique_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();
|
2017-11-16 13:13:17 +04:00
|
|
|
//void setupTabbedTop();
|
|
|
|
//void setupTabs(Tab tab);
|
|
|
|
//void createTabs();
|
2017-10-31 22:25:22 +04:00
|
|
|
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
|
|
|
|
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-11-16 13:13:17 +04:00
|
|
|
//void showTab(Tab tab);
|
2017-09-15 20:34:41 +03:00
|
|
|
void showContent(object_ptr<ContentWidget> content);
|
2017-11-16 21:19:41 +04:00
|
|
|
//std::unique_ptr<ContentMemento> createTabMemento(Tab tab);
|
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(
|
|
|
|
not_null<Window::Controller*> window,
|
2017-10-03 14:05:58 +01:00
|
|
|
not_null<ContentMemento*> memento);
|
2017-11-16 13:13:17 +04:00
|
|
|
//void convertProfileFromStackToTab();
|
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();
|
2018-09-09 20:38:08 +03:00
|
|
|
void addContentSaveButton();
|
2017-12-07 19:01:41 +04:00
|
|
|
void addProfileCallsButton();
|
2017-11-07 19:12:54 +04:00
|
|
|
void addProfileNotificationsButton();
|
2018-09-06 18:24:24 +03:00
|
|
|
void showTopBarMenu();
|
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;
|
2017-11-16 13:13:17 +04:00
|
|
|
//object_ptr<Ui::PlainShadow> _topTabsBackground = { nullptr };
|
|
|
|
//object_ptr<Ui::SettingsSlider> _topTabs = { nullptr };
|
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;
|
2017-11-07 19:12:54 +04:00
|
|
|
base::unique_qptr<Ui::IconButton> _topBarMenuToggle;
|
|
|
|
base::unique_qptr<Ui::DropdownMenu> _topBarMenu;
|
|
|
|
|
2017-11-16 21:19:41 +04:00
|
|
|
// Tab _tab = Tab::Profile;
|
|
|
|
// std::unique_ptr<ContentMemento> _anotherTabMemento;
|
2017-10-03 14:05:58 +01:00
|
|
|
std::vector<StackItem> _historyStack;
|
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;
|
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
|