eric7/HelpViewer/HelpViewerWidget.py

branch
eric7
changeset 8686
af2ee3a303ac
parent 8685
b0669ce1066d
child 8693
d51660d6f1b9
equal deleted inserted replaced
8685:b0669ce1066d 8686:af2ee3a303ac
203 ################################################################### 203 ###################################################################
204 204
205 self.setLayout(self.__layout) 205 self.setLayout(self.__layout)
206 206
207 self.__openPagesButton.setChecked(True) 207 self.__openPagesButton.setChecked(True)
208
209 self.__initHelpEngine()
210 208
211 self.__ui.preferencesChanged.connect(self.__populateHelpSelector) 209 self.__ui.preferencesChanged.connect(self.__populateHelpSelector)
212 210
213 self.__initActionsMenu() 211 self.__initActionsMenu()
214 212
480 self.__helpEngine = QHelpEngine( 478 self.__helpEngine = QHelpEngine(
481 self.__getQtHelpCollectionFileName(), 479 self.__getQtHelpCollectionFileName(),
482 self) 480 self)
483 self.__helpEngine.setReadOnly(False) 481 self.__helpEngine.setReadOnly(False)
484 self.__helpEngine.setUsesFilterEngine(True) 482 self.__helpEngine.setUsesFilterEngine(True)
483
484 self.__helpEngine.warning.connect(self.__warning)
485
485 self.__helpEngine.setupData() 486 self.__helpEngine.setupData()
486 self.__removeOldDocumentation() 487 self.__removeOldDocumentation()
487 self.__helpEngine.warning.connect(self.__warning)
488 488
489 def __getQtHelpCollectionFileName(cls): 489 def __getQtHelpCollectionFileName(cls):
490 """ 490 """
491 Private method to determine the name of the QtHelp collection file. 491 Private method to determine the name of the QtHelp collection file.
492 492
559 @type bool 559 @type bool
560 """ 560 """
561 self.__ui.statusBar().clearMessage() 561 self.__ui.statusBar().clearMessage()
562 self.__helpEngine.setupData() 562 self.__helpEngine.setupData()
563 563
564 #######################################################################
565 ## Actions Menu related methods
566 #######################################################################
567
568 def __initActionsMenu(self):
569 """
570 Private method to initialize the actions menu.
571 """
572 self.__actionsMenu = QMenu()
573 self.__actionsMenu.setToolTipsVisible(True)
574
575 self.__actionsMenu.addAction(
576 self.tr("Manage QtHelp Documents"),
577 self.__manageQtHelpDocuments)
578 self.__actionsMenu.addAction(
579 self.tr("Reindex Documentation"),
580 self.__helpSearchEngine.reindexDocumentation)
581
582 self.__actionsButton.setMenu(self.__actionsMenu)
583
564 @pyqtSlot() 584 @pyqtSlot()
565 def __manageQtHelpDocuments(self): 585 def __manageQtHelpDocuments(self):
566 """ 586 """
567 Private slot to manage the QtHelp documentation database. 587 Private slot to manage the QtHelp documentation database.
568 """ 588 """
570 QtHelpDocumentationConfigurationDialog 590 QtHelpDocumentationConfigurationDialog
571 ) 591 )
572 dlg = QtHelpDocumentationConfigurationDialog( 592 dlg = QtHelpDocumentationConfigurationDialog(
573 self.__helpEngine, self) 593 self.__helpEngine, self)
574 dlg.exec() 594 dlg.exec()
575
576 @pyqtSlot()
577 def __reindexDocumentation(self):
578 """
579 Private slot
580 """
581
582 #######################################################################
583 ## Actions Menu related methods
584 #######################################################################
585
586 def __initActionsMenu(self):
587 """
588 Private method to initialize the actions menu.
589 """
590 self.__actionsMenu = QMenu()
591 self.__actionsMenu.setToolTipsVisible(True)
592
593 self.__actionsMenu.addAction(self.tr("Manage QtHelp Documents"),
594 self.__manageQtHelpDocuments)
595 act = self.__actionsMenu.addAction(self.tr("Reindex Documentation"),
596 self.__reindexDocumentation)
597 act.triggered.connect(self.__helpSearchEngine.reindexDocumentation)
598
599 self.__actionsButton.setMenu(self.__actionsMenu)
600 595
601 ####################################################################### 596 #######################################################################
602 ## Navigation related methods below 597 ## Navigation related methods below
603 ####################################################################### 598 #######################################################################
604 599
823 comboWidth = QFontMetrics(QFont()).horizontalAdvance( 818 comboWidth = QFontMetrics(QFont()).horizontalAdvance(
824 "ComboBoxWithEnoughWidth") 819 "ComboBoxWithEnoughWidth")
825 self.__helpFilterCombo.setMinimumWidth(comboWidth) 820 self.__helpFilterCombo.setMinimumWidth(comboWidth)
826 layout.addWidget(self.__helpFilterCombo) 821 layout.addWidget(self.__helpFilterCombo)
827 822
828 self.__helpEngine.setupFinished.connect(self.__setupFilterCombo) 823 self.__helpEngine.setupFinished.connect(
824 self.__setupFilterCombo, Qt.ConnectionType.QueuedConnection)
829 self.__helpFilterCombo.currentIndexChanged.connect( 825 self.__helpFilterCombo.currentIndexChanged.connect(
830 self.__filterQtHelpDocumentation) 826 self.__filterQtHelpDocumentation)
827 self.__helpEngine.filterEngine().filterActivated.connect(
828 self.__currentFilterChanged)
831 829
832 self.__setupFilterCombo() 830 self.__setupFilterCombo()
833 831
834 return filterWidget 832 return filterWidget
835 833
865 @type int 863 @type int
866 """ 864 """
867 if self.__helpEngine: 865 if self.__helpEngine:
868 helpFilter = self.__helpFilterCombo.itemData(index) 866 helpFilter = self.__helpFilterCombo.itemData(index)
869 self.__helpEngine.filterEngine().setActiveFilter(helpFilter) 867 self.__helpEngine.filterEngine().setActiveFilter(helpFilter)
868
869 @pyqtSlot(str)
870 def __currentFilterChanged(self, filter):
871 """
872 Private slot handling a change of the active QtHelp filter.
873
874 @param filter filter name
875 @type str
876 """
877 index = self.__helpFilterCombo.findData(filter)
878 if index < 0:
879 index = 0
880 self.__helpFilterCombo.setCurrentIndex(index)

eric ide

mercurial