267 self.__plainTextViewer = PlainTextDocumentationViewer(self) |
267 self.__plainTextViewer = PlainTextDocumentationViewer(self) |
268 self.__plainTextViewer.setObjectName("__plainTextViewer") |
268 self.__plainTextViewer.setObjectName("__plainTextViewer") |
269 self.verticalLayout.addWidget(self.__plainTextViewer) |
269 self.verticalLayout.addWidget(self.__plainTextViewer) |
270 |
270 |
271 # Rich Text (Web) Viewer |
271 # Rich Text (Web) Viewer |
272 self.__richTextViewer = WebViewDocumentationViewer(self) |
272 try: |
273 self.__richTextViewer.setObjectName("__richTextViewer") |
273 self.__richTextViewer = WebViewDocumentationViewer(self) |
274 self.verticalLayout.addWidget(self.__richTextViewer) |
274 self.__richTextViewer.setObjectName("__richTextViewer") |
|
275 self.verticalLayout.addWidget(self.__richTextViewer) |
|
276 except ImportError: |
|
277 # neither QtWebEngineWidgets nor QtWebKitWidgets is available |
|
278 self.__richTextViewer = None |
275 |
279 |
276 self.__toolButton = E5ToolButton(self) |
280 self.__toolButton = E5ToolButton(self) |
277 self.__toolButton.setObjectName( |
281 self.__toolButton.setObjectName( |
278 "navigation_supermenu_button") |
282 "navigation_supermenu_button") |
279 self.__toolButton.setIcon(UI.PixmapCache.getIcon("superMenu.png")) |
283 self.__toolButton.setIcon(UI.PixmapCache.getIcon("superMenu.png")) |
285 self.__toolButton.setShowMenuInside(True) |
289 self.__toolButton.setShowMenuInside(True) |
286 |
290 |
287 self.__optionsActionGroup = QActionGroup(self) |
291 self.__optionsActionGroup = QActionGroup(self) |
288 self.__optionsActionGroup.setExclusive(True) |
292 self.__optionsActionGroup.setExclusive(True) |
289 self.__optionsMenu = QMenu(self) |
293 self.__optionsMenu = QMenu(self) |
290 self.__richTextAct = self.__optionsMenu.addAction( |
294 if self.__richTextViewer: |
291 self.tr("Rich Text"), |
295 self.__richTextAct = self.__optionsMenu.addAction( |
292 lambda: self.__showTextViewer(True)) |
296 self.tr("Rich Text"), |
293 self.__richTextAct.setCheckable(True) |
297 lambda: self.__showTextViewer(True)) |
294 self.__optionsActionGroup.addAction(self.__richTextAct) |
298 self.__richTextAct.setCheckable(True) |
|
299 self.__optionsActionGroup.addAction(self.__richTextAct) |
|
300 else: |
|
301 # neither QtWebEngineWidgets nor QtWebKitWidgets is available |
|
302 self.__richTextAct = None |
295 self.__plainTextAct = self.__optionsMenu.addAction( |
303 self.__plainTextAct = self.__optionsMenu.addAction( |
296 self.tr("Plain Text"), |
304 self.tr("Plain Text"), |
297 lambda: self.__showTextViewer(False)) |
305 lambda: self.__showTextViewer(False)) |
298 self.__plainTextAct.setCheckable(True) |
306 self.__plainTextAct.setCheckable(True) |
299 self.__optionsActionGroup.addAction(self.__plainTextAct) |
307 self.__optionsActionGroup.addAction(self.__plainTextAct) |
431 word = editor.getWord(line, index - 1) |
439 word = editor.getWord(line, index - 1) |
432 self.objectLineEdit.setText(word) |
440 self.objectLineEdit.setText(word) |
433 |
441 |
434 if self.__selectedProvider != self.__disabledProvider: |
442 if self.__selectedProvider != self.__disabledProvider: |
435 self.__plainTextViewer.clear() |
443 self.__plainTextViewer.clear() |
436 self.__richTextViewer.clear() |
444 if self.__richTextViewer: |
|
445 self.__richTextViewer.clear() |
437 self.__providers[self.__selectedProvider][0](editor) |
446 self.__providers[self.__selectedProvider][0](editor) |
438 |
447 |
439 def documentationReady(self, documentationInfo, isWarning=False, |
448 def documentationReady(self, documentationInfo, isWarning=False, |
440 isDocWarning=False): |
449 isDocWarning=False): |
441 """ |
450 """ |
554 Private slot to set the prepared HTML text. |
563 Private slot to set the prepared HTML text. |
555 |
564 |
556 @param html prepared HTML text |
565 @param html prepared HTML text |
557 @type str |
566 @type str |
558 """ |
567 """ |
559 self.__richTextViewer.setHtml(html) |
568 if self.__richTextViewer: |
|
569 self.__richTextViewer.setHtml(html) |
560 |
570 |
561 def __setHtmlWarning(self, warningText): |
571 def __setHtmlWarning(self, warningText): |
562 """ |
572 """ |
563 Private slot to set a display message. |
573 Private slot to set a display message. |
564 |
574 |
565 @param warningText text to be shown as a warning |
575 @param warningText text to be shown as a warning |
566 @type str |
576 @type str |
567 """ |
577 """ |
568 html = prepareDocumentationViewerHtmlWarningDocument(warningText) |
578 if self.__richTextViewer: |
569 self.__richTextViewer.setHtml(html) |
579 html = prepareDocumentationViewerHtmlWarningDocument(warningText) |
|
580 self.__richTextViewer.setHtml(html) |
570 |
581 |
571 @pyqtSlot(int) |
582 @pyqtSlot(int) |
572 def on_providerComboBox_currentIndexChanged(self, index): |
583 def on_providerComboBox_currentIndexChanged(self, index): |
573 """ |
584 """ |
574 Private slot to handle the selection of a provider. |
585 Private slot to handle the selection of a provider. |
576 @param index index of the selected provider |
587 @param index index of the selected provider |
577 @type int |
588 @type int |
578 """ |
589 """ |
579 if not self.__shuttingDown and not self.__startingUp: |
590 if not self.__shuttingDown and not self.__startingUp: |
580 self.__plainTextViewer.clear() |
591 self.__plainTextViewer.clear() |
581 self.__richTextViewer.clear() |
592 if self.__richTextViewer: |
|
593 self.__richTextViewer.clear() |
582 self.objectLineEdit.clear() |
594 self.objectLineEdit.clear() |
583 |
595 |
584 provider = self.providerComboBox.itemData(index) |
596 provider = self.providerComboBox.itemData(index) |
585 if provider == self.__disabledProvider: |
597 if provider == self.__disabledProvider: |
586 self.__showDisabledMessage() |
598 self.__showDisabledMessage() |
629 @type bool |
641 @type bool |
630 """ |
642 """ |
631 self.__showMarkdown = richText |
643 self.__showMarkdown = richText |
632 |
644 |
633 self.__plainTextViewer.clear() |
645 self.__plainTextViewer.clear() |
634 self.__richTextViewer.clear() |
|
635 |
|
636 self.__plainTextViewer.setVisible(not richText) |
646 self.__plainTextViewer.setVisible(not richText) |
637 self.__richTextViewer.setVisible(richText) |
647 |
|
648 if self.__richTextViewer: |
|
649 self.__richTextViewer.clear() |
|
650 self.__richTextViewer.setVisible(richText) |
638 |
651 |
639 self.__plainTextAct.setChecked(not richText) |
652 self.__plainTextAct.setChecked(not richText) |
640 self.__richTextAct.setChecked(richText) |
653 if self.__richTextAct: |
|
654 self.__richTextAct.setChecked(richText) |
641 |
655 |
642 self.documentationReady(self.__lastDocumentation) |
656 self.documentationReady(self.__lastDocumentation) |
643 |
657 |
644 Preferences.setDocuViewer("ShowInfoAsRichText", richText) |
658 Preferences.setDocuViewer("ShowInfoAsRichText", richText) |