15 pass |
15 pass |
16 |
16 |
17 import os |
17 import os |
18 |
18 |
19 from PyQt5.QtCore import pyqtSignal, QUrl, QFileInfo, Qt, QTimer, QEvent, \ |
19 from PyQt5.QtCore import pyqtSignal, QUrl, QFileInfo, Qt, QTimer, QEvent, \ |
20 QPoint, QDateTime, qVersion, QStandardPaths |
20 QPoint, QDateTime, QStandardPaths |
21 from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \ |
21 from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \ |
22 QContextMenuEvent, QPixmap |
22 QContextMenuEvent, QPixmap |
23 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication |
23 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication |
24 from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ |
24 from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ |
25 QWebEngineDownloadItem |
25 QWebEngineDownloadItem |
120 self.__mw.personalInformationManager().connectPage(self.page()) |
121 self.__mw.personalInformationManager().connectPage(self.page()) |
121 |
122 |
122 self.__inspector = None |
123 self.__inspector = None |
123 WebInspector.registerView(self) |
124 WebInspector.registerView(self) |
124 |
125 |
125 if qVersion() >= "5.8.0": |
126 if qVersionTuple() >= (5, 8, 0): |
126 if self.parentWidget() is not None: |
127 if self.parentWidget() is not None: |
127 self.parentWidget().installEventFilter(self) |
128 self.parentWidget().installEventFilter(self) |
128 |
129 |
129 lay = self.layout() |
130 lay = self.layout() |
130 lay.currentChanged.connect( |
131 lay.currentChanged.connect( |
340 |
341 |
341 def unselect(self): |
342 def unselect(self): |
342 """ |
343 """ |
343 Public slot to clear the current selection. |
344 Public slot to clear the current selection. |
344 """ |
345 """ |
345 if qVersion() >= "5.7.0": |
346 if qVersionTuple() >= (5, 7, 0): |
346 self.triggerPageAction(QWebEnginePage.Unselect) |
347 self.triggerPageAction(QWebEnginePage.Unselect) |
347 else: |
348 else: |
348 self.page().runJavaScript( |
349 self.page().runJavaScript( |
349 "window.getSelection().empty()", |
350 "window.getSelection().empty()", |
350 WebBrowserPage.SafeJsWorld) |
351 WebBrowserPage.SafeJsWorld) |
523 @type QMenu |
524 @type QMenu |
524 @param hitTest reference to the hit test object |
525 @param hitTest reference to the hit test object |
525 @type WebHitTestResult |
526 @type WebHitTestResult |
526 """ |
527 """ |
527 spellCheckActionCount = 0 |
528 spellCheckActionCount = 0 |
528 if qVersion() >= "5.7.0": |
529 if qVersionTuple() >= (5, 7, 0): |
529 contextMenuData = self.page().contextMenuData() |
530 contextMenuData = self.page().contextMenuData() |
530 hitTest.updateWithContextMenuData(contextMenuData) |
531 hitTest.updateWithContextMenuData(contextMenuData) |
531 |
532 |
532 if qVersion() >= "5.8.0" and \ |
533 if qVersionTuple() >= (5, 8, 0) and \ |
533 bool(contextMenuData.misspelledWord()): |
534 bool(contextMenuData.misspelledWord()): |
534 boldFont = menu.font() |
535 boldFont = menu.font() |
535 boldFont.setBold(True) |
536 boldFont.setBold(True) |
536 |
537 |
537 for suggestion in contextMenuData.spellCheckerSuggestions(): |
538 for suggestion in contextMenuData.spellCheckerSuggestions(): |
1389 @type QEvent |
1390 @type QEvent |
1390 @return flag indicating that the event should be filtered out |
1391 @return flag indicating that the event should be filtered out |
1391 @rtype bool |
1392 @rtype bool |
1392 """ |
1393 """ |
1393 # find the render widget receiving events for the web page |
1394 # find the render widget receiving events for the web page |
1394 if qVersion() < "5.8.0": |
1395 if qVersionTuple() < (5, 8, 0): |
1395 if obj is self and evt.type() == QEvent.ChildAdded: |
1396 if obj is self and evt.type() == QEvent.ChildAdded: |
1396 child = evt.child() |
1397 child = evt.child() |
1397 if child and child.inherits( |
1398 if child and child.inherits( |
1398 "QtWebEngineCore::" |
1399 "QtWebEngineCore::" |
1399 "RenderWidgetHostViewQtDelegateWidget"): |
1400 "RenderWidgetHostViewQtDelegateWidget"): |