diff --git a/ui/widgets/input_fields.cpp b/ui/widgets/input_fields.cpp index 7654d7a..ed7df91 100644 --- a/ui/widgets/input_fields.cpp +++ b/ui/widgets/input_fields.cpp @@ -822,8 +822,12 @@ void ApplyTagFormat(QTextCharFormat &to, const QTextCharFormat &from) { } to.setProperty(kReplaceTagId, from.property(kReplaceTagId)); to.setFont(from.font()); - to.setForeground(from.foreground()); - to.setBackground(from.background()); + if (from.hasProperty(QTextFormat::ForegroundBrush)) { + 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. @@ -1012,6 +1016,7 @@ void InsertEmojiAtCursor(QTextCursor cursor, EmojiPtr emoji) { } void InsertCustomEmojiAtCursor( + not_null field, QTextCursor cursor, const QString &text, const QString &link) { @@ -1023,6 +1028,9 @@ void InsertCustomEmojiAtCursor( format.setProperty(kCustomEmojiLink, unique); format.setProperty(kCustomEmojiId, CustomEmojiIdFromLink(link)); format.setVerticalAlignment(QTextCharFormat::AlignBottom); + format.setFont(field->st().font); + format.setForeground(field->st().textFg); + format.setBackground(QBrush()); ApplyTagFormat(format, currentFormat); format.setProperty(kTagProperty, TextUtilities::TagWithAdded( format.property(kTagProperty).toString(), @@ -2239,6 +2247,7 @@ void InputField::processFormatting(int insertPosition, int insertEnd) { InsertEmojiAtCursor(cursor, action.emoji); } else { InsertCustomEmojiAtCursor( + this, cursor, action.customEmojiText, action.customEmojiLink); diff --git a/ui/widgets/input_fields.h b/ui/widgets/input_fields.h index 1c592d8..8d7de73 100644 --- a/ui/widgets/input_fields.h +++ b/ui/widgets/input_fields.h @@ -37,9 +37,11 @@ const auto kEditLinkSequence = QKeySequence("ctrl+k"); const auto kSpoilerSequence = QKeySequence("ctrl+shift+p"); class PopupMenu; +class InputField; void InsertEmojiAtCursor(QTextCursor cursor, EmojiPtr emoji); void InsertCustomEmojiAtCursor( + not_null field, QTextCursor cursor, const QString &text, const QString &link); @@ -152,6 +154,10 @@ public: rpl::producer placeholder = nullptr, const TextWithTags &value = TextWithTags()); + [[nodiscard]] const style::InputField &st() const { + return _st; + } + void showError(); void showErrorNoFocus(); void hideError();