mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added support of chat themes to viewer widget for messages with ttl.
This commit is contained in:
parent
21dcb7b13c
commit
5ba918d213
1 changed files with 21 additions and 6 deletions
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/tooltip.h"
|
#include "ui/widgets/tooltip.h"
|
||||||
|
#include "window/section_widget.h" // Window::ChatThemeValueFromPeer.
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
@ -81,7 +82,10 @@ bool PreviewDelegate::elementIsChatWide() {
|
||||||
|
|
||||||
class PreviewWrap final : public Ui::RpWidget {
|
class PreviewWrap final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
PreviewWrap(not_null<Ui::RpWidget*> parent, not_null<HistoryItem*> item);
|
PreviewWrap(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
rpl::producer<std::shared_ptr<Ui::ChatTheme>> theme);
|
||||||
~PreviewWrap();
|
~PreviewWrap();
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> closeRequests() const;
|
[[nodiscard]] rpl::producer<> closeRequests() const;
|
||||||
|
@ -91,9 +95,9 @@ private:
|
||||||
[[nodiscard]] QRect elementRect() const;
|
[[nodiscard]] QRect elementRect() const;
|
||||||
|
|
||||||
const not_null<HistoryItem*> _item;
|
const not_null<HistoryItem*> _item;
|
||||||
const std::unique_ptr<Ui::ChatTheme> _theme;
|
|
||||||
const std::unique_ptr<Ui::ChatStyle> _style;
|
const std::unique_ptr<Ui::ChatStyle> _style;
|
||||||
const std::unique_ptr<PreviewDelegate> _delegate;
|
const std::unique_ptr<PreviewDelegate> _delegate;
|
||||||
|
std::shared_ptr<Ui::ChatTheme> _theme;
|
||||||
std::unique_ptr<HistoryView::Element> _element;
|
std::unique_ptr<HistoryView::Element> _element;
|
||||||
rpl::lifetime _elementLifetime;
|
rpl::lifetime _elementLifetime;
|
||||||
|
|
||||||
|
@ -108,17 +112,23 @@ private:
|
||||||
|
|
||||||
PreviewWrap::PreviewWrap(
|
PreviewWrap::PreviewWrap(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<HistoryItem*> item)
|
not_null<HistoryItem*> item,
|
||||||
|
rpl::producer<std::shared_ptr<Ui::ChatTheme>> theme)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _item(item)
|
, _item(item)
|
||||||
, _theme(Window::Theme::DefaultChatThemeOn(lifetime()))
|
|
||||||
, _style(std::make_unique<Ui::ChatStyle>(
|
, _style(std::make_unique<Ui::ChatStyle>(
|
||||||
item->history()->session().colorIndicesValue()))
|
item->history()->session().colorIndicesValue()))
|
||||||
, _delegate(std::make_unique<PreviewDelegate>(
|
, _delegate(std::make_unique<PreviewDelegate>(
|
||||||
parent,
|
parent,
|
||||||
_style.get(),
|
_style.get(),
|
||||||
[=] { update(elementRect()); })) {
|
[=] { update(elementRect()); })) {
|
||||||
_style->apply(_theme.get());
|
|
||||||
|
std::move(
|
||||||
|
theme
|
||||||
|
) | rpl::start_with_next([=](std::shared_ptr<Ui::ChatTheme> theme) {
|
||||||
|
_theme = std::move(theme);
|
||||||
|
_style->apply(_theme.get());
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
const auto session = &_item->history()->session();
|
const auto session = &_item->history()->session();
|
||||||
session->data().viewRepaintRequest(
|
session->data().viewRepaintRequest(
|
||||||
|
@ -269,7 +279,12 @@ void ShowTTLMediaLayerWidget(
|
||||||
not_null<HistoryItem*> item) {
|
not_null<HistoryItem*> item) {
|
||||||
const auto parent = controller->content();
|
const auto parent = controller->content();
|
||||||
const auto show = controller->uiShow();
|
const auto show = controller->uiShow();
|
||||||
auto preview = base::make_unique_q<PreviewWrap>(parent, item);
|
auto preview = base::make_unique_q<PreviewWrap>(
|
||||||
|
parent,
|
||||||
|
item,
|
||||||
|
Window::ChatThemeValueFromPeer(
|
||||||
|
controller,
|
||||||
|
item->history()->peer));
|
||||||
preview->closeRequests(
|
preview->closeRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
show->hideLayer();
|
show->hideLayer();
|
||||||
|
|
Loading…
Add table
Reference in a new issue