diff -r 8a5179bced9e -r 7e88f292b1b1 eric7/HelpViewer/HelpViewerWidget.py --- a/eric7/HelpViewer/HelpViewerWidget.py Sun Oct 17 15:26:01 2021 +0200 +++ b/eric7/HelpViewer/HelpViewerWidget.py Sun Oct 17 15:26:31 2021 +0200 @@ -202,7 +202,7 @@ self.__helpTocButton = self.__addNavigationButton( "tableOfContents", self.tr("Show the table of contents")) self.__helpIndexButton = self.__addNavigationButton( - "helpIndex", self.tr("Show the help document index")) + "helpIndex", self.tr("Show the help document index")) self.__helpSearchButton = self.__addNavigationButton( "documentFind", self.tr("Show the help search window")) self.__openPagesButton.setChecked(True) @@ -394,9 +394,9 @@ self.tr("HTML Files (*.htm *.html);;All Files (*)") ) if htmlFile: - self.currentViewer().setUrl(QUrl.fromLocalFile(htmlFile)) + self.currentViewer().setLink(QUrl.fromLocalFile(htmlFile)) - def addPage(self, url=QUrl("about:blank"), background=False): + def addPage(self, url=None, background=False): """ Public method to add a new help page with the given URL. @@ -405,23 +405,28 @@ @param background flag indicating to open the page in the background (defaults to False) @type bool (optional) + @return reference to the created page + @rtype HelpViewerImpl """ + if url is None: + url = QUrl("about:blank") + viewer = self.__newViewer() viewer.setUrl(url) - if background: - cv = self.currentViewer() - if cv: - index = self.__helpStack.indexOf(cv) + 1 - self.__helpStack.insertWidget(index, viewer) - self.__openPagesList.insertPage( - index, viewer, background=background) - cv.setFocus(Qt.FocusReason.OtherFocusReason) - return + cv = self.currentViewer() + if background and bool(cv): + index = self.__helpStack.indexOf(cv) + 1 + self.__helpStack.insertWidget(index, viewer) + self.__openPagesList.insertPage( + index, viewer, background=background) + cv.setFocus(Qt.FocusReason.OtherFocusReason) + else: + self.__helpStack.addWidget(viewer) + self.__openPagesList.addPage(viewer, background=background) + viewer.setFocus(Qt.FocusReason.OtherFocusReason) - self.__helpStack.addWidget(viewer) - self.__openPagesList.addPage(viewer, background=background) - viewer.setFocus(Qt.FocusReason.OtherFocusReason) + return viewer @pyqtSlot(QUrl) def openUrl(self, url): @@ -433,7 +438,7 @@ """ cv = self.currentViewer() if cv: - cv.setUrl(url) + cv.setLink(url) cv.setFocus(Qt.FocusReason.OtherFocusReason) @pyqtSlot(QUrl) @@ -457,6 +462,27 @@ self.addPage(url=url, background=True) @pyqtSlot() + def closeCurrentPage(self): + """ + Public slot to close the current page. + """ + self.__openPagesList.closeCurrentPage() + + @pyqtSlot() + def closeOtherPages(self): + """ + Public slot to close all other pages. + """ + self.__openPagesList.closeOtherPages() + + @pyqtSlot() + def closeAllPages(self): + """ + Public slot to close all pages. + """ + self.__openPagesList.closeAllPages() + + @pyqtSlot() def __activateCurrentPage(self): """ Private slot to activate the current page. @@ -473,11 +499,11 @@ @rtype HelpViewerImpl """ if WEBENGINE_AVAILABLE: - from .HelpViewerImpl_qwe import HelpViewerImpl_qwe - viewer = HelpViewerImpl_qwe(self.__helpEngine, self) + from .HelpViewerImplQWE import HelpViewerImplQWE + viewer = HelpViewerImplQWE(self.__helpEngine, self) else: - from .HelpViewerImpl_qtb import HelpViewerImpl_qtb - viewer = HelpViewerImpl_qtb(self.__helpEngine, self) + from .HelpViewerImplQTB import HelpViewerImplQTB + viewer = HelpViewerImplQTB(self.__helpEngine, self) viewer.zoomChanged.connect(self.__checkActionButtons) @@ -511,7 +537,7 @@ self.__helpEngine.setupData() self.__removeOldDocumentation() - def __getQtHelpCollectionFileName(cls): + def __getQtHelpCollectionFileName(self): """ Private method to determine the name of the QtHelp collection file. @@ -906,14 +932,14 @@ self.__helpEngine.filterEngine().setActiveFilter(helpFilter) @pyqtSlot(str) - def __currentFilterChanged(self, filter): + def __currentFilterChanged(self, filter_): """ Private slot handling a change of the active QtHelp filter. - @param filter filter name + @param filter_ filter name @type str """ - index = self.__helpFilterCombo.findData(filter) + index = self.__helpFilterCombo.findData(filter_) if index < 0: index = 0 self.__helpFilterCombo.setCurrentIndex(index)