label_with_custom_emoji.cpp 884 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "ui/widgets/label_with_custom_emoji.h"
  8. #include "core/ui_integration.h"
  9. #include "ui/widgets/labels.h"
  10. #include "styles/style_widgets.h"
  11. namespace Ui {
  12. object_ptr<Ui::FlatLabel> CreateLabelWithCustomEmoji(
  13. QWidget *parent,
  14. rpl::producer<TextWithEntities> &&text,
  15. Text::MarkedContext context,
  16. const style::FlatLabel &st) {
  17. auto label = object_ptr<Ui::FlatLabel>(parent, st);
  18. const auto raw = label.data();
  19. context.repaint = [=] { raw->update(); };
  20. std::move(text) | rpl::start_with_next([=](const TextWithEntities &text) {
  21. raw->setMarkedText(text, context);
  22. }, label->lifetime());
  23. return label;
  24. }
  25. } // namespace Ui