--- a/UI/CodeDocumentationViewer.py Sat Oct 21 15:13:56 2017 +0200 +++ b/UI/CodeDocumentationViewer.py Sat Oct 21 15:18:15 2017 +0200 @@ -24,6 +24,7 @@ from .CodeDocumentationViewerTemplate import \ prepareDocumentationViewerHtmlDocument, \ + prepareDocumentationViewerHtmlDocWarningDocument, \ prepareDocumentationViewerHtmlWarningDocument from .data import codeDocumentationViewer_rc # __IGNORE_WARNING__ @@ -213,6 +214,7 @@ self.__processingThread = DocumentProcessingThread() self.__processingThread.htmlReady.connect(self.__setHtml) + self.__processingThread.warning.connect(self.__setHtmlWarning) def __setupUi(self): """ @@ -299,7 +301,7 @@ """ Public method to finalize the setup of the documentation viewer. """ - self.__showTextViewer(Preferences.getDocuViewer("ShowInfoAsMarkdown")) + self.__showTextViewer(Preferences.getDocuViewer("ShowInfoAsRichText")) self.__startingUp = False provider = Preferences.getDocuViewer("Provider") @@ -408,7 +410,8 @@ self.__providers[self.__selectedProvider][0](editor) # TODO: document this hook in the plug-in document - def documentationReady(self, documentationInfo, isWarning=False): + def documentationReady(self, documentationInfo, isWarning=False, + isDocWarning=False): """ Public method to provide the documentation info to the viewer. @@ -425,6 +428,8 @@ @type dict or str @param isWarning flag indicating a warning page @type bool + @param isDocWarning flag indicating a documentation warning page + @type bool """ self.__ui.activateCodeDocumentationViewer(switchFocus=False) @@ -437,13 +442,16 @@ isWarning=True) else: self.documentationReady(self.__noDocumentationString, - isWarning=True) + isDocWarning=True) return if self.__showMarkdown: if isWarning: html = prepareDocumentationViewerHtmlWarningDocument( documentationInfo) + elif isDocWarning: + html = prepareDocumentationViewerHtmlDocWarningDocument( + documentationInfo) elif isinstance(documentationInfo, dict): html = prepareDocumentationViewerHtmlDocument( documentationInfo) @@ -496,6 +504,16 @@ """ self.__richTextViewer.setHtml(html) + def __setHtmlWarning(self, warningText): + """ + Private slot to set a display message. + + @param warningText text to be shown as a warning + @type str + """ + html = prepareDocumentationViewerHtmlWarningDocument(warningText) + self.__richTextViewer.setHtml(html) + @pyqtSlot(int) def on_providerComboBox_currentIndexChanged(self, index): """ @@ -529,7 +547,7 @@ """ Public slot to handle a change of preferences. """ - showMarkdown = Preferences.getDocuViewer("ShowInfoAsMarkdown") + showMarkdown = Preferences.getDocuViewer("ShowInfoAsRichText") if showMarkdown != self.__showMarkdown: self.__showTextViewer(showMarkdown) @@ -560,7 +578,7 @@ self.documentationReady(self.__lastDocumentation) - Preferences.setDocuViewer("ShowInfoAsMarkdown", richText) + Preferences.setDocuViewer("ShowInfoAsRichText", richText) class DocumentProcessingThread(QThread): @@ -570,8 +588,10 @@ @signal htmlReady(str) emitted with the processed HTML to signal the availability of the processed HTML + @signal warning(str) emitted with an error or warning message """ htmlReady = pyqtSignal(str) + warning = pyqtSignal(str) def __init__(self, parent=None): """ @@ -604,12 +624,11 @@ if language == "markdown": html = self.__convertMarkdown(text, True, "html5") + self.htmlReady.emit(html) else: - html = "<html><body><p>" - html += self.tr("Format '{0}' is not supported.").format(language) - html += "</p></body></html>" - - self.htmlReady.emit(html) + html = self.tr("Format <b>{0}</b> is not supported.")\ + .format(language) + self.warning.emit(html) def __convertMarkdown(self, text, convertNewLineToBreak, htmlFormat): """