[vlc-commits] commit: Qt4: Only scroll messages if required (Francois Cartegnie )

git at videolan.org git at videolan.org
Tue Sep 7 23:10:10 CEST 2010


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep  7 15:25:50 2010 +0200| [5c331b20ab0ec6f5cd0c7d350e9017cd2f129719] | committer: Jean-Baptiste Kempf 

Qt4: Only scroll messages if required

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/dialogs/messages.cpp |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index 614db13..22848af 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -40,6 +40,7 @@
 #include <QMutex>
 #include <QLineEdit>
 #include <QPushButton>
+#include <QScrollBar>
 
 #include <assert.h>
 
@@ -231,6 +232,12 @@ void MessagesDialog::updateConfig()
 
 void MessagesDialog::sinkMessage( msg_item_t *item )
 {
+    /* Only scroll if the viewport is at the end.
+       Don't bug user by auto-changing/loosing viewport on insert(). */
+    bool b_autoscroll = ( messages->verticalScrollBar()->value()
+                          + messages->verticalScrollBar()->pageStep()
+                          >= messages->verticalScrollBar()->maximum() );
+
     /* Copy selected text to the clipboard */
     if( messages->textCursor().hasSelection() )
         messages->copy();
@@ -270,7 +277,7 @@ void MessagesDialog::sinkMessage( msg_item_t *item )
     messages->setTextColor( "black" );
     messages->insertPlainText( qfu(item->psz_msg) );
     messages->insertPlainText( "\n" );
-    messages->ensureCursorVisible();
+    if ( b_autoscroll ) messages->ensureCursorVisible();
 }
 
 void MessagesDialog::customEvent( QEvent *event )



More information about the vlc-commits mailing list