Optimize custom emoji repaints in the InputField.
This commit is contained in:
parent
9cb7bb58f6
commit
ec76a4c0bb
2 changed files with 20 additions and 1 deletions
|
|
@ -963,6 +963,9 @@ protected:
|
||||||
void inputMethodEvent(QInputMethodEvent *e) override {
|
void inputMethodEvent(QInputMethodEvent *e) override {
|
||||||
return outer()->inputMethodEventInner(e);
|
return outer()->inputMethodEventInner(e);
|
||||||
}
|
}
|
||||||
|
void paintEvent(QPaintEvent *e) override {
|
||||||
|
return outer()->paintEventInner(e);
|
||||||
|
}
|
||||||
|
|
||||||
bool canInsertFromMimeData(const QMimeData *source) const override {
|
bool canInsertFromMimeData(const QMimeData *source) const override {
|
||||||
return outer()->canInsertFromMimeDataInner(source);
|
return outer()->canInsertFromMimeDataInner(source);
|
||||||
|
|
@ -1664,13 +1667,26 @@ void InputField::setCustomEmojiFactory(
|
||||||
Fn<bool()> paused) {
|
Fn<bool()> paused) {
|
||||||
_customEmojiObject = std::make_unique<CustomEmojiObject>([=](
|
_customEmojiObject = std::make_unique<CustomEmojiObject>([=](
|
||||||
QStringView data) {
|
QStringView data) {
|
||||||
return factory(data, [=] { _inner->update(); });
|
return factory(data, [=] { customEmojiRepaint(); });
|
||||||
}, std::move(paused));
|
}, std::move(paused));
|
||||||
_inner->document()->documentLayout()->registerHandler(
|
_inner->document()->documentLayout()->registerHandler(
|
||||||
kCustomEmojiFormat,
|
kCustomEmojiFormat,
|
||||||
_customEmojiObject.get());
|
_customEmojiObject.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputField::customEmojiRepaint() {
|
||||||
|
if (_customEmojiRepaintScheduled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_customEmojiRepaintScheduled = true;
|
||||||
|
_inner->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputField::paintEventInner(QPaintEvent *e) {
|
||||||
|
_customEmojiRepaintScheduled = false;
|
||||||
|
_inner->QTextEdit::paintEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
void InputField::setAdditionalMargin(int margin) {
|
void InputField::setAdditionalMargin(int margin) {
|
||||||
_additionalMargin = margin;
|
_additionalMargin = margin;
|
||||||
QResizeEvent e(size(), size());
|
QResizeEvent e(size(), size());
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,7 @@ private:
|
||||||
void contextMenuEventInner(QContextMenuEvent *e, QMenu *m = nullptr);
|
void contextMenuEventInner(QContextMenuEvent *e, QMenu *m = nullptr);
|
||||||
void dropEventInner(QDropEvent *e);
|
void dropEventInner(QDropEvent *e);
|
||||||
void inputMethodEventInner(QInputMethodEvent *e);
|
void inputMethodEventInner(QInputMethodEvent *e);
|
||||||
|
void paintEventInner(QPaintEvent *e);
|
||||||
|
|
||||||
QMimeData *createMimeDataFromSelectionInner() const;
|
QMimeData *createMimeDataFromSelectionInner() const;
|
||||||
bool canInsertFromMimeDataInner(const QMimeData *source) const;
|
bool canInsertFromMimeDataInner(const QMimeData *source) const;
|
||||||
|
|
@ -513,6 +514,7 @@ private:
|
||||||
|
|
||||||
bool revertFormatReplace();
|
bool revertFormatReplace();
|
||||||
|
|
||||||
|
void customEmojiRepaint();
|
||||||
void highlightMarkdown();
|
void highlightMarkdown();
|
||||||
|
|
||||||
const style::InputField &_st;
|
const style::InputField &_st;
|
||||||
|
|
@ -536,6 +538,7 @@ private:
|
||||||
|
|
||||||
bool _forcePlaceholderHidden = false;
|
bool _forcePlaceholderHidden = false;
|
||||||
bool _reverseMarkdownReplacement = false;
|
bool _reverseMarkdownReplacement = false;
|
||||||
|
bool _customEmojiRepaintScheduled = false;
|
||||||
|
|
||||||
// Tags list which we should apply while setText() call or insert from mime data.
|
// Tags list which we should apply while setText() call or insert from mime data.
|
||||||
TagList _insertedTags;
|
TagList _insertedTags;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue