Add logging for completion resizing

This commit is contained in:
Florian Bruhin 2014-06-22 23:52:50 +02:00
parent d5834e0cf0
commit 03098f861e

View File

@ -29,12 +29,12 @@ import qutebrowser.commands.utils as cmdutils
import qutebrowser.config.config as config import qutebrowser.config.config as config
import qutebrowser.utils.misc as utils import qutebrowser.utils.misc as utils
import qutebrowser.utils.message as message import qutebrowser.utils.message as message
import qutebrowser.utils.log as log
from qutebrowser.widgets.statusbar.bar import StatusBar from qutebrowser.widgets.statusbar.bar import StatusBar
from qutebrowser.widgets.tabbedbrowser import TabbedBrowser from qutebrowser.widgets.tabbedbrowser import TabbedBrowser
from qutebrowser.widgets.completion import CompletionView from qutebrowser.widgets.completion import CompletionView
from qutebrowser.widgets.downloads import DownloadView from qutebrowser.widgets.downloads import DownloadView
from qutebrowser.utils.usertypes import PromptMode from qutebrowser.utils.usertypes import PromptMode
from qutebrowser.utils.log import init as logger
class MainWindow(QWidget): class MainWindow(QWidget):
@ -60,18 +60,18 @@ class MainWindow(QWidget):
geom = b64decode(stateconf['geometry']['mainwindow'], geom = b64decode(stateconf['geometry']['mainwindow'],
validate=True) validate=True)
except (KeyError, binascii.Error) as e: except (KeyError, binascii.Error) as e:
logger.warning("Error while reading geometry: {}: {}".format( log.init.warning("Error while reading geometry: {}: {}".format(
e.__class__.__name__, e)) e.__class__.__name__, e))
self._set_default_geometry() self._set_default_geometry()
else: else:
try: try:
ok = self.restoreGeometry(geom) ok = self.restoreGeometry(geom)
except KeyError: except KeyError:
logger.warning("Error while restoring geometry: {}: {}".format( log.init.warning("Error while restoring geometry: {}: "
e.__class__.__name__, e)) "{}".format(e.__class__.__name__, e))
self._set_default_geometry() self._set_default_geometry()
if not ok: if not ok:
logger.warning("Error while restoring geometry.") log.init.warning("Error while restoring geometry.")
self._set_default_geometry() self._set_default_geometry()
self._vbox = QVBoxLayout(self) self._vbox = QVBoxLayout(self)
@ -126,6 +126,8 @@ class MainWindow(QWidget):
self.completion.horizontalScrollBar().sizeHint().height()) self.completion.horizontalScrollBar().sizeHint().height())
if contents_height <= height: if contents_height <= height:
height = contents_height height = contents_height
else:
contents_height = -1
# hpoint now would be the bottom-left edge of the widget if it was on # hpoint now would be the bottom-left edge of the widget if it was on
# the top of the main window. # the top of the main window.
topleft_y = self.height() - self.status.height() - height topleft_y = self.height() - self.status.height() - height
@ -133,6 +135,11 @@ class MainWindow(QWidget):
topleft = QPoint(0, topleft_y) topleft = QPoint(0, topleft_y)
bottomright = self.status.geometry().topRight() bottomright = self.status.geometry().topRight()
rect = QRect(topleft, bottomright) rect = QRect(topleft, bottomright)
log.misc.debug("confheight: {}, self.height(): {}, height: {}, "
"contents_height: {}, self.status.height(): {}, "
"topleft: {}, bottomright: {}".format(
confheight, self.height(), height, contents_height,
self.status.height(), topleft, bottomright))
utils.qt_ensure_valid(rect) utils.qt_ensure_valid(rect)
self.completion.setGeometry(rect) self.completion.setGeometry(rect)