Prevent escape key from being captured.
This commit is contained in:
parent
477adc81ac
commit
094d820882
@ -131,6 +131,15 @@ void TransmitTextEdit::replaceUnsentText(const QString &text){
|
||||
c.insertText(text);
|
||||
}
|
||||
|
||||
//
|
||||
void TransmitTextEdit::replacePlainText(const QString &text){
|
||||
auto c = textCursor();
|
||||
c.movePosition(QTextCursor::Start);
|
||||
c.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
|
||||
c.removeSelectedText();
|
||||
c.insertText(text);
|
||||
}
|
||||
|
||||
//
|
||||
void TransmitTextEdit::setFont(QFont f){
|
||||
m_font = f;
|
||||
@ -351,7 +360,11 @@ bool TransmitTextEdit::eventFilter(QObject */*o*/, QEvent *e){
|
||||
return false;
|
||||
}
|
||||
|
||||
// -1. don't filter the escape key
|
||||
QKeyEvent *k = static_cast<QKeyEvent *>(e);
|
||||
if(k->key() == Qt::Key_Escape){
|
||||
return false;
|
||||
}
|
||||
|
||||
auto c = textCursor();
|
||||
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
QString toPlainText() const;
|
||||
void setPlainText(const QString &text);
|
||||
void replaceUnsentText(const QString &text);
|
||||
void replacePlainText(const QString &text);
|
||||
|
||||
void setFont(QFont f);
|
||||
void setFont(QFont f, QColor fg, QColor bg);
|
||||
|
@ -6354,15 +6354,28 @@ bool MainWindow::prepareNextMessageFrame()
|
||||
|
||||
// typeahead
|
||||
static QString lastText;
|
||||
if(lastText == "" || lastText != ui->extFreeTextMsgEdit->toPlainText()){
|
||||
auto text = ui->extFreeTextMsgEdit->toPlainText();
|
||||
if(lastText == "" || lastText != text){
|
||||
#if 1
|
||||
auto sent = ui->extFreeTextMsgEdit->sentText();
|
||||
auto unsent = ui->extFreeTextMsgEdit->unsentText();
|
||||
qDebug() << "text dirty for typeahead\n" << sent << "\n" << unsent;
|
||||
m_txFrameQueue.clear();
|
||||
m_txFrameCount = 0;
|
||||
auto newUnsent = appendMessage(unsent);
|
||||
ui->extFreeTextMsgEdit->replaceUnsentText(newUnsent);
|
||||
lastText = ui->extFreeTextMsgEdit->toPlainText();
|
||||
auto newText = appendMessage(unsent);
|
||||
ui->extFreeTextMsgEdit->replaceUnsentText(newText);
|
||||
#else
|
||||
m_txFrameQueue.clear();
|
||||
auto newText = appendMessage(text);
|
||||
for(int i = 0; i < m_txFrameCount; i++){
|
||||
if(m_txFrameQueue.isEmpty()){
|
||||
break;
|
||||
}
|
||||
m_txFrameQueue.removeFirst();
|
||||
}
|
||||
ui->extFreeTextMsgEdit->replacePlainText(newText);
|
||||
#endif
|
||||
lastText = text;
|
||||
}
|
||||
|
||||
QPair<QString, int> f = popMessageFrame();
|
||||
|
Loading…
Reference in New Issue
Block a user