[vlc-devel] commit: Qt4_message: when the cursor it at the end, scroll down automatically. ( Rémi Duraffort )

git version control git at videolan.org
Mon Jan 12 17:21:48 CET 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Mon Jan 12 17:14:55 2009 +0100| [016a90f174fbffcfc70425685db5188983240708] | committer: Rémi Duraffort 

Qt4_message: when the cursor it at the end, scroll down automatically.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=016a90f174fbffcfc70425685db5188983240708
---

 modules/gui/qt4/dialogs/messages.cpp |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index 538de94..48d4b67 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -182,6 +182,8 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
     int endPos = messages->textCursor().selectionEnd();
 
     messages->moveCursor( QTextCursor::End );
+    if( startPos == endPos && messages->textCursor().selectionEnd() == endPos )
+        endPos = 0;
     messages->setFontItalic( true );
     messages->setTextColor( "darkBlue" );
     messages->insertPlainText( qfu( item->psz_module ) );
@@ -215,11 +217,18 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
     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 );
+    // If the cursor was at this end, put it at the end,
+    // so we don't need to scroll down.
+    if( endPos == 0 )
+        messages->moveCursor( QTextCursor::End );
+    else
+    {
+        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::customEvent( QEvent *event )
 {




More information about the vlc-devel mailing list