[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdevelop/lib/util
From:       Amilcar do Carmo Lucas <amilcar () ida ! ing ! tu-bs ! de>
Date:       2003-10-15 10:19:27
[Download RAW message or body]

CVS commit by aclu: 

To see output of application in the Application Output Tab.
This only was possible for the first messages, so I looked in the code of kdevelop to
see what was going on. I came up with this changes in processwidget.h/cpp,
The qApp->processEvents() is needed because otherwise the listbox is not
yet updated before the scroll down. I tried to do the same using a QTimer,
but then I would only get good results when the listbox was not yet very big.
Added a check to see if we are not somewhere in the midle of the output, 
meaning the user has scrolled back.

Patch by:  Pieter Pareit <pieter.pareit IN tinternet.be> Thanks.


  M +18 -2     processwidget.cpp   1.13
  M +3 -0      processwidget.h   1.7


--- kdevelop/lib/util/processwidget.cpp  #1.12:1.13
@@ -19,4 +19,5 @@
 #include <kprocess.h>
 #include <qpainter.h>
+#include <qapplication.h>
 
 
@@ -107,4 +108,5 @@ void ProcessWidget::slotProcessExited(KP
 {
     childFinished(childproc->normalExit(), childproc->exitStatus());
+    maybeScrollToBottom();
     emit processExited(childproc);
 }
@@ -115,4 +117,5 @@ void ProcessWidget::insertStdoutLine(con
     insertItem(new ProcessListBoxItem(line.stripWhiteSpace(),
         ProcessListBoxItem::Normal));
+    maybeScrollToBottom();
 }
 
@@ -122,4 +125,5 @@ void ProcessWidget::insertStderrLine(con
     insertItem(new ProcessListBoxItem(line.stripWhiteSpace(),
         ProcessListBoxItem::Error));
+    maybeScrollToBottom();
 }
 
@@ -154,4 +158,16 @@ QSize ProcessWidget::minimumSizeHint() c
     return QSize( QListBox::sizeHint().width(),
                   (fontMetrics().lineSpacing()+2)*4 );
+}
+
+/** Should be called right after an insertItem(),
+   will automatic scroll the listbox if it is already at the bottom
+   to prevent automatic scrolling when the user has scrolled up
+*/
+void ProcessWidget::maybeScrollToBottom()
+{
+    if ( verticalScrollBar()->value() == verticalScrollBar()->maxValue() ) {
+        qApp->processEvents();
+        verticalScrollBar()->setValue( verticalScrollBar()->maxValue() );
+    }
 }
 

--- kdevelop/lib/util/processwidget.h  #1.6:1.7
@@ -93,4 +93,7 @@ protected slots:
 
 private:
+    void maybeScrollToBottom();
+
+private:
     KProcess *childproc;
     ProcessLineMaker* procLineMaker;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic