diff options
author | Florian Bruhin <git@the-compiler.org> | 2014-12-10 15:35:13 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2014-12-10 15:35:13 +0100 |
commit | 06cc982ab51cc9e3142765f6429fdfa5869664b4 (patch) | |
tree | c1788edc174020167c9be2bc8d8cb5cfedc93f6b | |
parent | db2d4a6bedfd6941f9b368a71d35012877fb31cd (diff) | |
download | qutebrowser-06cc982ab51cc9e3142765f6429fdfa5869664b4.tar.gz qutebrowser-06cc982ab51cc9e3142765f6429fdfa5869664b4.zip |
Dynamically calculate needed size for command.
Closes #26.
-rw-r--r-- | qutebrowser/widgets/statusbar/command.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/qutebrowser/widgets/statusbar/command.py b/qutebrowser/widgets/statusbar/command.py index 13ef24b87..55d6aefe9 100644 --- a/qutebrowser/widgets/statusbar/command.py +++ b/qutebrowser/widgets/statusbar/command.py @@ -19,7 +19,7 @@ """The commandline in the statusbar.""" -from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl +from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QSize from PyQt5.QtWidgets import QSizePolicy from qutebrowser.keyinput import modeman, modeparsers @@ -68,6 +68,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): self.history.history = objreg.get('command-history').data self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored) self.cursorPositionChanged.connect(self.update_completion) + self.textChanged.connect(self.updateGeometry) def prefix(self): """Get the currently entered command prefix.""" @@ -215,3 +216,12 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): return else: super().keyPressEvent(e) + + def sizeHint(self): + """Dynamically calculate the needed size.""" + height = super().sizeHint().height() + text = self.text() + if not text: + text = 'x' + width = self.fontMetrics().width(text) + return QSize(width, height) |