150 ## self.setNetworkAccessManager(self.__proxy) |
150 ## self.setNetworkAccessManager(self.__proxy) |
151 |
151 |
152 self.__sslConfiguration = None |
152 self.__sslConfiguration = None |
153 ## self.__proxy.finished.connect(self.__managerFinished) |
153 ## self.__proxy.finished.connect(self.__managerFinished) |
154 ## |
154 ## |
155 self.__adBlockedEntries = [] |
155 ## self.__adBlockedEntries = [] |
156 self.loadStarted.connect(self.__loadStarted) |
156 ## self.loadStarted.connect(self.__loadStarted) |
157 ## |
|
158 ## self.saveFrameStateRequested.connect( |
|
159 ## self.__saveFrameStateRequested) |
|
160 ## self.restoreFrameStateRequested.connect( |
|
161 ## self.__restoreFrameStateRequested) |
|
162 self.featurePermissionRequested.connect( |
157 self.featurePermissionRequested.connect( |
163 self.__featurePermissionRequested) |
158 self.__featurePermissionRequested) |
164 |
159 |
165 self.authenticationRequired.connect( |
160 self.authenticationRequired.connect( |
166 WebBrowserWindow.networkManager().authentication) |
161 WebBrowserWindow.networkManager().authentication) |
395 ## "@BUTTON@", self.tr("Try Again").encode("utf8")) |
390 ## "@BUTTON@", self.tr("Try Again").encode("utf8")) |
396 ## errorPage.content = html |
391 ## errorPage.content = html |
397 ## return True |
392 ## return True |
398 ## |
393 ## |
399 ## return QWebPage.extension(self, extension, option, output) |
394 ## return QWebPage.extension(self, extension, option, output) |
400 |
395 ## |
401 def __loadStarted(self): |
396 ## def __loadStarted(self): |
402 """ |
397 ## """ |
403 Private slot to handle the loadStarted signal. |
398 ## Private slot to handle the loadStarted signal. |
404 """ |
399 ## """ |
405 self.__adBlockedEntries = [] |
400 ## self.__adBlockedEntries = [] |
406 ## |
401 ## |
407 ## def addAdBlockRule(self, rule, url): |
402 ## def addAdBlockRule(self, rule, url): |
408 ## """ |
403 ## """ |
409 ## Public slot to add an AdBlock rule to the page. |
404 ## Public slot to add an AdBlock rule to the page. |
410 ## |
405 ## |
607 ## fakeEvent = QMouseEvent(QEvent.MouseMove, QPoint(0, -1), |
602 ## fakeEvent = QMouseEvent(QEvent.MouseMove, QPoint(0, -1), |
608 ## Qt.NoButton, Qt.NoButton, Qt.NoModifier) |
603 ## Qt.NoButton, Qt.NoButton, Qt.NoModifier) |
609 ## return super(HelpWebPage, self).event(fakeEvent) |
604 ## return super(HelpWebPage, self).event(fakeEvent) |
610 ## |
605 ## |
611 ## return super(HelpWebPage, self).event(evt) |
606 ## return super(HelpWebPage, self).event(evt) |
612 ## |
|
613 ## def __saveFrameStateRequested(self, frame, itm): |
|
614 ## """ |
|
615 ## Private slot to save the page state (i.e. zoom level and scroll |
|
616 ## position). |
|
617 ## |
|
618 ## Note: Code is based on qutebrowser. |
|
619 ## |
|
620 ## @param frame frame to be saved |
|
621 ## @type QWebFrame |
|
622 ## @param itm web history item to be saved |
|
623 ## @type QWebHistoryItem |
|
624 ## """ |
|
625 ## try: |
|
626 ## if frame != self.mainFrame(): |
|
627 ## return |
|
628 ## except RuntimeError: |
|
629 ## # With Qt 5.2.1 (Ubuntu Trusty) we get this when closing a tab: |
|
630 ## # RuntimeError: wrapped C/C++ object of type BrowserPage has |
|
631 ## # been deleted |
|
632 ## # Since the information here isn't that important for closing web |
|
633 ## # views anyways, we ignore this error. |
|
634 ## return |
|
635 ## data = { |
|
636 ## 'zoom': frame.zoomFactor(), |
|
637 ## 'scrollPos': frame.scrollPosition(), |
|
638 ## } |
|
639 ## itm.setUserData(data) |
|
640 ## |
|
641 ## def __restoreFrameStateRequested(self, frame): |
|
642 ## """ |
|
643 ## Private slot to restore scroll position and zoom level from |
|
644 ## history. |
|
645 ## |
|
646 ## Note: Code is based on qutebrowser. |
|
647 ## |
|
648 ## @param frame frame to be restored |
|
649 ## @type QWebFrame |
|
650 ## """ |
|
651 ## if frame != self.mainFrame(): |
|
652 ## return |
|
653 ## |
|
654 ## data = self.history().currentItem().userData() |
|
655 ## if data is None: |
|
656 ## return |
|
657 ## |
|
658 ## if 'zoom' in data: |
|
659 ## frame.page().view().setZoomValue(int(data['zoom'] * 100), |
|
660 ## saveValue=False) |
|
661 ## |
|
662 ## if 'scrollPos' in data and frame.scrollPosition() == QPoint(0, 0): |
|
663 ## frame.setScrollPosition(data['scrollPos']) |
|
664 |
607 |
665 def __featurePermissionRequested(self, url, feature): |
608 def __featurePermissionRequested(self, url, feature): |
666 """ |
609 """ |
667 Private slot handling a feature permission request. |
610 Private slot handling a feature permission request. |
668 |
611 |