Mercurial > hg > octave-lyh
changeset 17216: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 | 8b64a1fc3071 |
children | eb88f77b3e26 |
files | libgui/src/history-dock-widget.cc |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
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