--- a/Helpviewer/HelpSearchWidget.py Mon Oct 17 18:57:24 2016 +0200 +++ b/Helpviewer/HelpSearchWidget.py Mon Oct 17 19:51:51 2016 +0200 @@ -9,7 +9,7 @@ from __future__ import unicode_literals -from PyQt5.QtCore import pyqtSignal, Qt, QEvent, QUrl +from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl from PyQt5.QtWidgets import QWidget, QVBoxLayout, QTextBrowser, QApplication, \ QMenu @@ -48,14 +48,12 @@ self.setFocusProxy(self.__query) self.__query.search.connect(self.__search) - self.__result.requestShowLink.connect(self.linkActivated) + self.__result.requestShowLink.connect(self.__linkActivated) self.__engine.searchingStarted.connect(self.__searchingStarted) self.__engine.searchingFinished.connect(self.__searchingFinished) self.__browser = self.__result.findChildren(QTextBrowser)[0] - if self.__browser: - self.__browser.viewport().installEventFilter(self) def __search(self): """ @@ -78,24 +76,25 @@ """ QApplication.restoreOverrideCursor() - def eventFilter(self, watched, event): + @pyqtSlot(QUrl) + def __linkActivated(self, url): """ - Public method called to filter the event queue. + Private slot handling the activation of an entry. - @param watched the QObject being watched (QObject) - @param event the event that occurred (QEvent) - @return flag indicating whether the event was handled (boolean) + @param url URL of the activated entry + @type QUrl """ - if self.__browser and watched == self.__browser.viewport() and \ - event.type() == QEvent.MouseButtonRelease: - link = self.__result.linkAt(event.pos()) - if not link.isEmpty() and link.isValid(): - ctrl = event.modifiers() & Qt.ControlModifier - if (event.button() == Qt.LeftButton and ctrl) or \ - event.button() == Qt.MidButton: - self.__mw.newTab(link) - - return QWidget.eventFilter(self, watched, event) + if not url.isEmpty() and url.isValid(): + buttons = QApplication.mouseButtons() + modifiers = QApplication.keyboardModifiers() + + if buttons & Qt.MidButton: + self.__mw.newTab(url) + else: + if modifiers & Qt.ControlModifier: + self.__mw.newTab(url) + else: + self.linkActivated.emit(url) def keyPressEvent(self, evt): """