mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Replaced credits currency with icon in buttons of reply keyboard.
This commit is contained in:
parent
273119fc55
commit
7e01b12825
1 changed files with 41 additions and 6 deletions
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/effects/spoiler_mess.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
|
@ -48,9 +49,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_session.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "api/api_bot.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_dialogs.h" // dialogsMiniReplyStory.
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
|
@ -679,6 +682,11 @@ ReplyKeyboard::ReplyKeyboard(
|
|||
const auto context = _item->fullId();
|
||||
const auto rowCount = int(markup->data.rows.size());
|
||||
_rows.reserve(rowCount);
|
||||
const auto buttonEmoji = Ui::Text::SingleCustomEmoji(
|
||||
owner->customEmojiManager().registerInternalEmoji(
|
||||
st::settingsPremiumIconStar,
|
||||
QMargins(0, -st::moderateBoxExpandInnerSkip, 0, 0),
|
||||
true));
|
||||
for (auto i = 0; i != rowCount; ++i) {
|
||||
const auto &row = markup->data.rows[i];
|
||||
const auto rowSize = int(row.size());
|
||||
|
@ -686,17 +694,44 @@ ReplyKeyboard::ReplyKeyboard(
|
|||
newRow.reserve(rowSize);
|
||||
for (auto j = 0; j != rowSize; ++j) {
|
||||
auto button = Button();
|
||||
const auto text = row[j].text;
|
||||
const auto text = base::duplicate(row[j].text).replace(
|
||||
Ui::kCreditsCurrency,
|
||||
QChar(0x2B50));
|
||||
const auto textWithEntities = [&] {
|
||||
auto result = TextWithEntities();
|
||||
auto firstPart = true;
|
||||
for (const auto &part : text.split(QChar(0x2B50))) {
|
||||
if (!firstPart) {
|
||||
result.append(buttonEmoji);
|
||||
}
|
||||
result.append(part);
|
||||
firstPart = false;
|
||||
}
|
||||
return result.entities.empty()
|
||||
? TextWithEntities()
|
||||
: result;
|
||||
}();
|
||||
button.type = row.at(j).type;
|
||||
button.link = std::make_shared<ReplyMarkupClickHandler>(
|
||||
owner,
|
||||
i,
|
||||
j,
|
||||
context);
|
||||
button.text.setText(
|
||||
_st->textStyle(),
|
||||
TextUtilities::SingleLine(text),
|
||||
kPlainTextOptions);
|
||||
if (!textWithEntities.text.isEmpty()) {
|
||||
button.text.setMarkedText(
|
||||
_st->textStyle(),
|
||||
TextUtilities::SingleLine(textWithEntities),
|
||||
kMarkupTextOptions,
|
||||
Core::MarkedTextContext{
|
||||
.session = &item->history()->owner().session(),
|
||||
.customEmojiRepaint = [=] { _st->repaint(item); },
|
||||
});
|
||||
} else {
|
||||
button.text.setText(
|
||||
_st->textStyle(),
|
||||
TextUtilities::SingleLine(text),
|
||||
kPlainTextOptions);
|
||||
}
|
||||
button.characters = text.isEmpty() ? 1 : text.size();
|
||||
newRow.push_back(std::move(button));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue