Mercurial > hg > octave-nkf
diff libgui/src/history-dock-widget.cc @ 17208:2527bc7200ee
Only scroll history window if it is positioned at bottom.
* history-dock-widget.cc
(history_dock_widget::append_history): Scroll to bottom if slide bar value
equals maximum.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Thu, 08 Aug 2013 15:52:30 -0400 |
parents | 944ade6e7f66 |
children | 7fb4461997aa |
line wrap: on
line diff
--- a/libgui/src/history-dock-widget.cc +++ b/libgui/src/history-dock-widget.cc @@ -28,6 +28,7 @@ #include <QClipboard> #include <QVBoxLayout> #include <QMenu> +#include <QScrollBar> #include "error.h" @@ -160,8 +161,16 @@ { QStringList lst = _history_model->stringList (); lst.append (hist_entry); + + QScrollBar *scroll_bar = _history_list_view->verticalScrollBar (); + + bool at_bottom = scroll_bar->maximum () - scroll_bar->value () < 1; + _history_model->setStringList (lst); - _history_list_view->scrollToBottom (); + + // Scroll if slider position at bottom. + if (at_bottom) + _history_list_view->scrollToBottom (); } void