Fixed #235: only 7-bit printable ascii allowed in the text box
This commit is contained in:
parent
d75c8fdc83
commit
18dec96843
@ -1,7 +1,9 @@
|
|||||||
#include "TransmitTextEdit.h"
|
#include "TransmitTextEdit.h"
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
void setTextEditFont(QTextEdit *edit, QFont font){
|
void setTextEditFont(QTextEdit *edit, QFont font){
|
||||||
// all uppercase
|
// all uppercase
|
||||||
font.setCapitalization(QFont::AllUppercase);
|
font.setCapitalization(QFont::AllUppercase);
|
||||||
@ -235,18 +237,30 @@ void TransmitTextEdit::on_textContentsChanged(int /*pos*/, int rem, int add){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto text = toPlainText();
|
QString text = toPlainText();
|
||||||
if(text != m_lastText){
|
if(text == m_lastText){
|
||||||
//qDebug() << "text changed" << pos << rem << add << "from" << m_lastText << "to" << text;
|
return;
|
||||||
|
|
||||||
highlight();
|
|
||||||
|
|
||||||
//qDebug() << "sent:" << sentText();
|
|
||||||
//qDebug() << "unsent:" << unsentText();
|
|
||||||
|
|
||||||
m_dirty = true;
|
|
||||||
m_lastText = text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString normalized = text.normalized(QString::NormalizationForm_KD);
|
||||||
|
QString result;
|
||||||
|
std::copy_if(normalized.begin(), normalized.end(), std::back_inserter(result), [](QChar& c) {
|
||||||
|
return c.toLatin1() != 0 && c > 31 && c < 128;
|
||||||
|
});
|
||||||
|
if(result != text){
|
||||||
|
bool blocked = signalsBlocked();
|
||||||
|
blockSignals(true);
|
||||||
|
{
|
||||||
|
replacePlainText(result, true);
|
||||||
|
text = result;
|
||||||
|
}
|
||||||
|
blockSignals(blocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
highlight();
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
m_lastText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransmitTextEdit::highlightBase(){
|
void TransmitTextEdit::highlightBase(){
|
||||||
|
Loading…
Reference in New Issue
Block a user