mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Added support of custom emoji to top bar suggestion.
This commit is contained in:
parent
ba31bbace8
commit
97c0e3d4a9
3 changed files with 38 additions and 18 deletions
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/star_gift_box.h" // ShowStarGiftBox.
|
||||
#include "core/application.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "data/data_birthday.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_session.h"
|
||||
|
@ -28,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_credits_graphics.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/credits_graphics.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
|
@ -136,7 +138,11 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
|||
promo->dismiss(custom->suggestion);
|
||||
repeat(repeat);
|
||||
});
|
||||
content->setContent(custom->title, custom->description);
|
||||
|
||||
content->setContent(
|
||||
custom->title,
|
||||
custom->description,
|
||||
Core::TextContext({ .session = session }));
|
||||
state->desiredWrapToggle.force_assign(
|
||||
Toggle{ true, anim::type::normal });
|
||||
return;
|
||||
|
@ -194,6 +200,19 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
|||
promo->dismiss(kSugLowCreditsSubs.utf8());
|
||||
repeat(repeat);
|
||||
});
|
||||
|
||||
const auto fontH = content->contentTitleSt().font->height;
|
||||
auto customEmojiFactory = [=](
|
||||
QStringView data,
|
||||
const Ui::Text::MarkedContext &context
|
||||
) -> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
return Ui::MakeCreditsIconEmoji(fontH, 1);
|
||||
};
|
||||
using namespace Ui::Text;
|
||||
auto context = MarkedContext{
|
||||
.customEmojiFactory = std::move(customEmojiFactory),
|
||||
};
|
||||
|
||||
content->setContent(
|
||||
tr::lng_dialogs_suggestions_credits_sub_low_title(
|
||||
tr::now,
|
||||
|
@ -207,7 +226,7 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
|||
tr::lng_dialogs_suggestions_credits_sub_low_about(
|
||||
tr::now,
|
||||
TextWithEntities::Simple),
|
||||
true);
|
||||
std::move(context));
|
||||
state->desiredWrapToggle.force_assign(
|
||||
Toggle{ true, anim::type::normal });
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ For license and copyright information please follow this link:
|
|||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "dialogs/ui/dialogs_top_bar_suggestion_content.h"
|
||||
#include "ui/effects/credits_graphics.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
#include "ui/ui_rpl_filter.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
@ -141,28 +141,19 @@ void TopBarSuggestionContent::draw(QPainter &p) {
|
|||
void TopBarSuggestionContent::setContent(
|
||||
TextWithEntities title,
|
||||
TextWithEntities description,
|
||||
bool makeContext) {
|
||||
if (makeContext) {
|
||||
auto customEmojiFactory = [=, h = _contentTitleSt.font->height](
|
||||
QStringView data,
|
||||
const Ui::Text::MarkedContext &context
|
||||
) -> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
return Ui::MakeCreditsIconEmoji(h, 1);
|
||||
};
|
||||
const auto context = Ui::Text::MarkedContext{
|
||||
.repaint = [=] { update(); },
|
||||
.customEmojiFactory = std::move(customEmojiFactory),
|
||||
};
|
||||
std::optional<Ui::Text::MarkedContext> context) {
|
||||
if (context) {
|
||||
context->repaint = [=] { update(); };
|
||||
_contentTitle.setMarkedText(
|
||||
_contentTitleSt,
|
||||
std::move(title),
|
||||
kMarkupTextOptions,
|
||||
context);
|
||||
*context);
|
||||
_contentText.setMarkedText(
|
||||
_contentTextSt,
|
||||
std::move(description),
|
||||
kMarkupTextOptions,
|
||||
context);
|
||||
base::take(*context));
|
||||
} else {
|
||||
_contentTitle.setMarkedText(_contentTitleSt, std::move(title));
|
||||
_contentText.setMarkedText(_contentTextSt, std::move(description));
|
||||
|
@ -203,4 +194,8 @@ void TopBarSuggestionContent::setLeftPadding(int value) {
|
|||
update();
|
||||
}
|
||||
|
||||
const style::TextStyle & TopBarSuggestionContent::contentTitleSt() const {
|
||||
return _contentTitleSt;
|
||||
}
|
||||
|
||||
} // namespace Dialogs
|
||||
|
|
|
@ -14,6 +14,10 @@ class DynamicImage;
|
|||
class IconButton;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Ui::Text {
|
||||
struct MarkedContext;
|
||||
} // namespace Ui::Text
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
class TopBarSuggestionContent : public Ui::RippleButton {
|
||||
|
@ -29,7 +33,7 @@ public:
|
|||
void setContent(
|
||||
TextWithEntities title,
|
||||
TextWithEntities description,
|
||||
bool makeContext = false);
|
||||
std::optional<Ui::Text::MarkedContext> context = std::nullopt);
|
||||
|
||||
[[nodiscard]] rpl::producer<int> desiredHeightValue() const override;
|
||||
|
||||
|
@ -37,6 +41,8 @@ public:
|
|||
void setRightIcon(RightIcon);
|
||||
void setLeftPadding(int);
|
||||
|
||||
[[nodiscard]] const style::TextStyle &contentTitleSt() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue