WebBrowser/Bookmarks/BookmarksMenu.py

changeset 5038
df7103c3f2a6
parent 5015
ca1d44f0f6b2
child 5389
9b1c800daff3
--- a/WebBrowser/Bookmarks/BookmarksMenu.py	Thu Jul 14 18:56:39 2016 +0200
+++ b/WebBrowser/Bookmarks/BookmarksMenu.py	Sun Jul 17 15:36:11 2016 +0200
@@ -25,11 +25,14 @@
     
     @signal openUrl(QUrl, str) emitted to open a URL with the given title in
         the current tab
-    @signal newUrl(QUrl, str) emitted to open a URL with the given title in a
+    @signal newTab(QUrl, str) emitted to open a URL with the given title in a
         new tab
+    @signal newWindow(QUrl, str) emitted to open a URL with the given title in
+        a new window
     """
     openUrl = pyqtSignal(QUrl, str)
-    newUrl = pyqtSignal(QUrl, str)
+    newTab = pyqtSignal(QUrl, str)
+    newWindow = pyqtSignal(QUrl, str)
     
     def __init__(self, parent=None):
         """
@@ -54,7 +57,8 @@
         """
         menu = BookmarksMenu(self)
         menu.openUrl.connect(self.openUrl)
-        menu.newUrl.connect(self.newUrl)
+        menu.newTab.connect(self.newTab)
+        menu.newWindow.connect(self.newWindow)
         return menu
     
     def __updateVisitCount(self, idx):
@@ -76,7 +80,11 @@
         @param idx index of the activated item (QModelIndex)
         """
         if self._keyboardModifiers & Qt.ControlModifier:
-            self.newUrl.emit(
+            self.newTab.emit(
+                idx.data(BookmarksModel.UrlRole),
+                idx.data(Qt.DisplayRole))
+        elif self._keyboardModifiers & Qt.ShiftModifier:
+            self.newWindow.emit(
                 idx.data(BookmarksModel.UrlRole),
                 idx.data(Qt.DisplayRole))
         else:
@@ -84,7 +92,6 @@
                 idx.data(BookmarksModel.UrlRole),
                 idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
-        self.resetFlags()
     
     def postPopulated(self):
         """
@@ -134,7 +141,7 @@
                     child.data(BookmarksModel.UrlRole),
                     child.data(Qt.DisplayRole))
             else:
-                self.newUrl.emit(
+                self.newTab.emit(
                     child.data(BookmarksModel.UrlRole),
                     child.data(Qt.DisplayRole))
             self.__updateVisitCount(child)
@@ -201,7 +208,7 @@
         """
         idx = self.index(self.sender())
         
-        self.newUrl.emit(
+        self.newTab.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
@@ -266,7 +273,6 @@
         """
         BookmarksMenu.__init__(self, parent)
         
-##        self.__bookmarksManager = None
         self.__initialActions = []
     
     def prePopulated(self):

eric ide

mercurial