From 66ec4f05990c52523bf76f3fef8b5098ab7bbb41 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 28 Jan 2015 22:16:22 +0100 Subject: [PATCH] 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. --- qutebrowser/completion/completionwidget.py | 5 +++++ qutebrowser/mainwindow/mainwindow.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index ffff7f338..d3b357a5f 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -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) diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index e86ee641b..84d8a7bcb 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -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('%'):