mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-24 06:22:59 +02:00
Added some utils to convenient insert of credits icons to text labels.
This commit is contained in:
parent
8e3100acdd
commit
ef5a9eb777
4 changed files with 27 additions and 16 deletions
|
@ -204,32 +204,22 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
|||
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,
|
||||
lt_count,
|
||||
float64(needed - whole),
|
||||
lt_emoji,
|
||||
Ui::Text::SingleCustomEmoji(Ui::kCreditsCurrency),
|
||||
Ui::MakeCreditsIconEntity(),
|
||||
lt_channels,
|
||||
{ peers },
|
||||
Ui::Text::Bold),
|
||||
tr::lng_dialogs_suggestions_credits_sub_low_about(
|
||||
tr::now,
|
||||
TextWithEntities::Simple),
|
||||
std::move(context));
|
||||
Ui::MakeCreditsIconContext(
|
||||
content->contentTitleSt().font->height,
|
||||
1));
|
||||
state->desiredWrapToggle.force_assign(
|
||||
Toggle{ true, anim::type::normal });
|
||||
};
|
||||
|
|
|
@ -2966,7 +2966,7 @@ object_ptr<Ui::RpWidget> SetupChannelMembersAndManage(
|
|||
std::move(currencyValue)
|
||||
) | rpl::map([](CreditsAmount credits, CreditsAmount currency) {
|
||||
auto creditsText = (credits > CreditsAmount(0))
|
||||
? Ui::Text::SingleCustomEmoji(Ui::kCreditsCurrency)
|
||||
? Ui::MakeCreditsIconEntity()
|
||||
.append(QChar(' '))
|
||||
.append(Info::ChannelEarn::MajorPart(credits))
|
||||
.append(Info::ChannelEarn::MinorPart(credits))
|
||||
|
|
|
@ -26,7 +26,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/empty_userpic.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/fields/number_input.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
|
@ -691,4 +693,18 @@ std::unique_ptr<Ui::Text::CustomEmoji> MakeCreditsIconEmoji(
|
|||
u"credits_icon:%1:%2"_q.arg(height).arg(count));
|
||||
}
|
||||
|
||||
Ui::Text::MarkedContext MakeCreditsIconContext(int height, int count) {
|
||||
auto customEmojiFactory = [=](
|
||||
QStringView data,
|
||||
const Ui::Text::MarkedContext &context
|
||||
) -> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
return MakeCreditsIconEmoji(height, count);
|
||||
};
|
||||
return { .customEmojiFactory = std::move(customEmojiFactory) };
|
||||
}
|
||||
|
||||
TextWithEntities MakeCreditsIconEntity() {
|
||||
return Ui::Text::SingleCustomEmoji(Ui::kCreditsCurrency);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -21,6 +21,7 @@ class Session;
|
|||
|
||||
namespace Ui::Text {
|
||||
class CustomEmoji;
|
||||
struct MarkedContext;
|
||||
} // namespace Ui::Text
|
||||
|
||||
namespace Ui {
|
||||
|
@ -86,8 +87,12 @@ Fn<void(QPainter &)> PaintOutlinedColoredCreditsIconCallback(
|
|||
|
||||
[[nodiscard]] QImage CreditsWhiteDoubledIcon(int size, float64 outlineRatio);
|
||||
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> MakeCreditsIconEmoji(
|
||||
[[nodiscard]] std::unique_ptr<Ui::Text::CustomEmoji> MakeCreditsIconEmoji(
|
||||
int height,
|
||||
int count);
|
||||
[[nodiscard]] Ui::Text::MarkedContext MakeCreditsIconContext(
|
||||
int height,
|
||||
int count);
|
||||
[[nodiscard]] TextWithEntities MakeCreditsIconEntity();
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue