Fix colored custom emoji in field.
This commit is contained in:
parent
770b5d0e59
commit
4befce5a29
2 changed files with 17 additions and 2 deletions
|
|
@ -822,8 +822,12 @@ void ApplyTagFormat(QTextCharFormat &to, const QTextCharFormat &from) {
|
||||||
}
|
}
|
||||||
to.setProperty(kReplaceTagId, from.property(kReplaceTagId));
|
to.setProperty(kReplaceTagId, from.property(kReplaceTagId));
|
||||||
to.setFont(from.font());
|
to.setFont(from.font());
|
||||||
to.setForeground(from.foreground());
|
if (from.hasProperty(QTextFormat::ForegroundBrush)) {
|
||||||
to.setBackground(from.background());
|
to.setForeground(from.brushProperty(QTextFormat::ForegroundBrush));
|
||||||
|
}
|
||||||
|
if (from.hasProperty(QTextFormat::BackgroundBrush)) {
|
||||||
|
to.setBackground(from.brushProperty(QTextFormat::BackgroundBrush));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the position of the first inserted tag or "changedEnd" value if none found.
|
// Returns the position of the first inserted tag or "changedEnd" value if none found.
|
||||||
|
|
@ -1012,6 +1016,7 @@ void InsertEmojiAtCursor(QTextCursor cursor, EmojiPtr emoji) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertCustomEmojiAtCursor(
|
void InsertCustomEmojiAtCursor(
|
||||||
|
not_null<InputField*> field,
|
||||||
QTextCursor cursor,
|
QTextCursor cursor,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QString &link) {
|
const QString &link) {
|
||||||
|
|
@ -1023,6 +1028,9 @@ void InsertCustomEmojiAtCursor(
|
||||||
format.setProperty(kCustomEmojiLink, unique);
|
format.setProperty(kCustomEmojiLink, unique);
|
||||||
format.setProperty(kCustomEmojiId, CustomEmojiIdFromLink(link));
|
format.setProperty(kCustomEmojiId, CustomEmojiIdFromLink(link));
|
||||||
format.setVerticalAlignment(QTextCharFormat::AlignBottom);
|
format.setVerticalAlignment(QTextCharFormat::AlignBottom);
|
||||||
|
format.setFont(field->st().font);
|
||||||
|
format.setForeground(field->st().textFg);
|
||||||
|
format.setBackground(QBrush());
|
||||||
ApplyTagFormat(format, currentFormat);
|
ApplyTagFormat(format, currentFormat);
|
||||||
format.setProperty(kTagProperty, TextUtilities::TagWithAdded(
|
format.setProperty(kTagProperty, TextUtilities::TagWithAdded(
|
||||||
format.property(kTagProperty).toString(),
|
format.property(kTagProperty).toString(),
|
||||||
|
|
@ -2239,6 +2247,7 @@ void InputField::processFormatting(int insertPosition, int insertEnd) {
|
||||||
InsertEmojiAtCursor(cursor, action.emoji);
|
InsertEmojiAtCursor(cursor, action.emoji);
|
||||||
} else {
|
} else {
|
||||||
InsertCustomEmojiAtCursor(
|
InsertCustomEmojiAtCursor(
|
||||||
|
this,
|
||||||
cursor,
|
cursor,
|
||||||
action.customEmojiText,
|
action.customEmojiText,
|
||||||
action.customEmojiLink);
|
action.customEmojiLink);
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@ const auto kEditLinkSequence = QKeySequence("ctrl+k");
|
||||||
const auto kSpoilerSequence = QKeySequence("ctrl+shift+p");
|
const auto kSpoilerSequence = QKeySequence("ctrl+shift+p");
|
||||||
|
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
|
class InputField;
|
||||||
|
|
||||||
void InsertEmojiAtCursor(QTextCursor cursor, EmojiPtr emoji);
|
void InsertEmojiAtCursor(QTextCursor cursor, EmojiPtr emoji);
|
||||||
void InsertCustomEmojiAtCursor(
|
void InsertCustomEmojiAtCursor(
|
||||||
|
not_null<InputField*> field,
|
||||||
QTextCursor cursor,
|
QTextCursor cursor,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QString &link);
|
const QString &link);
|
||||||
|
|
@ -152,6 +154,10 @@ public:
|
||||||
rpl::producer<QString> placeholder = nullptr,
|
rpl::producer<QString> placeholder = nullptr,
|
||||||
const TextWithTags &value = TextWithTags());
|
const TextWithTags &value = TextWithTags());
|
||||||
|
|
||||||
|
[[nodiscard]] const style::InputField &st() const {
|
||||||
|
return _st;
|
||||||
|
}
|
||||||
|
|
||||||
void showError();
|
void showError();
|
||||||
void showErrorNoFocus();
|
void showErrorNoFocus();
|
||||||
void hideError();
|
void hideError();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue