From: Ed Page Date: Thu, 13 Jan 2011 02:43:01 +0000 (-0600) Subject: Fixing scroll to bottom on startup X-Git-Url: http://vcs.maemo.org/git/?p=ejpi;a=commitdiff_plain;h=a33ea3a4f4ef862030bd2c6406fa3c1c44f0edad Fixing scroll to bottom on startup --- diff --git a/src/ejpi_qt.py b/src/ejpi_qt.py index 1c79d9d..82cd74e 100755 --- a/src/ejpi_qt.py +++ b/src/ejpi_qt.py @@ -218,6 +218,12 @@ class MainWindow(qwrappers.WindowWrapper): self.enable_plugin(self._keyboardPlugins.lookup_plugin("Computer")) self.enable_plugin(self._keyboardPlugins.lookup_plugin("Alphabet")) + self._scrollTimer = QtCore.QTimer() + self._scrollTimer.setInterval(0) + self._scrollTimer.setSingleShot(True) + self._scrollTimer.timeout.connect(self._on_delayed_scroll_to_bottom) + self._scrollTimer.start() + self.set_fullscreen(self._app.fullscreenAction.isChecked()) self.set_orientation(self._app.orientationAction.isChecked()) @@ -286,6 +292,11 @@ class MainWindow(qwrappers.WindowWrapper): f.write("%s\n" % line) @misc_utils.log_exception(_moduleLogger) + def _on_delayed_scroll_to_bottom(self): + with qui_utils.notify_error(self._app.errorLog): + self._historyView.scroll_to_bottom() + + @misc_utils.log_exception(_moduleLogger) def _on_child_close(self, something = None): with qui_utils.notify_error(self._app.errorLog): self._child = None diff --git a/src/qhistory.py b/src/qhistory.py index 759ba49..fdd48dd 100644 --- a/src/qhistory.py +++ b/src/qhistory.py @@ -86,7 +86,7 @@ class QCalcHistory(history.AbstractHistory): self._historyStore.appendRow(row) index = result.index() - self._historyView.scrollTo(index) + self._historyView.scrollToBottom() self._rowCount += 1 def pop(self): @@ -111,6 +111,9 @@ class QCalcHistory(history.AbstractHistory): self._historyStore.clear() self._rowCount = 0 + def scroll_to_bottom(self): + self._historyView.scrollToBottom() + @misc_utils.log_exception(_moduleLogger) def _on_row_activated(self, index): with qui_utils.notify_error(self._errorLog):