Skip to content

Commit

Permalink
fix: [inline chat] The chat view display is abnormal
Browse files Browse the repository at this point in the history
The chat view display is abnormal due to the pre-input status

Log: fix bug
Bug: https://pms.uniontech.com/bug-view-282523.html
  • Loading branch information
Kakueeen authored and deepin-mozart committed Nov 7, 2024
1 parent f636ee2 commit 33c9ac8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/codegeex/widgets/inlinechatwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class InlineChatWidgetPrivate : public QObject
int deleteMarker { -1 };
int insertMarker { -1 };
int selectionMarker { -1 };
bool isPreinputStatus { false };
};

InlineChatWidgetPrivate::InlineChatWidgetPrivate(InlineChatWidget *qq)
Expand Down Expand Up @@ -315,6 +316,12 @@ void InlineChatWidgetPrivate::setState(State s)

void InlineChatWidgetPrivate::handleTextChanged()
{
// Preinput status is not a real user input
if (isPreinputStatus) {
isPreinputStatus = false;
return;
}

const auto &text = edit->toPlainText();
questionLabel->setEnabled(text.isEmpty());
answerLabel->setEnabled(text.isEmpty());
Expand Down Expand Up @@ -865,6 +872,9 @@ bool InlineChatWidget::eventFilter(QObject *obj, QEvent *e)
}
} else if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut) {
d->updateButtonIcon();
} else if (e->type() == QEvent::InputMethod) {
auto imEvent = static_cast<QInputMethodEvent *>(e);
d->isPreinputStatus = imEvent->commitString().isEmpty();
}

return QWidget::eventFilter(obj, e);
Expand Down

0 comments on commit 33c9ac8

Please sign in to comment.