Actually handle contents_size_changed correctly

This commit is contained in:
Florian Bruhin 2016-07-28 14:56:42 +02:00
parent a0ae96d43e
commit 21c1dec59a
2 changed files with 11 additions and 3 deletions

View File

@ -811,6 +811,7 @@ class HintManager(QObject):
self._context.args = args self._context.args = args
self._context.group = group self._context.group = group
self._init_elements() self._init_elements()
tab.contents_size_changed.connect(self.on_contents_size_changed)
message_bridge = objreg.get('message-bridge', scope='window', message_bridge = objreg.get('message-bridge', scope='window',
window=self._win_id) window=self._win_id)
message_bridge.set_text(self._get_text()) message_bridge.set_text(self._get_text())
@ -1010,8 +1011,8 @@ class HintManager(QObject):
raise cmdexc.CommandError("No hint {}!".format(keystring)) raise cmdexc.CommandError("No hint {}!".format(keystring))
self.fire(keystring, force=True) self.fire(keystring, force=True)
@pyqtSlot('QSize') @pyqtSlot()
def on_contents_size_changed(self, _size): def on_contents_size_changed(self):
"""Reposition hints if contents size changed.""" """Reposition hints if contents size changed."""
log.hints.debug("Contents size changed...!") log.hints.debug("Contents size changed...!")
for e in self._context.all_elems: for e in self._context.all_elems:

View File

@ -23,7 +23,8 @@ import sys
import functools import functools
import xml.etree.ElementTree import xml.etree.ElementTree
from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF,
QSize)
from PyQt5.QtGui import QKeyEvent from PyQt5.QtGui import QKeyEvent
from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame
from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKit import QWebSettings
@ -596,6 +597,10 @@ class WebKitTab(browsertab.AbstractTab):
# https://github.com/The-Compiler/qutebrowser/issues/263 # https://github.com/The-Compiler/qutebrowser/issues/263
frame.contentsSizeChanged.connect(self.contents_size_changed) frame.contentsSizeChanged.connect(self.contents_size_changed)
@pyqtSlot(QSize)
def _on_contents_size_changed(self, size):
self.contents_size_changed.emit(QSizeF(size))
def _connect_signals(self): def _connect_signals(self):
view = self._widget view = self._widget
page = view.page() page = view.page()
@ -611,3 +616,5 @@ class WebKitTab(browsertab.AbstractTab):
page.networkAccessManager().sslErrors.connect(self._on_ssl_errors) page.networkAccessManager().sslErrors.connect(self._on_ssl_errors)
frame.loadFinished.connect(self._on_frame_load_finished) frame.loadFinished.connect(self._on_frame_load_finished)
view.iconChanged.connect(self._on_webkit_icon_changed) view.iconChanged.connect(self._on_webkit_icon_changed)
page.frameCreated.connect(self._on_frame_created)
frame.contentsSizeChanged.connect(self._on_contents_size_changed)