293 @signal forwardAvailable(bool) emitted after the current URL has changed |
293 @signal forwardAvailable(bool) emitted after the current URL has changed |
294 @signal backwardAvailable(bool) emitted after the current URL has changed |
294 @signal backwardAvailable(bool) emitted after the current URL has changed |
295 @signal highlighted(const QString&) emitted, when the mouse hovers over a link |
295 @signal highlighted(const QString&) emitted, when the mouse hovers over a link |
296 @signal search(const QUrl &) emitted, when a search is requested |
296 @signal search(const QUrl &) emitted, when a search is requested |
297 """ |
297 """ |
|
298 sourceChanged = pyqtSignal(QUrl) |
|
299 forwardAvailable = pyqtSignal(bool) |
|
300 backwardAvailable = pyqtSignal(bool) |
|
301 highlighted = pyqtSignal(str) |
|
302 search = pyqtSignal(QUrl) |
|
303 |
298 def __init__(self, parent = None, name = ""): |
304 def __init__(self, parent = None, name = ""): |
299 """ |
305 """ |
300 Constructor |
306 Constructor |
301 |
307 |
302 @param parent parent widget of this window (QWidget) |
308 @param parent parent widget of this window (QWidget) |
325 ] |
331 ] |
326 |
332 |
327 self.__javaScriptBinding = None |
333 self.__javaScriptBinding = None |
328 self.__javaScriptEricObject = None |
334 self.__javaScriptEricObject = None |
329 |
335 |
330 self.connect(self.mw, SIGNAL("zoomTextOnlyChanged(bool)"), self.__applyZoom) |
336 self.mw.zoomTextOnlyChanged.connect(self.__applyZoom) |
331 |
337 |
332 self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) |
338 self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) |
333 self.connect(self, SIGNAL('linkClicked(const QUrl &)'), self.setSource) |
339 self.linkClicked.connect(self.setSource) |
334 self.connect(self, SIGNAL('iconChanged()'), self.__iconChanged) |
340 self.iconChanged.connect(self.__iconChanged) |
335 |
341 |
336 self.connect(self, SIGNAL('urlChanged(const QUrl &)'), self.__urlChanged) |
342 self.urlChanged.connect(self.__urlChanged) |
337 self.connect(self, SIGNAL('statusBarMessage(const QString &)'), |
343 self.statusBarMessage.connect(self.__statusBarMessage) |
338 self.__statusBarMessage) |
344 self.page().linkHovered.connect(self.__linkHovered) |
339 self.connect(self.page(), |
345 |
340 SIGNAL('linkHovered(const QString &, const QString &, const QString &)'), |
346 self.loadStarted.connect(self.__loadStarted) |
341 self.__linkHovered) |
347 self.loadProgress.connect(self.__loadProgress) |
342 |
348 self.loadFinished.connect(self.__loadFinished) |
343 self.connect(self, SIGNAL('loadStarted()'), self.__loadStarted) |
|
344 self.connect(self, SIGNAL('loadProgress(int)'), self.__loadProgress) |
|
345 self.connect(self, SIGNAL('loadFinished(bool)'), self.__loadFinished) |
|
346 |
349 |
347 self.page().setForwardUnsupportedContent(True) |
350 self.page().setForwardUnsupportedContent(True) |
348 self.connect(self.page(), SIGNAL('unsupportedContent(QNetworkReply *)'), |
351 self.page().unsupportedContent.connect(self.__unsupportedContent) |
349 self.__unsupportedContent) |
352 |
350 |
353 self.page().downloadRequested.connect(self.__downloadRequested) |
351 self.connect(self.page(), SIGNAL('downloadRequested(const QNetworkRequest &)'), |
354 self.page().frameCreated.connect(self.__addExternalBinding) |
352 self.__downloadRequested) |
|
353 self.connect(self.page(), SIGNAL("frameCreated(QWebFrame *)"), |
|
354 self.__addExternalBinding) |
|
355 self.__addExternalBinding(self.page().mainFrame()) |
355 self.__addExternalBinding(self.page().mainFrame()) |
356 |
356 |
357 self.connect(self.page(), SIGNAL('databaseQuotaExceeded(QWebFrame*, QString)'), |
357 self.page().databaseQuotaExceeded.connect(self.__databaseQuotaExceeded) |
358 self.__databaseQuotaExceeded) |
358 |
359 |
359 self.mw.openSearchManager().currentEngineChanged.connect( |
360 self.connect(self.mw.openSearchManager(), |
360 self.__currentEngineChanged) |
361 SIGNAL("currentEngineChanged()"), |
|
362 self.__currentEngineChanged) |
|
363 |
361 |
364 def __addExternalBinding(self, frame = None): |
362 def __addExternalBinding(self, frame = None): |
365 """ |
363 """ |
366 Private slot to add javascript bindings for adding search providers. |
364 Private slot to add javascript bindings for adding search providers. |
367 |
365 |
384 if self.__javaScriptEricObject is None: |
382 if self.__javaScriptEricObject is None: |
385 self.__javaScriptEricObject = JavaScriptEricObject(self.mw, self) |
383 self.__javaScriptEricObject = JavaScriptEricObject(self.mw, self) |
386 frame.addToJavaScriptWindowObject("eric", self.__javaScriptEricObject) |
384 frame.addToJavaScriptWindowObject("eric", self.__javaScriptEricObject) |
387 else: |
385 else: |
388 # called from QWebPage.frameCreated |
386 # called from QWebPage.frameCreated |
389 self.connect(frame, SIGNAL("javaScriptWindowObjectCleared()"), |
387 frame.javaScriptWindowObjectCleared.connect(self.__addExternalBinding) |
390 self.__addExternalBinding) |
|
391 frame.addToJavaScriptWindowObject("external", self.__javaScriptBinding) |
388 frame.addToJavaScriptWindowObject("external", self.__javaScriptBinding) |
392 |
389 |
393 def linkedResources(self, relation = ""): |
390 def linkedResources(self, relation = ""): |
394 """ |
391 """ |
395 Public method to extract linked resources. |
392 Public method to extract linked resources. |
758 for engineName in engineNames: |
755 for engineName in engineNames: |
759 engine = self.mw.openSearchManager().engine(engineName) |
756 engine = self.mw.openSearchManager().engine(engineName) |
760 act = OpenSearchEngineAction(engine, self.__searchMenu) |
757 act = OpenSearchEngineAction(engine, self.__searchMenu) |
761 self.__searchMenu.addAction(act) |
758 self.__searchMenu.addAction(act) |
762 act.setData(engineName) |
759 act.setData(engineName) |
763 self.connect(self.__searchMenu, SIGNAL("triggered(QAction *)"), |
760 self.__searchMenu.triggered.connect(self.__searchRequested) |
764 self.__searchRequested) |
|
765 |
761 |
766 menu.addSeparator() |
762 menu.addSeparator() |
767 |
763 |
768 if hasattr(QtWebKit, 'QWebElement'): |
764 if hasattr(QtWebKit, 'QWebElement'): |
769 element = hit.element() |
765 element = hit.element() |
1011 """ |
1007 """ |
1012 Private slot to handle the urlChanged signal. |
1008 Private slot to handle the urlChanged signal. |
1013 |
1009 |
1014 @param url the new url (QUrl) |
1010 @param url the new url (QUrl) |
1015 """ |
1011 """ |
1016 self.emit(SIGNAL('sourceChanged(const QUrl &)'), url) |
1012 self.sourceChanged.emit(url) |
1017 |
1013 |
1018 self.emit(SIGNAL('forwardAvailable(bool)'), self.isForwardAvailable()) |
1014 self.forwardAvailable.emit(self.isForwardAvailable()) |
1019 self.emit(SIGNAL('backwardAvailable(bool)'), self.isBackwardAvailable()) |
1015 self.backwardAvailable.emit(self.isBackwardAvailable()) |
1020 |
1016 |
1021 def __statusBarMessage(self, text): |
1017 def __statusBarMessage(self, text): |
1022 """ |
1018 """ |
1023 Private slot to handle the statusBarMessage signal. |
1019 Private slot to handle the statusBarMessage signal. |
1024 |
1020 |
1032 |
1028 |
1033 @param link the URL of the link (string) |
1029 @param link the URL of the link (string) |
1034 @param title the link title (string) |
1030 @param title the link title (string) |
1035 @param textContent text content of the link (string) |
1031 @param textContent text content of the link (string) |
1036 """ |
1032 """ |
1037 self.emit(SIGNAL('highlighted(const QString&)'), link) |
1033 self.highlighted.emit(link) |
1038 |
1034 |
1039 ############################################################################ |
1035 ############################################################################ |
1040 ## Signal handlers below |
1036 ## Signal handlers below |
1041 ############################################################################ |
1037 ############################################################################ |
1042 |
1038 |
1119 |
1115 |
1120 if requestFilename is None: |
1116 if requestFilename is None: |
1121 requestFilename = Preferences.getUI("RequestDownloadFilename") |
1117 requestFilename = Preferences.getUI("RequestDownloadFilename") |
1122 dlg = DownloadDialog(reply, requestFilename, self.page(), download) |
1118 dlg = DownloadDialog(reply, requestFilename, self.page(), download) |
1123 if dlg.initialize(): |
1119 if dlg.initialize(): |
1124 self.connect(dlg, SIGNAL("done()"), self.__downloadDone) |
1120 dlg.done[()].connect(self.__downloadDone) |
1125 self.__downloadWindows.append(dlg) |
1121 self.__downloadWindows.append(dlg) |
1126 dlg.show() |
1122 dlg.show() |
1127 self.setUrl(self.url()) |
1123 self.setUrl(self.url()) |
1128 else: |
1124 else: |
1129 replyUrl = reply.url() |
1125 replyUrl = reply.url() |
1153 "proxy, make sure that the browser is permitted to access " |
1149 "proxy, make sure that the browser is permitted to access " |
1154 "the network.") |
1150 "the network.") |
1155 ) |
1151 ) |
1156 self.setHtml(html, replyUrl) |
1152 self.setHtml(html, replyUrl) |
1157 self.mw.historyManager().removeHistoryEntry(replyUrl, self.title()) |
1153 self.mw.historyManager().removeHistoryEntry(replyUrl, self.title()) |
1158 self.emit(SIGNAL('loadFinished(bool)'), False) |
1154 self.loadFinished.emit(False) |
1159 |
1155 |
1160 def __downloadDone(self): |
1156 def __downloadDone(self): |
1161 """ |
1157 """ |
1162 Private slot to handle the done signal of the download dialogs. |
1158 Private slot to handle the done signal of the download dialogs. |
1163 """ |
1159 """ |
1164 dlg = self.sender() |
1160 dlg = self.sender() |
1165 if dlg in self.__downloadWindows: |
1161 if dlg in self.__downloadWindows: |
1166 self.disconnect(dlg, SIGNAL("done()"), self.__downloadDone) |
1162 dlg.done[()].disconnect(self.__downloadDone) |
1167 |
1163 |
1168 def __downloadRequested(self, request): |
1164 def __downloadRequested(self, request): |
1169 """ |
1165 """ |
1170 Private slot to handle a download request. |
1166 Private slot to handle a download request. |
1171 |
1167 |