Commit 7c8f1b05 authored by Ludovic Fauvet's avatar Ludovic Fauvet Committed by Rémi Denis-Courmont

Fix a cursor selection bug in the Messages logs (see #2163)

Also introduce a smart selection where the selection is restored after
text is inserted.
Signed-off-by: default avatarRémi Denis-Courmont <rdenis@simphalempin.com>
parent 52193737
......@@ -166,7 +166,11 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
|| (item->i_type == VLC_MSG_DBG && verbosityBox->value() < 2 ))
return;
messages->textCursor().movePosition( QTextCursor::End );
// Saving cursor selection
int startPos = messages->textCursor().selectionStart();
int endPos = messages->textCursor().selectionEnd();
messages->moveCursor( QTextCursor::End );
messages->setFontItalic( true );
messages->setTextColor( "darkBlue" );
messages->insertPlainText( qfu( item->psz_module ) );
......@@ -198,6 +202,13 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
messages->insertPlainText( qfu(item->psz_msg) );
messages->insertPlainText( "\n" );
messages->ensureCursorVisible();
// Restoring saved cursor selection
QTextCursor cur = messages->textCursor();
cur.movePosition( QTextCursor::Start );
cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, startPos );
cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, endPos - startPos );
messages->setTextCursor( cur );
}
void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment