[vlc-devel] commit: Fix a cursor selection bug in the Messages logs (see #2163) ( Ludovic Fauvet )
git version control
git at videolan.org
Wed Nov 12 20:09:19 CET 2008
vlc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Tue Nov 11 11:37:34 2008 +0100| [7c8f1b05e8d2b4aa1717e623eb683337e6f1dced] | committer: 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: Rémi Denis-Courmont <rdenis at simphalempin.com>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c8f1b05e8d2b4aa1717e623eb683337e6f1dced
---
modules/gui/qt4/dialogs/messages.cpp | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index 46aa53b..dd8d9fe 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -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,
More information about the vlc-devel
mailing list