Mon, 29 Feb 2016 19:30:13 +0100
Continued porting the web browser.
- added actions to open a link in a new (private) window to the link context menu
--- a/WebBrowser/WebBrowserTabWidget.py Sun Feb 28 20:09:44 2016 +0100 +++ b/WebBrowser/WebBrowserTabWidget.py Mon Feb 29 19:30:13 2016 +0100 @@ -171,6 +171,7 @@ self.tr("Close Others"), self.__tabContextMenuCloseOthers) self.__tabContextMenu.addAction( self.tr('Close All'), self.closeAllBrowsers) + # TODO: Print ## self.__tabContextMenu.addSeparator() ## self.__tabContextMenu.addAction( ## UI.PixmapCache.getIcon("printPreview.png"), @@ -270,6 +271,7 @@ list(range(index - 1, -1, -1)): self.closeBrowserAt(i) + # TODO: Print ## def __tabContextMenuPrint(self): ## """ ## Private method to print the selected tab. @@ -526,6 +528,7 @@ li.append(self.widget(index)) return li + # TODO: Print ## @pyqtSlot() ## def printBrowser(self, browser=None): ## """ @@ -536,6 +539,7 @@ ## if browser is None: ## browser = self.currentBrowser() ## +## browser.page().runJavaScript("window.print()") ## self.__printRequested(browser.page().mainFrame()) ## ## def __printRequested(self, frame):
--- a/WebBrowser/WebBrowserView.py Sun Feb 28 20:09:44 2016 +0100 +++ b/WebBrowser/WebBrowserView.py Mon Feb 29 19:30:13 2016 +0100 @@ -663,8 +663,14 @@ UI.PixmapCache.getIcon("openNewTab.png"), self.tr("Open Link in New Tab\tCtrl+LMB"), self.__openLinkInNewTab).setData(hitTest.linkUrl()) - # TODO: context menu: Open Link in New Window - # TODO: context menu: Open Link in Private Window + menu.addAction( + UI.PixmapCache.getIcon("newWindow.png"), + self.tr("Open Link in New Window"), + self.__openLinkInNewWindow).setData(hitTest.linkUrl()) + menu.addAction( + UI.PixmapCache.getIcon("privateMode.png"), + self.tr("Open Link in New Private Window"), + self.__openLinkInNewPrivateWindow).setData(hitTest.linkUrl()) menu.addSeparator() # TODO: Qt 5.6 ## menu.addAction( @@ -972,7 +978,7 @@ def __openLinkInNewTab(self): """ Private method called by the context menu to open a link in a new - window. + tab. """ act = self.sender() url = act.data() @@ -984,6 +990,30 @@ self.setSource(url) self.__ctrlPressed = False + def __openLinkInNewWindow(self): + """ + Private slot called by the context menu to open a link in a new + window. + """ + act = self.sender() + url = act.data() + if url.isEmpty(): + return + + self.__mw.newWindow(url) + + def __openLinkInNewPrivateWindow(self): + """ + Private slot called by the context menu to open a link in a new + private window. + """ + act = self.sender() + url = act.data() + if url.isEmpty(): + return + + self.__mw.newPrivateWindow(url) + def __bookmarkLink(self): """ Private slot to bookmark a link via the context menu.
--- a/eric6_browser.py Sun Feb 28 20:09:44 2016 +0100 +++ b/eric6_browser.py Mon Feb 29 19:30:13 2016 +0100 @@ -35,17 +35,16 @@ from PyQt5.QtCore import qVersion if qVersion() < MIN_QT_VERSION: - try: # Py2 - import tkMessageBox as messagebox - except ImportError: - try: # Py3 - from tkinter import messagebox - except ImportError: - sys.exit(100) - messagebox.showerror( - "eric6 Error", + from PyQt5.QtCore import QTimer + from PyQt5.QtWidgets import QApplication + from E5Gui import E5MessageBox + app = QApplication([]) + QTimer.singleShot(0, lambda: E5MessageBox.critical( + None, + "eric6 Web Browser", "You need at least Qt Version {0} to execute the web browser." - .format(MIN_QT_VERSION)) + .format(MIN_QT_VERSION))) + app.exec_() sys.exit(100) SettingsDir = None