--- a/Helpviewer/Bookmarks/BookmarksMenu.py Tue Feb 06 19:18:24 2018 +0100 +++ b/Helpviewer/Bookmarks/BookmarksMenu.py Tue Feb 06 19:18:43 2018 +0100 @@ -96,13 +96,16 @@ self.addSeparator() act = self.addAction(self.tr("Open all in Tabs")) - act.triggered.connect(self.openAll) + act.triggered.connect(lambda: self.openAll(act)) - def openAll(self): + def openAll(self, act): """ Public slot to open all the menu's items. + + @param act reference to the action object + @type QAction """ - menu = self.sender().parent() + menu = act.parent() if menu is None: return @@ -139,23 +142,24 @@ 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) + 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)) menu.addSeparator() - menuAction = menu.addAction( - self.tr("&Remove"), self.__removeBookmark) - menuAction.setData(v) + act2 = menu.addAction(self.tr("Remove")) + act2.setData(v) + act2.triggered.connect(lambda: self.__removeBookmark(act2)) menu.addSeparator() - menuAction = menu.addAction( - self.tr("&Properties..."), self.__edit) - menuAction.setData(v) + act2 = menu.addAction(self.tr("Properties...")) + act2.setData(v) + act2.triggered.connect(lambda: self.__edit(act2)) execAct = menu.exec_(QCursor.pos()) if execAct is not None: @@ -165,40 +169,52 @@ parent.close() parent = parent.parent() - 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)) - 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.newUrl.emit( idx.data(BookmarksModel.UrlRole), idx.data(Qt.DisplayRole)) - 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.removeEntry(idx) - 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.model().node(idx) dlg = BookmarkPropertiesDialog(node) dlg.exec_() @@ -279,13 +295,15 @@ self.addSeparator() act = self.addAction(self.tr("Default Home Page")) act.setData("eric:home") - act.triggered.connect(self.__defaultBookmarkTriggered) + act.triggered.connect( + lambda: self.__defaultBookmarkTriggered(act)) act = self.addAction(self.tr("Speed Dial")) act.setData("eric:speeddial") - act.triggered.connect(self.__defaultBookmarkTriggered) + act.triggered.connect( + lambda: self.__defaultBookmarkTriggered(act)) self.addSeparator() act = self.addAction(self.tr("Open all in Tabs")) - act.triggered.connect(self.openAll) + act.triggered.connect(lambda: self.openAll(act)) def setInitialActions(self, actions): """ @@ -298,11 +316,13 @@ for act in self.__initialActions: self.addAction(act) - def __defaultBookmarkTriggered(self): + def __defaultBookmarkTriggered(self, act): """ Private slot handling the default bookmark menu entries. + + @param act reference to the action object + @type QAction """ - act = self.sender() urlStr = act.data() if urlStr.startswith("eric:"): self.openUrl.emit(QUrl(urlStr), "")