mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Added entities support to title from ServiceBoxContent.
This commit is contained in:
parent
2ca763cc77
commit
23c9f7a957
11 changed files with 46 additions and 27 deletions
|
@ -49,7 +49,7 @@ public:
|
|||
int width() override;
|
||||
int top() override;
|
||||
QSize size() override;
|
||||
QString title() override;
|
||||
TextWithEntities title() override;
|
||||
TextWithEntities subtitle() override;
|
||||
int buttonSkip() override;
|
||||
rpl::producer<QString> button() override;
|
||||
|
@ -162,8 +162,8 @@ QSize PremiumRequiredBox::size() {
|
|||
return { st::msgServicePhotoWidth, st::msgServicePhotoWidth };
|
||||
}
|
||||
|
||||
QString PremiumRequiredBox::title() {
|
||||
return QString();
|
||||
TextWithEntities PremiumRequiredBox::title() {
|
||||
return {};
|
||||
}
|
||||
|
||||
int PremiumRequiredBox::buttonSkip() {
|
||||
|
|
|
@ -66,29 +66,35 @@ QSize PremiumGift::size() {
|
|||
st::msgServiceGiftBoxStickerSize);
|
||||
}
|
||||
|
||||
QString PremiumGift::title() {
|
||||
TextWithEntities PremiumGift::title() {
|
||||
using namespace Ui::Text;
|
||||
if (starGift()) {
|
||||
const auto peer = _parent->history()->peer;
|
||||
return peer->isSelf()
|
||||
? tr::lng_action_gift_self_subtitle(tr::now)
|
||||
? tr::lng_action_gift_self_subtitle(tr::now, WithEntities)
|
||||
: peer->isServiceUser()
|
||||
? tr::lng_gift_link_label_gift(tr::now)
|
||||
? tr::lng_gift_link_label_gift(tr::now, WithEntities)
|
||||
: (outgoingGift()
|
||||
? tr::lng_action_gift_sent_subtitle
|
||||
: tr::lng_action_gift_got_subtitle)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
peer->shortName());
|
||||
WithEntities(peer->shortName()),
|
||||
WithEntities);
|
||||
} else if (creditsPrize()) {
|
||||
return tr::lng_prize_title(tr::now);
|
||||
} else if (const auto count = credits()) {
|
||||
return tr::lng_gift_stars_title(tr::now, lt_count, count);
|
||||
return tr::lng_prize_title(tr::now, WithEntities);
|
||||
} else if (const auto c = credits()) {
|
||||
return tr::lng_gift_stars_title(tr::now, lt_count, c, WithEntities);
|
||||
}
|
||||
return gift()
|
||||
? tr::lng_action_gift_premium_months(tr::now, lt_count, _data.count)
|
||||
? tr::lng_action_gift_premium_months(
|
||||
tr::now,
|
||||
lt_count,
|
||||
_data.count,
|
||||
WithEntities)
|
||||
: _data.unclaimed
|
||||
? tr::lng_prize_unclaimed_title(tr::now)
|
||||
: tr::lng_prize_title(tr::now);
|
||||
? tr::lng_prize_unclaimed_title(tr::now, WithEntities)
|
||||
: tr::lng_prize_title(tr::now, WithEntities);
|
||||
}
|
||||
|
||||
TextWithEntities PremiumGift::subtitle() {
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
int top() override;
|
||||
int width() override;
|
||||
QSize size() override;
|
||||
QString title() override;
|
||||
TextWithEntities title() override;
|
||||
TextWithEntities subtitle() override;
|
||||
rpl::producer<QString> button() override;
|
||||
bool buttonMinistars() override;
|
||||
|
|
|
@ -45,8 +45,12 @@ ServiceBox::ServiceBox(
|
|||
, _title(
|
||||
st::defaultSubsectionTitle.style,
|
||||
_content->title(),
|
||||
kDefaultTextOptions,
|
||||
_maxWidth)
|
||||
kMarkupTextOptions,
|
||||
_maxWidth,
|
||||
Core::MarkedTextContext{
|
||||
.session = &parent->history()->session(),
|
||||
.customEmojiRepaint = [parent] { parent->customEmojiRepaint(); },
|
||||
})
|
||||
, _subtitle(
|
||||
st::premiumPreviewAbout.style,
|
||||
Ui::Text::Filtered(
|
||||
|
@ -148,7 +152,16 @@ void ServiceBox::draw(Painter &p, const PaintContext &context) const {
|
|||
const auto &padding = st::msgServiceGiftBoxTitlePadding;
|
||||
top += padding.top();
|
||||
if (!_title.isEmpty()) {
|
||||
_title.draw(p, st::msgPadding.left(), top, _maxWidth, style::al_top);
|
||||
_title.draw(p, {
|
||||
.position = QPoint(st::msgPadding.left(), top),
|
||||
.availableWidth = _maxWidth,
|
||||
.align = style::al_top,
|
||||
.palette = &context.st->serviceTextPalette(),
|
||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||
.now = context.now,
|
||||
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||
});
|
||||
top += _title.countHeight(_maxWidth) + padding.bottom();
|
||||
}
|
||||
_parent->prepareCustomEmojiPaint(p, context, _subtitle);
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
[[nodiscard]] virtual int width();
|
||||
[[nodiscard]] virtual int top() = 0;
|
||||
[[nodiscard]] virtual QSize size() = 0;
|
||||
[[nodiscard]] virtual QString title() = 0;
|
||||
[[nodiscard]] virtual TextWithEntities title() = 0;
|
||||
[[nodiscard]] virtual TextWithEntities subtitle() = 0;
|
||||
[[nodiscard]] virtual int buttonSkip() {
|
||||
return top();
|
||||
|
|
|
@ -68,8 +68,8 @@ QSize StoryMention::size() {
|
|||
return { st::msgServicePhotoWidth, st::msgServicePhotoWidth };
|
||||
}
|
||||
|
||||
QString StoryMention::title() {
|
||||
return QString();
|
||||
TextWithEntities StoryMention::title() {
|
||||
return {};
|
||||
}
|
||||
|
||||
int StoryMention::buttonSkip() {
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
int top() override;
|
||||
QSize size() override;
|
||||
QString title() override;
|
||||
TextWithEntities title() override;
|
||||
TextWithEntities subtitle() override;
|
||||
int buttonSkip() override;
|
||||
rpl::producer<QString> button() override;
|
||||
|
|
|
@ -509,8 +509,8 @@ QSize ThemeDocumentBox::size() {
|
|||
: QSize(st::msgServicePhotoWidth, st::msgServicePhotoWidth);
|
||||
}
|
||||
|
||||
QString ThemeDocumentBox::title() {
|
||||
return QString();
|
||||
TextWithEntities ThemeDocumentBox::title() {
|
||||
return {};
|
||||
}
|
||||
|
||||
TextWithEntities ThemeDocumentBox::subtitle() {
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
|
||||
int top() override;
|
||||
QSize size() override;
|
||||
QString title() override;
|
||||
TextWithEntities title() override;
|
||||
TextWithEntities subtitle() override;
|
||||
rpl::producer<QString> button() override;
|
||||
void draw(
|
||||
|
|
|
@ -197,8 +197,8 @@ QSize UserpicSuggestion::size() {
|
|||
return { _photo.maxWidth(), _photo.minHeight() };
|
||||
}
|
||||
|
||||
QString UserpicSuggestion::title() {
|
||||
return QString();
|
||||
TextWithEntities UserpicSuggestion::title() {
|
||||
return {};
|
||||
}
|
||||
|
||||
rpl::producer<QString> UserpicSuggestion::button() {
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
int top() override;
|
||||
QSize size() override;
|
||||
QString title() override;
|
||||
TextWithEntities title() override;
|
||||
TextWithEntities subtitle() override;
|
||||
rpl::producer<QString> button() override;
|
||||
void draw(
|
||||
|
|
Loading…
Add table
Reference in a new issue