Fixing scroll to bottom on startup
authorEd Page <eopage@byu.net>
Thu, 13 Jan 2011 02:43:01 +0000 (20:43 -0600)
committerEd Page <eopage@byu.net>
Thu, 13 Jan 2011 03:06:16 +0000 (21:06 -0600)
src/ejpi_qt.py
src/qhistory.py

index 1c79d9d..82cd74e 100755 (executable)
@@ -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
index 759ba49..fdd48dd 100644 (file)
@@ -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):