From 9c01bbca95858cb9af6ee24a0f97f6ab7ef4c841 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 5 Nov 2017 21:40:16 +0400 Subject: [PATCH] Fix invoice amount display. --- .../history/history_media_types.cpp | 18 +++++++++++++----- .../SourceFiles/history/history_media_types.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index c98e337469..a3aa3e1b91 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -4225,14 +4225,20 @@ int HistoryGame::bottomInfoPadding() const { return result; } -HistoryInvoice::HistoryInvoice(not_null parent, const MTPDmessageMediaInvoice &data) : HistoryMedia(parent) +HistoryInvoice::HistoryInvoice( + not_null parent, + const MTPDmessageMediaInvoice &data) +: HistoryMedia(parent) , _title(st::msgMinWidth) , _description(st::msgMinWidth) , _status(st::msgMinWidth) { fillFromData(data); } -HistoryInvoice::HistoryInvoice(not_null parent, const HistoryInvoice &other) : HistoryMedia(parent) +HistoryInvoice::HistoryInvoice( + not_null parent, + const HistoryInvoice &other) +: HistoryMedia(parent) , _attach(other._attach ? other._attach->clone(parent) : nullptr) , _titleHeight(other._titleHeight) , _descriptionHeight(other._descriptionHeight) @@ -4241,7 +4247,7 @@ HistoryInvoice::HistoryInvoice(not_null parent, const HistoryInvoi , _status(other._status) { } -QString HistoryInvoice::fillAmountAndCurrency(int amount, const QString ¤cy) { +QString HistoryInvoice::fillAmountAndCurrency(uint64 amount, const QString ¤cy) { static auto shortCurrencyNames = QMap { { qsl("USD"), QString::fromUtf8("\x24") }, { qsl("GBP"), QString::fromUtf8("\xC2\xA3") }, @@ -4285,7 +4291,6 @@ void HistoryInvoice::fillFromData(const MTPDmessageMediaInvoice &data) { _attach = std::make_unique(_parent, photo, QString()); } } - auto labelText = [&data] { if (data.has_receipt_msg_id()) { if (data.is_test()) { @@ -4297,7 +4302,10 @@ void HistoryInvoice::fillFromData(const MTPDmessageMediaInvoice &data) { } return lang(lng_payments_invoice_label); }; - auto statusText = TextWithEntities { fillAmountAndCurrency(data.vtotal_amount.v, qs(data.vcurrency)), EntitiesInText() }; + auto statusText = TextWithEntities { + fillAmountAndCurrency(data.vtotal_amount.v, qs(data.vcurrency)), + EntitiesInText() + }; statusText.entities.push_back(EntityInText(EntityInTextBold, 0, statusText.text.size())); statusText.text += ' ' + labelText().toUpper(); _status.setMarkedText(st::defaultTextStyle, statusText, itemTextOptions(_parent)); diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index a7d33a5c19..4f697e8766 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -1023,7 +1023,7 @@ public: QString getTitle() const { return _title.originalText(); } - static QString fillAmountAndCurrency(int amount, const QString ¤cy); + static QString fillAmountAndCurrency(uint64 amount, const QString ¤cy); void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;