diff -r 4cc6c171ecf6 -r da9e08920e7c WebBrowser/Bookmarks/BookmarksToolBar.py --- a/WebBrowser/Bookmarks/BookmarksToolBar.py Tue Feb 06 19:18:24 2018 +0100 +++ b/WebBrowser/Bookmarks/BookmarksToolBar.py Tue Feb 06 19:18:43 2018 +0100 @@ -84,28 +84,32 @@ v = act.data() if act.menu() is None: - 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) + act2 = menu.addAction(self.tr("Open")) + act2.setData(v) + act2.triggered.connect( + lambda: self.__openBookmark(act2)) + act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB")) + act2.setData(v) + act2.triggered.connect( + lambda: self.__openBookmarkInNewTab(act2)) + act2 = menu.addAction(self.tr("Open in New Window")) + act2.setData(v) + act2.triggered.connect( + lambda: self.__openBookmarkInNewWindow(act2)) + act2 = menu.addAction(self.tr("Open in New Private Window")) + act2.setData(v) + act2.triggered.connect( + lambda: self.__openBookmarkInPrivateWindow(act2)) menu.addSeparator() - menu.addAction( - self.tr("Remove"), - self.__removeBookmark).setData(v) + act2 = menu.addAction(self.tr("Remove")) + act2.setData(v) + act2.triggered.connect(lambda: self.__removeBookmark(act2)) menu.addSeparator() - menu.addAction( - self.tr("Properties..."), - self.__edit).setData(v) + act2 = menu.addAction(self.tr("Properties...")) + act2.setData(v) + act2.triggered.connect(lambda: self.__edit(act2)) menu.addSeparator() menu.addAction(self.tr("Add Bookmark..."), self.__newBookmark) @@ -153,55 +157,70 @@ idx.data(Qt.DisplayRole)) self.__updateVisitCount(idx) - def __openBookmark(self): + def __openBookmark(self, act): """ Private slot to open a bookmark in the current browser tab. + + @param act reference to the triggering action + @type QAction """ - idx = self.index(self.sender()) + idx = self.index(act) self.openUrl.emit( idx.data(BookmarksModel.UrlRole), idx.data(Qt.DisplayRole)) self.__updateVisitCount(idx) - def __openBookmarkInNewTab(self): + def __openBookmarkInNewTab(self, act): """ Private slot to open a bookmark in a new browser tab. + + @param act reference to the triggering action + @type QAction """ - idx = self.index(self.sender()) + idx = self.index(act) self.newTab.emit( idx.data(BookmarksModel.UrlRole), idx.data(Qt.DisplayRole)) self.__updateVisitCount(idx) - def __openBookmarkInNewWindow(self): + def __openBookmarkInNewWindow(self, act): """ Private slot to open a bookmark in a new window. + + @param act reference to the triggering action + @type QAction """ - idx = self.index(self.sender()) + idx = self.index(act) self.newWindow.emit( idx.data(BookmarksModel.UrlRole), idx.data(Qt.DisplayRole)) self.__updateVisitCount(idx) - def __openBookmarkInPrivateWindow(self): + def __openBookmarkInPrivateWindow(self, act): """ Private slot to open a bookmark in a new private window. + + @param act reference to the triggering action + @type QAction """ - idx = self.index(self.sender()) + idx = self.index(act) url = idx.data(BookmarksModel.UrlRole) from WebBrowser.WebBrowserWindow import WebBrowserWindow WebBrowserWindow.mainWindow().newPrivateWindow(url) self.__updateVisitCount(idx) - def __removeBookmark(self): + def __removeBookmark(self, act): """ Private slot to remove a bookmark. + + @param act reference to the triggering action + @type QAction """ - idx = self.index(self.sender()) + idx = self.index(act) self.__bookmarksModel.removeRow(idx.row(), self.rootIndex()) @@ -237,12 +256,15 @@ menu.newWindow.connect(self.newWindow) return menu - def __edit(self): + def __edit(self, act): """ Private slot to edit a bookmarks properties. + + @param act reference to the triggering action + @type QAction """ from .BookmarkPropertiesDialog import BookmarkPropertiesDialog - idx = self.index(self.sender()) + idx = self.index(act) node = self.__bookmarksModel.node(idx) dlg = BookmarkPropertiesDialog(node) dlg.exec_()