2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-22 10:17:10 +00:00
tdesktop/Telegram/SourceFiles/info/info_wrap_widget.h

252 lines
6.5 KiB
C
Raw Normal View History

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