2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Support custom emoji in reply / pinned / forward bars.

This commit is contained in:
John Preston
2022-07-04 12:49:31 +04:00
parent 2fc43a44a4
commit 3238cf2b4b
12 changed files with 112 additions and 39 deletions

View File

@@ -41,9 +41,13 @@ namespace {
} // namespace
MessageBar::MessageBar(not_null<QWidget*> parent, const style::MessageBar &st)
MessageBar::MessageBar(
not_null<QWidget*> parent,
const style::MessageBar &st,
Fn<bool()> customEmojiPaused)
: _st(st)
, _widget(parent) {
, _widget(parent)
, _customEmojiPaused(std::move(customEmojiPaused)) {
setup();
style::PaletteChanged(
@@ -57,6 +61,7 @@ void MessageBar::setup() {
_widget.paintRequest(
) | rpl::start_with_next([=](QRect rect) {
auto p = Painter(&_widget);
p.setInactive(_customEmojiPaused());
paint(p);
}, _widget.lifetime());
}
@@ -187,7 +192,11 @@ void MessageBar::tweenTo(MessageBarContent &&content) {
void MessageBar::updateFromContent(MessageBarContent &&content) {
_content = std::move(content);
_title.setText(_st.title, _content.title);
_text.setMarkedText(_st.text, _content.text, Ui::DialogTextOptions());
_text.setMarkedText(
_st.text,
_content.text,
Ui::DialogTextOptions(),
_content.context);
_image = prepareImage(_content.preview);
}

View File

@@ -23,13 +23,17 @@ struct MessageBarContent {
int count = 1;
QString title;
TextWithEntities text;
std::any context;
QImage preview;
style::margins margins;
};
class MessageBar final {
public:
MessageBar(not_null<QWidget*> parent, const style::MessageBar &st);
MessageBar(
not_null<QWidget*> parent,
const style::MessageBar &st,
Fn<bool()> customEmojiPaused);
void set(MessageBarContent &&content);
void set(rpl::producer<MessageBarContent> content);
@@ -100,6 +104,7 @@ private:
const style::MessageBar &_st;
Ui::RpWidget _widget;
Fn<bool()> _customEmojiPaused;
MessageBarContent _content;
rpl::lifetime _contentLifetime;
Ui::Text::String _title, _text;

View File

@@ -18,9 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Ui {
PinnedBar::PinnedBar(not_null<QWidget*> parent)
PinnedBar::PinnedBar(not_null<QWidget*> parent, Fn<bool()> customEmojiPaused)
: _wrap(parent, object_ptr<RpWidget>(parent))
, _shadow(std::make_unique<PlainShadow>(_wrap.parentWidget())) {
, _shadow(std::make_unique<PlainShadow>(_wrap.parentWidget()))
, _customEmojiPaused(std::move(customEmojiPaused)) {
_wrap.hide(anim::type::instant);
_shadow->hide();
@@ -133,7 +134,8 @@ void PinnedBar::createControls() {
_bar = std::make_unique<MessageBar>(
_wrap.entity(),
st::defaultMessageBar);
st::defaultMessageBar,
_customEmojiPaused);
if (_right.button) {
_right.button->raise();
}
@@ -205,6 +207,12 @@ void PinnedBar::raise() {
_shadow->raise();
}
void PinnedBar::update() {
if (_bar) {
_bar->widget()->update();
}
}
void PinnedBar::finishAnimating() {
_wrap.finishAnimating();
}

View File

@@ -22,12 +22,13 @@ class RpWidget;
class PinnedBar final {
public:
PinnedBar(not_null<QWidget*> parent);
PinnedBar(not_null<QWidget*> parent, Fn<bool()> customEmojiPaused);
~PinnedBar();
void show();
void hide();
void raise();
void update();
void finishAnimating();
void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
@@ -60,6 +61,7 @@ private:
} _right;
std::unique_ptr<Ui::PlainShadow> _shadow;
Fn<bool()> _customEmojiPaused;
rpl::event_stream<> _barClicks;
Fn<QRect(QRect)> _shadowGeometryPostprocess;
bool _shouldBeShown = false;