261 self.__plainTextViewer = PlainTextDocumentationViewer(self) |
261 self.__plainTextViewer = PlainTextDocumentationViewer(self) |
262 self.__plainTextViewer.setObjectName("__plainTextViewer") |
262 self.__plainTextViewer.setObjectName("__plainTextViewer") |
263 self.verticalLayout.addWidget(self.__plainTextViewer) |
263 self.verticalLayout.addWidget(self.__plainTextViewer) |
264 |
264 |
265 # Rich Text (Web) Viewer |
265 # Rich Text (Web) Viewer |
266 try: |
266 self.__richTextViewer = WebViewDocumentationViewer(self) |
267 self.__richTextViewer = WebViewDocumentationViewer(self) |
267 self.__richTextViewer.setObjectName("__richTextViewer") |
268 self.__richTextViewer.setObjectName("__richTextViewer") |
268 self.verticalLayout.addWidget(self.__richTextViewer) |
269 self.verticalLayout.addWidget(self.__richTextViewer) |
|
270 except ImportError: |
|
271 self.__richTextViewer = None |
|
272 |
269 |
273 self.__toolButton = E5ToolButton(self) |
270 self.__toolButton = E5ToolButton(self) |
274 self.__toolButton.setObjectName( |
271 self.__toolButton.setObjectName( |
275 "navigation_supermenu_button") |
272 "navigation_supermenu_button") |
276 self.__toolButton.setIcon(UI.PixmapCache.getIcon("superMenu.png")) |
273 self.__toolButton.setIcon(UI.PixmapCache.getIcon("superMenu.png")) |
282 self.__toolButton.setShowMenuInside(True) |
279 self.__toolButton.setShowMenuInside(True) |
283 |
280 |
284 self.__optionsActionGroup = QActionGroup(self) |
281 self.__optionsActionGroup = QActionGroup(self) |
285 self.__optionsActionGroup.setExclusive(True) |
282 self.__optionsActionGroup.setExclusive(True) |
286 self.__optionsMenu = QMenu(self) |
283 self.__optionsMenu = QMenu(self) |
287 if self.__richTextViewer: |
284 self.__richTextAct = self.__optionsMenu.addAction( |
288 self.__richTextAct = self.__optionsMenu.addAction( |
285 self.tr("Rich Text"), |
289 self.tr("Rich Text"), |
286 lambda: self.__showTextViewer(True)) |
290 lambda: self.__showTextViewer(True)) |
287 self.__richTextAct.setCheckable(True) |
291 self.__richTextAct.setCheckable(True) |
288 self.__optionsActionGroup.addAction(self.__richTextAct) |
292 self.__optionsActionGroup.addAction(self.__richTextAct) |
|
293 self.__plainTextAct = self.__optionsMenu.addAction( |
289 self.__plainTextAct = self.__optionsMenu.addAction( |
294 self.tr("Plain Text"), |
290 self.tr("Plain Text"), |
295 lambda: self.__showTextViewer(False)) |
291 lambda: self.__showTextViewer(False)) |
296 self.__plainTextAct.setCheckable(True) |
292 self.__plainTextAct.setCheckable(True) |
297 self.__optionsActionGroup.addAction(self.__plainTextAct) |
293 self.__optionsActionGroup.addAction(self.__plainTextAct) |
304 |
300 |
305 def finalizeSetup(self): |
301 def finalizeSetup(self): |
306 """ |
302 """ |
307 Public method to finalize the setup of the documentation viewer. |
303 Public method to finalize the setup of the documentation viewer. |
308 """ |
304 """ |
309 if self.__richTextViewer: |
305 self.__showTextViewer( |
310 self.__showTextViewer( |
306 Preferences.getDocuViewer("ShowInfoAsRichText")) |
311 Preferences.getDocuViewer("ShowInfoAsRichText")) |
|
312 else: |
|
313 self.__showTextViewer(False) |
|
314 |
307 |
315 self.__startingUp = False |
308 self.__startingUp = False |
316 provider = Preferences.getDocuViewer("Provider") |
309 provider = Preferences.getDocuViewer("Provider") |
317 if provider in self.__providers: |
310 if provider in self.__providers: |
318 index = self.providerComboBox.findData(provider) |
311 index = self.providerComboBox.findData(provider) |
415 word = editor.getWord(line, index - 1) |
408 word = editor.getWord(line, index - 1) |
416 self.objectLineEdit.setText(word) |
409 self.objectLineEdit.setText(word) |
417 |
410 |
418 if self.__selectedProvider != self.__disabledProvider: |
411 if self.__selectedProvider != self.__disabledProvider: |
419 self.__plainTextViewer.clear() |
412 self.__plainTextViewer.clear() |
420 self.__richTextViewer and self.__richTextViewer.clear() |
413 self.__richTextViewer.clear() |
421 self.__providers[self.__selectedProvider][0](editor) |
414 self.__providers[self.__selectedProvider][0](editor) |
422 |
415 |
423 # TODO: document this hook in the plug-in document |
416 # TODO: document this hook in the plug-in document |
424 def documentationReady(self, documentationInfo, isWarning=False, |
417 def documentationReady(self, documentationInfo, isWarning=False, |
425 isDocWarning=False): |
418 isDocWarning=False): |
539 Private slot to set the prepared HTML text. |
532 Private slot to set the prepared HTML text. |
540 |
533 |
541 @param html prepared HTML text |
534 @param html prepared HTML text |
542 @type str |
535 @type str |
543 """ |
536 """ |
544 if self.__richTextViewer: |
537 self.__richTextViewer.setHtml(html) |
545 self.__richTextViewer.setHtml(html) |
|
546 |
538 |
547 def __setHtmlWarning(self, warningText): |
539 def __setHtmlWarning(self, warningText): |
548 """ |
540 """ |
549 Private slot to set a display message. |
541 Private slot to set a display message. |
550 |
542 |
551 @param warningText text to be shown as a warning |
543 @param warningText text to be shown as a warning |
552 @type str |
544 @type str |
553 """ |
545 """ |
554 if self.__richTextViewer: |
546 html = prepareDocumentationViewerHtmlWarningDocument(warningText) |
555 html = prepareDocumentationViewerHtmlWarningDocument(warningText) |
547 self.__richTextViewer.setHtml(html) |
556 self.__richTextViewer.setHtml(html) |
|
557 |
548 |
558 @pyqtSlot(int) |
549 @pyqtSlot(int) |
559 def on_providerComboBox_currentIndexChanged(self, index): |
550 def on_providerComboBox_currentIndexChanged(self, index): |
560 """ |
551 """ |
561 Private slot to handle the selection of a provider. |
552 Private slot to handle the selection of a provider. |
563 @param index index of the selected provider |
554 @param index index of the selected provider |
564 @type int |
555 @type int |
565 """ |
556 """ |
566 if not self.__shuttingDown and not self.__startingUp: |
557 if not self.__shuttingDown and not self.__startingUp: |
567 self.__plainTextViewer.clear() |
558 self.__plainTextViewer.clear() |
568 self.__richTextViewer and self.__richTextViewer.clear() |
559 self.__richTextViewer.clear() |
569 self.objectLineEdit.clear() |
560 self.objectLineEdit.clear() |
570 |
561 |
571 provider = self.providerComboBox.itemData(index) |
562 provider = self.providerComboBox.itemData(index) |
572 if provider == self.__disabledProvider: |
563 if provider == self.__disabledProvider: |
573 self.__showDisabledMessage() |
564 self.__showDisabledMessage() |
586 |
577 |
587 def preferencesChanged(self): |
578 def preferencesChanged(self): |
588 """ |
579 """ |
589 Public slot to handle a change of preferences. |
580 Public slot to handle a change of preferences. |
590 """ |
581 """ |
591 if self.__richTextViewer: |
582 showMarkdown = Preferences.getDocuViewer("ShowInfoAsRichText") |
592 showMarkdown = Preferences.getDocuViewer("ShowInfoAsRichText") |
583 if showMarkdown != self.__showMarkdown: |
593 if showMarkdown != self.__showMarkdown: |
584 self.__showTextViewer(showMarkdown) |
594 self.__showTextViewer(showMarkdown) |
|
595 else: |
|
596 self.__showTextViewer(False) |
|
597 |
585 |
598 provider = Preferences.getDocuViewer("Provider") |
586 provider = Preferences.getDocuViewer("Provider") |
599 if provider != self.__selectedProvider: |
587 if provider != self.__selectedProvider: |
600 index = self.providerComboBox.findData(provider) |
588 index = self.providerComboBox.findData(provider) |
601 if index < 0: |
589 if index < 0: |
610 @type bool |
598 @type bool |
611 """ |
599 """ |
612 self.__showMarkdown = richText |
600 self.__showMarkdown = richText |
613 |
601 |
614 self.__plainTextViewer.clear() |
602 self.__plainTextViewer.clear() |
615 self.__richTextViewer and self.__richTextViewer.clear() |
603 self.__richTextViewer.clear() |
616 |
604 |
617 self.__plainTextViewer.setVisible(not richText) |
605 self.__plainTextViewer.setVisible(not richText) |
618 self.__richTextViewer and self.__richTextViewer.setVisible(richText) |
606 self.__richTextViewer.setVisible(richText) |
619 |
607 |
620 self.__plainTextAct.setChecked(not richText) |
608 self.__plainTextAct.setChecked(not richText) |
621 self.__richTextViewer and self.__richTextAct.setChecked(richText) |
609 self.__richTextAct.setChecked(richText) |
622 |
610 |
623 self.documentationReady(self.__lastDocumentation) |
611 self.documentationReady(self.__lastDocumentation) |
624 |
612 |
625 Preferences.setDocuViewer("ShowInfoAsRichText", richText) |
613 Preferences.setDocuViewer("ShowInfoAsRichText", richText) |