Show nice General icon in an empty topic.

This commit is contained in:
John Preston 2022-11-29 18:27:56 +04:00
parent 6ff29b8902
commit 545cf93d82
3 changed files with 32 additions and 4 deletions

View file

@ -678,7 +678,11 @@ EmptyPainter::EmptyPainter(
: _history(topic->history())
, _topic(topic)
, _icon(
std::make_unique<Info::Profile::TopicIconView>(topic, paused, update))
std::make_unique<Info::Profile::TopicIconView>(
topic,
paused,
update,
st::msgServiceFg))
, _header(st::msgMinWidth)
, _text(st::msgMinWidth) {
fillAboutTopic();

View file

@ -121,7 +121,20 @@ TopicIconView::TopicIconView(
not_null<Data::ForumTopic*> topic,
Fn<bool()> paused,
Fn<void()> update)
: TopicIconView(
topic,
std::move(paused),
std::move(update),
st::windowSubTextFg) {
}
TopicIconView::TopicIconView(
not_null<Data::ForumTopic*> topic,
Fn<bool()> paused,
Fn<void()> update,
const style::color &generalIconFg)
: _topic(topic)
, _generalIconFg(generalIconFg)
, _paused(std::move(paused))
, _update(std::move(update)) {
setup(topic);
@ -218,9 +231,14 @@ void TopicIconView::setupPlayer(not_null<Data::ForumTopic*> topic) {
void TopicIconView::setupImage(not_null<Data::ForumTopic*> topic) {
using namespace Data;
if (topic->isGeneral()) {
_image = ForumTopicGeneralIconFrame(
st::infoForumTopicIcon.size,
st::windowSubTextFg);
rpl::single(rpl::empty) | rpl::then(
style::PaletteChanged()
) | rpl::start_with_next([=] {
_image = ForumTopicGeneralIconFrame(
st::infoForumTopicIcon.size,
_generalIconFg);
_update();
}, _lifetime);
return;
}
rpl::combine(

View file

@ -50,6 +50,11 @@ public:
not_null<Data::ForumTopic*> topic,
Fn<bool()> paused,
Fn<void()> update);
TopicIconView(
not_null<Data::ForumTopic*> topic,
Fn<bool()> paused,
Fn<void()> update,
const style::color &generalIconFg);
void paintInRect(QPainter &p, QRect rect);
@ -61,6 +66,7 @@ private:
void setupImage(not_null<Data::ForumTopic*> topic);
const not_null<Data::ForumTopic*> _topic;
const style::color &_generalIconFg;
Fn<bool()> _paused;
Fn<void()> _update;
std::shared_ptr<StickerPlayer> _player;