Continued porting the web browser. QtWebEngine

Sat, 05 Mar 2016 17:24:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Mar 2016 17:24:44 +0100
branch
QtWebEngine
changeset 4808
328e613165fe
parent 4807
5c87ef12aa6d
child 4809
4daf93888029

Continued porting the web browser.

- added actions to open a bookmark in a new and a new private window to the bookmarks menu and toolbar

WebBrowser/Bookmarks/BookmarksMenu.py file | annotate | diff | comparison | revisions
WebBrowser/Bookmarks/BookmarksToolBar.py file | annotate | diff | comparison | revisions
--- a/WebBrowser/Bookmarks/BookmarksMenu.py	Sat Mar 05 17:02:57 2016 +0100
+++ b/WebBrowser/Bookmarks/BookmarksMenu.py	Sat Mar 05 17:24:44 2016 +0100
@@ -139,23 +139,28 @@
             menu = QMenu()
             v = act.data()
             
-            menuAction = menu.addAction(
-                self.tr("&Open"), self.__openBookmark)
-            menuAction.setData(v)
-            menuAction = menu.addAction(
-                self.tr("Open in New &Tab\tCtrl+LMB"),
-                self.__openBookmarkInNewTab)
-            menuAction.setData(v)
+            menu.addAction(
+                self.tr("Open"),
+                self.__openBookmark).setData(v)
+            menu.addAction(
+                self.tr("Open in New Tab\tCtrl+LMB"),
+                self.__openBookmarkInNewTab).setData(v)
+            menu.addAction(
+                self.tr("Open in New Window"),
+                self.__openBookmarkInNewWindow).setData(v)
+            menu.addAction(
+                self.tr("Open in New Private Window"),
+                self.__openBookmarkInPrivateWindow).setData(v)
             menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Remove"), self.__removeBookmark)
-            menuAction.setData(v)
+            menu.addAction(
+                self.tr("Remove"),
+                self.__removeBookmark).setData(v)
             menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Properties..."), self.__edit)
-            menuAction.setData(v)
+            menu.addAction(
+                self.tr("Properties..."),
+                self.__edit).setData(v)
             
             execAct = menu.exec_(QCursor.pos())
             if execAct is not None:
@@ -185,6 +190,26 @@
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
     
+    def __openBookmarkInNewWindow(self):
+        """
+        Private slot to open a bookmark in a new window.
+        """
+        idx = self.index(self.sender())
+        url = idx.data(BookmarksModel.UrlRole)
+        
+        from WebBrowser.WebBrowserWindow import WebBrowserWindow
+        WebBrowserWindow.mainWindow().newWindow(url)
+    
+    def __openBookmarkInPrivateWindow(self):
+        """
+        Private slot to open a bookmark in a new private window.
+        """
+        idx = self.index(self.sender())
+        url = idx.data(BookmarksModel.UrlRole)
+        
+        from WebBrowser.WebBrowserWindow import WebBrowserWindow
+        WebBrowserWindow.mainWindow().newPrivateWindow(url)
+    
     def __removeBookmark(self):
         """
         Private slot to remove a bookmark.
--- a/WebBrowser/Bookmarks/BookmarksToolBar.py	Sat Mar 05 17:02:57 2016 +0100
+++ b/WebBrowser/Bookmarks/BookmarksToolBar.py	Sat Mar 05 17:24:44 2016 +0100
@@ -83,29 +83,32 @@
             v = act.data()
             
             if act.menu() is None:
-                menuAction = menu.addAction(
-                    self.tr("&Open"), self.__openBookmark)
-                menuAction.setData(v)
-                menuAction = menu.addAction(
-                    self.tr("Open in New &Tab\tCtrl+LMB"),
-                    self.__openBookmarkInNewTab)
-                menuAction.setData(v)
-                # TODO: Bookmarks: add open in new window
-                # TODO: Bookmarks: add open in private window
+                menu.addAction(
+                    self.tr("Open"),
+                    self.__openBookmark).setData(v)
+                menu.addAction(
+                    self.tr("Open in New Tab\tCtrl+LMB"),
+                    self.__openBookmarkInNewTab).setData(v)
+                menu.addAction(
+                    self.tr("Open in New Window"),
+                    self.__openBookmarkInNewWindow).setData(v)
+                menu.addAction(
+                    self.tr("Open in New Private Window"),
+                    self.__openBookmarkInPrivateWindow).setData(v)
                 menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Remove"), self.__removeBookmark)
-            menuAction.setData(v)
+            menu.addAction(
+                self.tr("Remove"),
+                self.__removeBookmark).setData(v)
             menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Properties..."), self.__edit)
-            menuAction.setData(v)
+            menu.addAction(
+                self.tr("Properties..."),
+                self.__edit).setData(v)
             menu.addSeparator()
         
-        menu.addAction(self.tr("Add &Bookmark..."), self.__newBookmark)
-        menu.addAction(self.tr("Add &Folder..."), self.__newFolder)
+        menu.addAction(self.tr("Add Bookmark..."), self.__newBookmark)
+        menu.addAction(self.tr("Add Folder..."), self.__newFolder)
         
         menu.exec_(QCursor.pos())
     
@@ -167,6 +170,26 @@
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
     
+    def __openBookmarkInNewWindow(self):
+        """
+        Private slot to open a bookmark in a new window.
+        """
+        idx = self.index(self.sender())
+        url = idx.data(BookmarksModel.UrlRole)
+        
+        from WebBrowser.WebBrowserWindow import WebBrowserWindow
+        WebBrowserWindow.mainWindow().newWindow(url)
+    
+    def __openBookmarkInPrivateWindow(self):
+        """
+        Private slot to open a bookmark in a new private window.
+        """
+        idx = self.index(self.sender())
+        url = idx.data(BookmarksModel.UrlRole)
+        
+        from WebBrowser.WebBrowserWindow import WebBrowserWindow
+        WebBrowserWindow.mainWindow().newPrivateWindow(url)
+    
     def __removeBookmark(self):
         """
         Private slot to remove a bookmark.

eric ide

mercurial