mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced icon with custom emoji in list of credits history entries.
This commit is contained in:
parent
70d5dd8b71
commit
f2f85a9083
5 changed files with 30 additions and 49 deletions
|
@ -361,16 +361,12 @@ void InnerWidget::fillHistory() {
|
||||||
e));
|
e));
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto star = lifetime().make_state<QImage>(
|
|
||||||
Ui::GenerateStars(st::creditsTopupButton.height, 1));
|
|
||||||
|
|
||||||
Info::Statistics::AddCreditsHistoryList(
|
Info::Statistics::AddCreditsHistoryList(
|
||||||
controller->uiShow(),
|
controller->uiShow(),
|
||||||
fullSlice,
|
fullSlice,
|
||||||
fullWrap->entity(),
|
fullWrap->entity(),
|
||||||
entryClicked,
|
entryClicked,
|
||||||
peer,
|
peer,
|
||||||
star,
|
|
||||||
true,
|
true,
|
||||||
true);
|
true);
|
||||||
Info::Statistics::AddCreditsHistoryList(
|
Info::Statistics::AddCreditsHistoryList(
|
||||||
|
@ -379,7 +375,6 @@ void InnerWidget::fillHistory() {
|
||||||
inWrap->entity(),
|
inWrap->entity(),
|
||||||
entryClicked,
|
entryClicked,
|
||||||
peer,
|
peer,
|
||||||
star,
|
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
Info::Statistics::AddCreditsHistoryList(
|
Info::Statistics::AddCreditsHistoryList(
|
||||||
|
@ -388,7 +383,6 @@ void InnerWidget::fillHistory() {
|
||||||
outWrap->entity(),
|
outWrap->entity(),
|
||||||
std::move(entryClicked),
|
std::move(entryClicked),
|
||||||
peer,
|
peer,
|
||||||
star,
|
|
||||||
false,
|
false,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
|
|
@ -1412,16 +1412,12 @@ void InnerWidget::fill() {
|
||||||
e));
|
e));
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto star = tabCreditsList->lifetime().make_state<QImage>(
|
|
||||||
Ui::GenerateStars(st::creditsTopupButton.height, 1));
|
|
||||||
|
|
||||||
Info::Statistics::AddCreditsHistoryList(
|
Info::Statistics::AddCreditsHistoryList(
|
||||||
show,
|
show,
|
||||||
data.creditsStatusSlice,
|
data.creditsStatusSlice,
|
||||||
tabCreditsList->entity(),
|
tabCreditsList->entity(),
|
||||||
entryClicked,
|
entryClicked,
|
||||||
_peer,
|
_peer,
|
||||||
star,
|
|
||||||
true,
|
true,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,6 @@ struct CreditsDescriptor final {
|
||||||
Data::CreditsStatusSlice firstSlice;
|
Data::CreditsStatusSlice firstSlice;
|
||||||
Fn<void(const Data::CreditsHistoryEntry &)> entryClickedCallback;
|
Fn<void(const Data::CreditsHistoryEntry &)> entryClickedCallback;
|
||||||
not_null<PeerData*> peer;
|
not_null<PeerData*> peer;
|
||||||
not_null<QImage*> creditIcon;
|
|
||||||
bool in = false;
|
bool in = false;
|
||||||
bool out = false;
|
bool out = false;
|
||||||
};
|
};
|
||||||
|
@ -724,7 +723,7 @@ public:
|
||||||
struct Descriptor final {
|
struct Descriptor final {
|
||||||
Data::CreditsHistoryEntry entry;
|
Data::CreditsHistoryEntry entry;
|
||||||
Data::SubscriptionEntry subscription;
|
Data::SubscriptionEntry subscription;
|
||||||
not_null<QImage*> creditIcon;
|
Core::MarkedTextContext context;
|
||||||
int rowHeight = 0;
|
int rowHeight = 0;
|
||||||
Fn<void(not_null<PeerListRow*>)> updateCallback;
|
Fn<void(not_null<PeerListRow*>)> updateCallback;
|
||||||
};
|
};
|
||||||
|
@ -755,7 +754,7 @@ private:
|
||||||
|
|
||||||
const Data::CreditsHistoryEntry _entry;
|
const Data::CreditsHistoryEntry _entry;
|
||||||
const Data::SubscriptionEntry _subscription;
|
const Data::SubscriptionEntry _subscription;
|
||||||
not_null<QImage*> const _creditIcon;
|
const Core::MarkedTextContext _context;
|
||||||
const int _rowHeight;
|
const int _rowHeight;
|
||||||
|
|
||||||
PaintRoundImageCallback _paintUserpicCallback;
|
PaintRoundImageCallback _paintUserpicCallback;
|
||||||
|
@ -773,7 +772,7 @@ CreditsRow::CreditsRow(
|
||||||
: PeerListRow(peer, UniqueRowIdFromEntry(descriptor.entry))
|
: PeerListRow(peer, UniqueRowIdFromEntry(descriptor.entry))
|
||||||
, _entry(descriptor.entry)
|
, _entry(descriptor.entry)
|
||||||
, _subscription(descriptor.subscription)
|
, _subscription(descriptor.subscription)
|
||||||
, _creditIcon(descriptor.creditIcon)
|
, _context(descriptor.context)
|
||||||
, _rowHeight(descriptor.rowHeight) {
|
, _rowHeight(descriptor.rowHeight) {
|
||||||
const auto callback = Ui::PaintPreviewCallback(
|
const auto callback = Ui::PaintPreviewCallback(
|
||||||
&peer->session(),
|
&peer->session(),
|
||||||
|
@ -790,7 +789,7 @@ CreditsRow::CreditsRow(const Descriptor &descriptor)
|
||||||
: PeerListRow(UniqueRowIdFromEntry(descriptor.entry))
|
: PeerListRow(UniqueRowIdFromEntry(descriptor.entry))
|
||||||
, _entry(descriptor.entry)
|
, _entry(descriptor.entry)
|
||||||
, _subscription(descriptor.subscription)
|
, _subscription(descriptor.subscription)
|
||||||
, _creditIcon(descriptor.creditIcon)
|
, _context(descriptor.context)
|
||||||
, _rowHeight(descriptor.rowHeight) {
|
, _rowHeight(descriptor.rowHeight) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -831,23 +830,27 @@ void CreditsRow::init() {
|
||||||
lt_date,
|
lt_date,
|
||||||
langDayOfMonthFull(_subscription.until.date())));
|
langDayOfMonthFull(_subscription.until.date())));
|
||||||
}
|
}
|
||||||
|
auto &manager = _context.session->data().customEmojiManager();
|
||||||
if (_entry) {
|
if (_entry) {
|
||||||
constexpr auto kMinus = QChar(0x2212);
|
constexpr auto kMinus = QChar(0x2212);
|
||||||
_rightText.setText(
|
_rightText.setMarkedText(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
(_entry.in ? QChar('+') : kMinus)
|
TextWithEntities()
|
||||||
+ Lang::FormatCountDecimal(std::abs(int64(_entry.credits))));
|
.append(_entry.in ? QChar('+') : kMinus)
|
||||||
|
.append(
|
||||||
|
Lang::FormatCountDecimal(std::abs(int64(_entry.credits))))
|
||||||
|
.append(QChar(' '))
|
||||||
|
.append(manager.creditsEmoji()),
|
||||||
|
kMarkupTextOptions,
|
||||||
|
_context);
|
||||||
} else if (_subscription.subscription.credits && !isSpecial) {
|
} else if (_subscription.subscription.credits && !isSpecial) {
|
||||||
const auto peer = PeerListRow::peer();
|
const auto peer = PeerListRow::peer();
|
||||||
_rightText.setMarkedText(
|
_rightText.setMarkedText(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
peer->owner().customEmojiManager().creditsEmoji().append(
|
manager.creditsEmoji().append(
|
||||||
Lang::FormatCountDecimal(_subscription.subscription.credits)),
|
Lang::FormatCountDecimal(_subscription.subscription.credits)),
|
||||||
kMarkupTextOptions,
|
kMarkupTextOptions,
|
||||||
Core::MarkedTextContext{
|
_context);
|
||||||
.session = &peer->session(),
|
|
||||||
.customEmojiRepaint = [] {},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (!_paintUserpicCallback) {
|
if (!_paintUserpicCallback) {
|
||||||
_paintUserpicCallback = !isSpecial
|
_paintUserpicCallback = !isSpecial
|
||||||
|
@ -880,19 +883,14 @@ QSize CreditsRow::rightActionSize() const {
|
||||||
return QSize(
|
return QSize(
|
||||||
st::contactsStatusFont->width(text) + st::boxRowPadding.right(),
|
st::contactsStatusFont->width(text) + st::boxRowPadding.right(),
|
||||||
_rowHeight);
|
_rowHeight);
|
||||||
} else if (_subscription) {
|
} else if (_subscription || _entry) {
|
||||||
return QSize(
|
return QSize(
|
||||||
_rightText.maxWidth() + st::boxRowPadding.right(),
|
_rightText.maxWidth() + st::boxRowPadding.right(),
|
||||||
_rowHeight);
|
_rowHeight);
|
||||||
} else if (!_entry && !_subscription) {
|
} else if (!_entry && !_subscription) {
|
||||||
return QSize();
|
return QSize();
|
||||||
}
|
}
|
||||||
return QSize(
|
return QSize();
|
||||||
_rightText.maxWidth()
|
|
||||||
+ (_creditIcon->width() / style::DevicePixelRatio())
|
|
||||||
+ st::creditsHistoryRightSkip
|
|
||||||
+ _rightText.style()->font->spacew * 2,
|
|
||||||
_rowHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMargins CreditsRow::rightActionMargins() const {
|
QMargins CreditsRow::rightActionMargins() const {
|
||||||
|
@ -911,12 +909,12 @@ void CreditsRow::rightActionPaint(
|
||||||
bool selected,
|
bool selected,
|
||||||
bool actionSelected) {
|
bool actionSelected) {
|
||||||
const auto &font = _rightText.style()->font;
|
const auto &font = _rightText.style()->font;
|
||||||
|
const auto rightSkip = st::boxRowPadding.right();
|
||||||
if (_subscription) {
|
if (_subscription) {
|
||||||
const auto &statusFont = st::contactsStatusFont;
|
const auto &statusFont = st::contactsStatusFont;
|
||||||
const auto &st = st::boostsListBox.item;
|
const auto &st = st::boostsListBox.item;
|
||||||
const auto textHeight = font->height + statusFont->height;
|
const auto textHeight = font->height + statusFont->height;
|
||||||
const auto skip = (_rowHeight - textHeight) / 2;
|
const auto skip = (_rowHeight - textHeight) / 2;
|
||||||
const auto rightSkip = st::boxRowPadding.right();
|
|
||||||
if (_subscription.cancelled || _subscription.expired) {
|
if (_subscription.cancelled || _subscription.expired) {
|
||||||
y += _rowHeight / 2;
|
y += _rowHeight / 2;
|
||||||
p.setFont(statusFont);
|
p.setFont(statusFont);
|
||||||
|
@ -955,17 +953,13 @@ void CreditsRow::rightActionPaint(
|
||||||
: _entry.in
|
: _entry.in
|
||||||
? st::boxTextFgGood
|
? st::boxTextFgGood
|
||||||
: st::menuIconAttentionColor);
|
: st::menuIconAttentionColor);
|
||||||
x += st::creditsHistoryRightSkip;
|
|
||||||
_rightText.draw(p, Ui::Text::PaintContext{
|
_rightText.draw(p, Ui::Text::PaintContext{
|
||||||
.position = QPoint(x, y - font->height / 2),
|
.position = QPoint(
|
||||||
|
outerWidth - _rightText.maxWidth() - rightSkip,
|
||||||
|
y - font->height / 2),
|
||||||
.outerWidth = outerWidth,
|
.outerWidth = outerWidth,
|
||||||
.availableWidth = outerWidth,
|
.availableWidth = outerWidth,
|
||||||
});
|
});
|
||||||
x += _rightText.maxWidth() + font->spacew * 2;
|
|
||||||
p.drawImage(
|
|
||||||
x,
|
|
||||||
y -(_creditIcon->height() / style::DevicePixelRatio()) / 2,
|
|
||||||
*_creditIcon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreditsController final : public PeerListController {
|
class CreditsController final : public PeerListController {
|
||||||
|
@ -987,11 +981,11 @@ private:
|
||||||
|
|
||||||
const not_null<Main::Session*> _session;
|
const not_null<Main::Session*> _session;
|
||||||
Fn<void(const Data::CreditsHistoryEntry &)> _entryClickedCallback;
|
Fn<void(const Data::CreditsHistoryEntry &)> _entryClickedCallback;
|
||||||
not_null<QImage*> const _creditIcon;
|
|
||||||
|
|
||||||
Api::CreditsHistory _api;
|
Api::CreditsHistory _api;
|
||||||
Data::CreditsStatusSlice _firstSlice;
|
Data::CreditsStatusSlice _firstSlice;
|
||||||
Data::CreditsStatusSlice::OffsetToken _apiToken;
|
Data::CreditsStatusSlice::OffsetToken _apiToken;
|
||||||
|
Core::MarkedTextContext _context;
|
||||||
|
|
||||||
rpl::variable<bool> _allLoaded = false;
|
rpl::variable<bool> _allLoaded = false;
|
||||||
bool _requesting = false;
|
bool _requesting = false;
|
||||||
|
@ -1001,9 +995,12 @@ private:
|
||||||
CreditsController::CreditsController(CreditsDescriptor d)
|
CreditsController::CreditsController(CreditsDescriptor d)
|
||||||
: _session(&d.peer->session())
|
: _session(&d.peer->session())
|
||||||
, _entryClickedCallback(std::move(d.entryClickedCallback))
|
, _entryClickedCallback(std::move(d.entryClickedCallback))
|
||||||
, _creditIcon(d.creditIcon)
|
|
||||||
, _api(d.peer, d.in, d.out)
|
, _api(d.peer, d.in, d.out)
|
||||||
, _firstSlice(std::move(d.firstSlice)) {
|
, _firstSlice(std::move(d.firstSlice))
|
||||||
|
, _context(Core::MarkedTextContext{
|
||||||
|
.session = _session,
|
||||||
|
.customEmojiRepaint = [] {},
|
||||||
|
}) {
|
||||||
PeerListController::setStyleOverrides(&st::boostsListBox);
|
PeerListController::setStyleOverrides(&st::boostsListBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,7 +1042,7 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) {
|
||||||
const auto descriptor = CreditsRow::Descriptor{
|
const auto descriptor = CreditsRow::Descriptor{
|
||||||
.entry = i,
|
.entry = i,
|
||||||
.subscription = s,
|
.subscription = s,
|
||||||
.creditIcon = _creditIcon,
|
.context = _context,
|
||||||
.rowHeight = computeListSt().item.height,
|
.rowHeight = computeListSt().item.height,
|
||||||
.updateCallback = [=](not_null<PeerListRow*> row) {
|
.updateCallback = [=](not_null<PeerListRow*> row) {
|
||||||
delegate()->peerListUpdateRow(row);
|
delegate()->peerListUpdateRow(row);
|
||||||
|
@ -1235,7 +1232,6 @@ void AddCreditsHistoryList(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
Fn<void(const Data::CreditsHistoryEntry &)> callback,
|
Fn<void(const Data::CreditsHistoryEntry &)> callback,
|
||||||
not_null<PeerData*> bot,
|
not_null<PeerData*> bot,
|
||||||
not_null<QImage*> icon,
|
|
||||||
bool in,
|
bool in,
|
||||||
bool out) {
|
bool out) {
|
||||||
struct State final {
|
struct State final {
|
||||||
|
@ -1249,7 +1245,7 @@ void AddCreditsHistoryList(
|
||||||
CreditsController controller;
|
CreditsController controller;
|
||||||
};
|
};
|
||||||
const auto state = container->lifetime().make_state<State>(
|
const auto state = container->lifetime().make_state<State>(
|
||||||
CreditsDescriptor{ firstSlice, callback, bot, icon, in, out },
|
CreditsDescriptor{ firstSlice, callback, bot, in, out },
|
||||||
show);
|
show);
|
||||||
|
|
||||||
state->delegate.setContent(container->add(
|
state->delegate.setContent(container->add(
|
||||||
|
|
|
@ -56,7 +56,6 @@ void AddCreditsHistoryList(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
Fn<void(const Data::CreditsHistoryEntry &)> entryClickedCallback,
|
Fn<void(const Data::CreditsHistoryEntry &)> entryClickedCallback,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
not_null<QImage*> creditIcon,
|
|
||||||
bool in,
|
bool in,
|
||||||
bool out);
|
bool out);
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,6 @@ void Credits::setupSubscriptions(not_null<Ui::VerticalLayout*> container) {
|
||||||
fullWrap->entity(),
|
fullWrap->entity(),
|
||||||
entryClicked,
|
entryClicked,
|
||||||
self,
|
self,
|
||||||
&_star,
|
|
||||||
true,
|
true,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
@ -296,7 +295,6 @@ void Credits::setupHistory(not_null<Ui::VerticalLayout*> container) {
|
||||||
fullWrap->entity(),
|
fullWrap->entity(),
|
||||||
entryClicked,
|
entryClicked,
|
||||||
self,
|
self,
|
||||||
&_star,
|
|
||||||
true,
|
true,
|
||||||
true);
|
true);
|
||||||
Info::Statistics::AddCreditsHistoryList(
|
Info::Statistics::AddCreditsHistoryList(
|
||||||
|
@ -305,7 +303,6 @@ void Credits::setupHistory(not_null<Ui::VerticalLayout*> container) {
|
||||||
inWrap->entity(),
|
inWrap->entity(),
|
||||||
entryClicked,
|
entryClicked,
|
||||||
self,
|
self,
|
||||||
&_star,
|
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
Info::Statistics::AddCreditsHistoryList(
|
Info::Statistics::AddCreditsHistoryList(
|
||||||
|
@ -314,7 +311,6 @@ void Credits::setupHistory(not_null<Ui::VerticalLayout*> container) {
|
||||||
outWrap->entity(),
|
outWrap->entity(),
|
||||||
std::move(entryClicked),
|
std::move(entryClicked),
|
||||||
self,
|
self,
|
||||||
&_star,
|
|
||||||
false,
|
false,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue