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);
|
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){
|
void TransmitTextEdit::setFont(QFont f){
|
||||||
m_font = f;
|
m_font = f;
|
||||||
@ -351,7 +360,11 @@ bool TransmitTextEdit::eventFilter(QObject */*o*/, QEvent *e){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -1. don't filter the escape key
|
||||||
QKeyEvent *k = static_cast<QKeyEvent *>(e);
|
QKeyEvent *k = static_cast<QKeyEvent *>(e);
|
||||||
|
if(k->key() == Qt::Key_Escape){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto c = textCursor();
|
auto c = textCursor();
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
QString toPlainText() const;
|
QString toPlainText() const;
|
||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
void replaceUnsentText(const QString &text);
|
void replaceUnsentText(const QString &text);
|
||||||
|
void replacePlainText(const QString &text);
|
||||||
|
|
||||||
void setFont(QFont f);
|
void setFont(QFont f);
|
||||||
void setFont(QFont f, QColor fg, QColor bg);
|
void setFont(QFont f, QColor fg, QColor bg);
|
||||||
|
@ -6354,15 +6354,28 @@ bool MainWindow::prepareNextMessageFrame()
|
|||||||
|
|
||||||
// typeahead
|
// typeahead
|
||||||
static QString lastText;
|
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 sent = ui->extFreeTextMsgEdit->sentText();
|
||||||
auto unsent = ui->extFreeTextMsgEdit->unsentText();
|
auto unsent = ui->extFreeTextMsgEdit->unsentText();
|
||||||
qDebug() << "text dirty for typeahead\n" << sent << "\n" << unsent;
|
qDebug() << "text dirty for typeahead\n" << sent << "\n" << unsent;
|
||||||
m_txFrameQueue.clear();
|
m_txFrameQueue.clear();
|
||||||
m_txFrameCount = 0;
|
m_txFrameCount = 0;
|
||||||
auto newUnsent = appendMessage(unsent);
|
auto newText = appendMessage(unsent);
|
||||||
ui->extFreeTextMsgEdit->replaceUnsentText(newUnsent);
|
ui->extFreeTextMsgEdit->replaceUnsentText(newText);
|
||||||
lastText = ui->extFreeTextMsgEdit->toPlainText();
|
#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();
|
QPair<QString, int> f = popMessageFrame();
|
||||||
|
Loading…
Reference in New Issue
Block a user