Resize completion when it's shown, and only then.

Before this, we always resized the completion when the mainwindow was resized.
If the statusbar is hidden during the resize (ui -> hide-statusbar is true), we
got an invalid calculated QRect for the completion, causing the update to be
not applied at all - so the completion showed up incorrectly.

With this change, another resize is done when the completion is shown - at this
point it's certain the statusbar is visible. Also we only update it while it's
shown - it doesn't make sense to always adjust its size when it's hidden
anyways.
This commit is contained in:
Florian Bruhin 2015-01-28 22:16:22 +01:00
parent 81b91888f4
commit 66ec4f0599
2 changed files with 9 additions and 0 deletions

View File

@ -241,3 +241,8 @@ class CompletionView(QTreeView):
"""Extend resizeEvent to adjust column size."""
super().resizeEvent(e)
self._resize_columns()
def showEvent(self, e):
"""Adjust the completion size when it's freshly shown."""
self.resize_completion.emit()
super().showEvent(e)

View File

@ -266,6 +266,10 @@ class MainWindow(QWidget):
@pyqtSlot()
def resize_completion(self):
"""Adjust completion according to config."""
if not self._completion.isVisible():
# It doesn't make sense to resize the completion as long as it's
# not shown anyways.
return
# Get the configured height/percentage.
confheight = str(config.get('completion', 'height'))
if confheight.endswith('%'):