200 self.__openPagesButton = self.__addNavigationButton( |
200 self.__openPagesButton = self.__addNavigationButton( |
201 "fileMisc", self.tr("Show list of open pages")) |
201 "fileMisc", self.tr("Show list of open pages")) |
202 self.__helpTocButton = self.__addNavigationButton( |
202 self.__helpTocButton = self.__addNavigationButton( |
203 "tableOfContents", self.tr("Show the table of contents")) |
203 "tableOfContents", self.tr("Show the table of contents")) |
204 self.__helpIndexButton = self.__addNavigationButton( |
204 self.__helpIndexButton = self.__addNavigationButton( |
205 "helpIndex", self.tr("Show the help document index")) |
205 "helpIndex", self.tr("Show the help document index")) |
206 self.__helpSearchButton = self.__addNavigationButton( |
206 self.__helpSearchButton = self.__addNavigationButton( |
207 "documentFind", self.tr("Show the help search window")) |
207 "documentFind", self.tr("Show the help search window")) |
208 self.__openPagesButton.setChecked(True) |
208 self.__openPagesButton.setChecked(True) |
209 |
209 |
210 self.__buttonLayout.addStretch() |
210 self.__buttonLayout.addStretch() |
392 self.tr("Open HTML File"), |
392 self.tr("Open HTML File"), |
393 "", |
393 "", |
394 self.tr("HTML Files (*.htm *.html);;All Files (*)") |
394 self.tr("HTML Files (*.htm *.html);;All Files (*)") |
395 ) |
395 ) |
396 if htmlFile: |
396 if htmlFile: |
397 self.currentViewer().setUrl(QUrl.fromLocalFile(htmlFile)) |
397 self.currentViewer().setLink(QUrl.fromLocalFile(htmlFile)) |
398 |
398 |
399 def addPage(self, url=QUrl("about:blank"), background=False): |
399 def addPage(self, url=None, background=False): |
400 """ |
400 """ |
401 Public method to add a new help page with the given URL. |
401 Public method to add a new help page with the given URL. |
402 |
402 |
403 @param url requested URL (defaults to QUrl("about:blank")) |
403 @param url requested URL (defaults to QUrl("about:blank")) |
404 @type QUrl (optional) |
404 @type QUrl (optional) |
405 @param background flag indicating to open the page in the background |
405 @param background flag indicating to open the page in the background |
406 (defaults to False) |
406 (defaults to False) |
407 @type bool (optional) |
407 @type bool (optional) |
408 """ |
408 @return reference to the created page |
|
409 @rtype HelpViewerImpl |
|
410 """ |
|
411 if url is None: |
|
412 url = QUrl("about:blank") |
|
413 |
409 viewer = self.__newViewer() |
414 viewer = self.__newViewer() |
410 viewer.setUrl(url) |
415 viewer.setUrl(url) |
411 |
416 |
412 if background: |
417 cv = self.currentViewer() |
413 cv = self.currentViewer() |
418 if background and bool(cv): |
414 if cv: |
419 index = self.__helpStack.indexOf(cv) + 1 |
415 index = self.__helpStack.indexOf(cv) + 1 |
420 self.__helpStack.insertWidget(index, viewer) |
416 self.__helpStack.insertWidget(index, viewer) |
421 self.__openPagesList.insertPage( |
417 self.__openPagesList.insertPage( |
422 index, viewer, background=background) |
418 index, viewer, background=background) |
423 cv.setFocus(Qt.FocusReason.OtherFocusReason) |
419 cv.setFocus(Qt.FocusReason.OtherFocusReason) |
424 else: |
420 return |
425 self.__helpStack.addWidget(viewer) |
421 |
426 self.__openPagesList.addPage(viewer, background=background) |
422 self.__helpStack.addWidget(viewer) |
427 viewer.setFocus(Qt.FocusReason.OtherFocusReason) |
423 self.__openPagesList.addPage(viewer, background=background) |
428 |
424 viewer.setFocus(Qt.FocusReason.OtherFocusReason) |
429 return viewer |
425 |
430 |
426 @pyqtSlot(QUrl) |
431 @pyqtSlot(QUrl) |
427 def openUrl(self, url): |
432 def openUrl(self, url): |
428 """ |
433 """ |
429 Public slot to load a URL in the current page. |
434 Public slot to load a URL in the current page. |
455 @type QUrl |
460 @type QUrl |
456 """ |
461 """ |
457 self.addPage(url=url, background=True) |
462 self.addPage(url=url, background=True) |
458 |
463 |
459 @pyqtSlot() |
464 @pyqtSlot() |
|
465 def closeCurrentPage(self): |
|
466 """ |
|
467 Public slot to close the current page. |
|
468 """ |
|
469 self.__openPagesList.closeCurrentPage() |
|
470 |
|
471 @pyqtSlot() |
|
472 def closeOtherPages(self): |
|
473 """ |
|
474 Public slot to close all other pages. |
|
475 """ |
|
476 self.__openPagesList.closeOtherPages() |
|
477 |
|
478 @pyqtSlot() |
|
479 def closeAllPages(self): |
|
480 """ |
|
481 Public slot to close all pages. |
|
482 """ |
|
483 self.__openPagesList.closeAllPages() |
|
484 |
|
485 @pyqtSlot() |
460 def __activateCurrentPage(self): |
486 def __activateCurrentPage(self): |
461 """ |
487 """ |
462 Private slot to activate the current page. |
488 Private slot to activate the current page. |
463 """ |
489 """ |
464 cv = self.currentViewer() |
490 cv = self.currentViewer() |
471 |
497 |
472 @return help viewer |
498 @return help viewer |
473 @rtype HelpViewerImpl |
499 @rtype HelpViewerImpl |
474 """ |
500 """ |
475 if WEBENGINE_AVAILABLE: |
501 if WEBENGINE_AVAILABLE: |
476 from .HelpViewerImpl_qwe import HelpViewerImpl_qwe |
502 from .HelpViewerImplQWE import HelpViewerImplQWE |
477 viewer = HelpViewerImpl_qwe(self.__helpEngine, self) |
503 viewer = HelpViewerImplQWE(self.__helpEngine, self) |
478 else: |
504 else: |
479 from .HelpViewerImpl_qtb import HelpViewerImpl_qtb |
505 from .HelpViewerImplQTB import HelpViewerImplQTB |
480 viewer = HelpViewerImpl_qtb(self.__helpEngine, self) |
506 viewer = HelpViewerImplQTB(self.__helpEngine, self) |
481 |
507 |
482 viewer.zoomChanged.connect(self.__checkActionButtons) |
508 viewer.zoomChanged.connect(self.__checkActionButtons) |
483 |
509 |
484 return viewer |
510 return viewer |
485 |
511 |
509 self.__helpEngine.warning.connect(self.__warning) |
535 self.__helpEngine.warning.connect(self.__warning) |
510 |
536 |
511 self.__helpEngine.setupData() |
537 self.__helpEngine.setupData() |
512 self.__removeOldDocumentation() |
538 self.__removeOldDocumentation() |
513 |
539 |
514 def __getQtHelpCollectionFileName(cls): |
540 def __getQtHelpCollectionFileName(self): |
515 """ |
541 """ |
516 Private method to determine the name of the QtHelp collection file. |
542 Private method to determine the name of the QtHelp collection file. |
517 |
543 |
518 @return path of the QtHelp collection file |
544 @return path of the QtHelp collection file |
519 @rtype str |
545 @rtype str |
904 if self.__helpEngine: |
930 if self.__helpEngine: |
905 helpFilter = self.__helpFilterCombo.itemData(index) |
931 helpFilter = self.__helpFilterCombo.itemData(index) |
906 self.__helpEngine.filterEngine().setActiveFilter(helpFilter) |
932 self.__helpEngine.filterEngine().setActiveFilter(helpFilter) |
907 |
933 |
908 @pyqtSlot(str) |
934 @pyqtSlot(str) |
909 def __currentFilterChanged(self, filter): |
935 def __currentFilterChanged(self, filter_): |
910 """ |
936 """ |
911 Private slot handling a change of the active QtHelp filter. |
937 Private slot handling a change of the active QtHelp filter. |
912 |
938 |
913 @param filter filter name |
939 @param filter_ filter name |
914 @type str |
940 @type str |
915 """ |
941 """ |
916 index = self.__helpFilterCombo.findData(filter) |
942 index = self.__helpFilterCombo.findData(filter_) |
917 if index < 0: |
943 if index < 0: |
918 index = 0 |
944 index = 0 |
919 self.__helpFilterCombo.setCurrentIndex(index) |
945 self.__helpFilterCombo.setCurrentIndex(index) |
920 |
946 |
921 ####################################################################### |
947 ####################################################################### |