gui/log: add scroll to bottom button

This commit is contained in:
Sebastien Bourdeauducq 2016-01-16 13:06:45 -07:00
parent 16f6d00e35
commit ed6a53db00

View File

@ -169,13 +169,19 @@ class _LogDock(dockarea.Dock):
self.filter_freetext_changed)
grid.addWidget(self.filter_freetext, 0, 2)
scrollbottom = QtGui.QToolButton()
scrollbottom.setToolTip("Scroll to bottom")
scrollbottom.setIcon(QtGui.QApplication.style().standardIcon(
QtGui.QStyle.SP_ArrowDown))
grid.addWidget(scrollbottom, 0, 3)
scrollbottom.clicked.connect(self.scroll_to_bottom)
newdock = QtGui.QToolButton()
newdock.setToolTip("Create new log dock")
newdock.setIcon(QtGui.QApplication.style().standardIcon(
QtGui.QStyle.SP_FileDialogNewFolder))
# note the lambda, the default parameter is overriden otherwise
newdock.clicked.connect(lambda: manager.create_new_dock())
grid.addWidget(newdock, 0, 3)
grid.addWidget(newdock, 0, 4)
grid.layout.setColumnStretch(2, 1)
self.log = QtGui.QTableView()
@ -192,7 +198,7 @@ class _LogDock(dockarea.Dock):
QtGui.QAbstractItemView.ScrollPerPixel)
self.log.setShowGrid(False)
self.log.setTextElideMode(QtCore.Qt.ElideNone)
grid.addWidget(self.log, 1, 0, colspan=4)
grid.addWidget(self.log, 1, 0, colspan=5)
self.scroll_at_bottom = False
self.scroll_value = 0
@ -209,6 +215,9 @@ class _LogDock(dockarea.Dock):
return
self.table_model_filter.set_freetext(self.filter_freetext.text())
def scroll_to_bottom(self):
self.log.scrollToBottom()
def rows_inserted_before(self):
scrollbar = self.log.verticalScrollBar()
self.scroll_value = scrollbar.value()