Protect function drops the selected sent text to make it easier to replace the next frames

This commit is contained in:
Jordan Sherer 2019-09-26 20:29:05 -04:00
parent b216063f60
commit 7aff060ec7

View File

@ -176,6 +176,17 @@ void TransmitTextEdit::on_selectionChanged(){
auto protect = cursorShouldBeProtected(c);
if(protect){
blockSignals(true);
{
int end = c.selectionEnd();
c.setPosition(m_sent);
c.setPosition(end, QTextCursor::KeepAnchor);
setTextCursor(c);
}
blockSignals(false);
}
setProtected(protect);
// TODO: when protected and text is selected, remove protected region from selection
@ -382,10 +393,16 @@ bool TransmitTextEdit::eventFilter(QObject */*o*/, QEvent *e){
// 2. if on the edge, do not filter if not a backspace
int start = qMin(c.selectionStart(), c.selectionEnd());
int end = qMax(c.selectionStart(), c.selectionEnd());
if(start == m_sent && k->key() != Qt::Key_Backspace){
return false;
}
// 3. if on the edge, do not filter if a backspace and there is text selected
if(start == m_sent && start != end && k->key() == Qt::Key_Backspace){
return false;
}
return true;
}