mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 width() override;
|
||||||
int top() override;
|
int top() override;
|
||||||
QSize size() override;
|
QSize size() override;
|
||||||
QString title() override;
|
TextWithEntities title() override;
|
||||||
TextWithEntities subtitle() override;
|
TextWithEntities subtitle() override;
|
||||||
int buttonSkip() override;
|
int buttonSkip() override;
|
||||||
rpl::producer<QString> button() override;
|
rpl::producer<QString> button() override;
|
||||||
|
@ -162,8 +162,8 @@ QSize PremiumRequiredBox::size() {
|
||||||
return { st::msgServicePhotoWidth, st::msgServicePhotoWidth };
|
return { st::msgServicePhotoWidth, st::msgServicePhotoWidth };
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PremiumRequiredBox::title() {
|
TextWithEntities PremiumRequiredBox::title() {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int PremiumRequiredBox::buttonSkip() {
|
int PremiumRequiredBox::buttonSkip() {
|
||||||
|
|
|
@ -66,29 +66,35 @@ QSize PremiumGift::size() {
|
||||||
st::msgServiceGiftBoxStickerSize);
|
st::msgServiceGiftBoxStickerSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PremiumGift::title() {
|
TextWithEntities PremiumGift::title() {
|
||||||
|
using namespace Ui::Text;
|
||||||
if (starGift()) {
|
if (starGift()) {
|
||||||
const auto peer = _parent->history()->peer;
|
const auto peer = _parent->history()->peer;
|
||||||
return peer->isSelf()
|
return peer->isSelf()
|
||||||
? tr::lng_action_gift_self_subtitle(tr::now)
|
? tr::lng_action_gift_self_subtitle(tr::now, WithEntities)
|
||||||
: peer->isServiceUser()
|
: peer->isServiceUser()
|
||||||
? tr::lng_gift_link_label_gift(tr::now)
|
? tr::lng_gift_link_label_gift(tr::now, WithEntities)
|
||||||
: (outgoingGift()
|
: (outgoingGift()
|
||||||
? tr::lng_action_gift_sent_subtitle
|
? tr::lng_action_gift_sent_subtitle
|
||||||
: tr::lng_action_gift_got_subtitle)(
|
: tr::lng_action_gift_got_subtitle)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_user,
|
lt_user,
|
||||||
peer->shortName());
|
WithEntities(peer->shortName()),
|
||||||
|
WithEntities);
|
||||||
} else if (creditsPrize()) {
|
} else if (creditsPrize()) {
|
||||||
return tr::lng_prize_title(tr::now);
|
return tr::lng_prize_title(tr::now, WithEntities);
|
||||||
} else if (const auto count = credits()) {
|
} else if (const auto c = credits()) {
|
||||||
return tr::lng_gift_stars_title(tr::now, lt_count, count);
|
return tr::lng_gift_stars_title(tr::now, lt_count, c, WithEntities);
|
||||||
}
|
}
|
||||||
return gift()
|
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
|
: _data.unclaimed
|
||||||
? tr::lng_prize_unclaimed_title(tr::now)
|
? tr::lng_prize_unclaimed_title(tr::now, WithEntities)
|
||||||
: tr::lng_prize_title(tr::now);
|
: tr::lng_prize_title(tr::now, WithEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities PremiumGift::subtitle() {
|
TextWithEntities PremiumGift::subtitle() {
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
int top() override;
|
int top() override;
|
||||||
int width() override;
|
int width() override;
|
||||||
QSize size() override;
|
QSize size() override;
|
||||||
QString title() override;
|
TextWithEntities title() override;
|
||||||
TextWithEntities subtitle() override;
|
TextWithEntities subtitle() override;
|
||||||
rpl::producer<QString> button() override;
|
rpl::producer<QString> button() override;
|
||||||
bool buttonMinistars() override;
|
bool buttonMinistars() override;
|
||||||
|
|
|
@ -45,8 +45,12 @@ ServiceBox::ServiceBox(
|
||||||
, _title(
|
, _title(
|
||||||
st::defaultSubsectionTitle.style,
|
st::defaultSubsectionTitle.style,
|
||||||
_content->title(),
|
_content->title(),
|
||||||
kDefaultTextOptions,
|
kMarkupTextOptions,
|
||||||
_maxWidth)
|
_maxWidth,
|
||||||
|
Core::MarkedTextContext{
|
||||||
|
.session = &parent->history()->session(),
|
||||||
|
.customEmojiRepaint = [parent] { parent->customEmojiRepaint(); },
|
||||||
|
})
|
||||||
, _subtitle(
|
, _subtitle(
|
||||||
st::premiumPreviewAbout.style,
|
st::premiumPreviewAbout.style,
|
||||||
Ui::Text::Filtered(
|
Ui::Text::Filtered(
|
||||||
|
@ -148,7 +152,16 @@ void ServiceBox::draw(Painter &p, const PaintContext &context) const {
|
||||||
const auto &padding = st::msgServiceGiftBoxTitlePadding;
|
const auto &padding = st::msgServiceGiftBoxTitlePadding;
|
||||||
top += padding.top();
|
top += padding.top();
|
||||||
if (!_title.isEmpty()) {
|
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();
|
top += _title.countHeight(_maxWidth) + padding.bottom();
|
||||||
}
|
}
|
||||||
_parent->prepareCustomEmojiPaint(p, context, _subtitle);
|
_parent->prepareCustomEmojiPaint(p, context, _subtitle);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
[[nodiscard]] virtual int width();
|
[[nodiscard]] virtual int width();
|
||||||
[[nodiscard]] virtual int top() = 0;
|
[[nodiscard]] virtual int top() = 0;
|
||||||
[[nodiscard]] virtual QSize size() = 0;
|
[[nodiscard]] virtual QSize size() = 0;
|
||||||
[[nodiscard]] virtual QString title() = 0;
|
[[nodiscard]] virtual TextWithEntities title() = 0;
|
||||||
[[nodiscard]] virtual TextWithEntities subtitle() = 0;
|
[[nodiscard]] virtual TextWithEntities subtitle() = 0;
|
||||||
[[nodiscard]] virtual int buttonSkip() {
|
[[nodiscard]] virtual int buttonSkip() {
|
||||||
return top();
|
return top();
|
||||||
|
|
|
@ -68,8 +68,8 @@ QSize StoryMention::size() {
|
||||||
return { st::msgServicePhotoWidth, st::msgServicePhotoWidth };
|
return { st::msgServicePhotoWidth, st::msgServicePhotoWidth };
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StoryMention::title() {
|
TextWithEntities StoryMention::title() {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int StoryMention::buttonSkip() {
|
int StoryMention::buttonSkip() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
int top() override;
|
int top() override;
|
||||||
QSize size() override;
|
QSize size() override;
|
||||||
QString title() override;
|
TextWithEntities title() override;
|
||||||
TextWithEntities subtitle() override;
|
TextWithEntities subtitle() override;
|
||||||
int buttonSkip() override;
|
int buttonSkip() override;
|
||||||
rpl::producer<QString> button() override;
|
rpl::producer<QString> button() override;
|
||||||
|
|
|
@ -509,8 +509,8 @@ QSize ThemeDocumentBox::size() {
|
||||||
: QSize(st::msgServicePhotoWidth, st::msgServicePhotoWidth);
|
: QSize(st::msgServicePhotoWidth, st::msgServicePhotoWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ThemeDocumentBox::title() {
|
TextWithEntities ThemeDocumentBox::title() {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities ThemeDocumentBox::subtitle() {
|
TextWithEntities ThemeDocumentBox::subtitle() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
|
|
||||||
int top() override;
|
int top() override;
|
||||||
QSize size() override;
|
QSize size() override;
|
||||||
QString title() override;
|
TextWithEntities title() override;
|
||||||
TextWithEntities subtitle() override;
|
TextWithEntities subtitle() override;
|
||||||
rpl::producer<QString> button() override;
|
rpl::producer<QString> button() override;
|
||||||
void draw(
|
void draw(
|
||||||
|
|
|
@ -197,8 +197,8 @@ QSize UserpicSuggestion::size() {
|
||||||
return { _photo.maxWidth(), _photo.minHeight() };
|
return { _photo.maxWidth(), _photo.minHeight() };
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserpicSuggestion::title() {
|
TextWithEntities UserpicSuggestion::title() {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> UserpicSuggestion::button() {
|
rpl::producer<QString> UserpicSuggestion::button() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
int top() override;
|
int top() override;
|
||||||
QSize size() override;
|
QSize size() override;
|
||||||
QString title() override;
|
TextWithEntities title() override;
|
||||||
TextWithEntities subtitle() override;
|
TextWithEntities subtitle() override;
|
||||||
rpl::producer<QString> button() override;
|
rpl::producer<QString> button() override;
|
||||||
void draw(
|
void draw(
|
||||||
|
|
Loading…
Add table
Reference in a new issue