142 @pyqtSlot(bool) |
143 @pyqtSlot(bool) |
143 def on_jsCheckBox_clicked(self, checked): |
144 def on_jsCheckBox_clicked(self, checked): |
144 """ |
145 """ |
145 Private slot to enable/disable JavaScript. |
146 Private slot to enable/disable JavaScript. |
146 |
147 |
147 @param checked state of the checkbox (boolean) |
148 @param checked state of the checkbox |
|
149 @type bool |
148 """ |
150 """ |
149 Preferences.setUI("ShowFilePreviewJS", checked) |
151 Preferences.setUI("ShowFilePreviewJS", checked) |
150 self.__setJavaScriptEnabled(checked) |
152 self.__setJavaScriptEnabled(checked) |
151 |
153 |
152 def __setJavaScriptEnabled(self, enable): |
154 def __setJavaScriptEnabled(self, enable): |
153 """ |
155 """ |
154 Private method to enable/disable JavaScript. |
156 Private method to enable/disable JavaScript. |
155 |
157 |
156 @param enable flag indicating the enable state (boolean) |
158 @param enable flag indicating the enable state |
|
159 @type bool |
157 """ |
160 """ |
158 self.jsCheckBox.setChecked(enable) |
161 self.jsCheckBox.setChecked(enable) |
159 |
162 |
160 settings = self.previewView.settings() |
163 settings = self.previewView.settings() |
161 settings.setAttribute(settings.WebAttribute.JavascriptEnabled, enable) |
164 settings.setAttribute(settings.WebAttribute.JavascriptEnabled, enable) |
165 @pyqtSlot(bool) |
168 @pyqtSlot(bool) |
166 def on_ssiCheckBox_clicked(self, checked): |
169 def on_ssiCheckBox_clicked(self, checked): |
167 """ |
170 """ |
168 Private slot to enable/disable SSI. |
171 Private slot to enable/disable SSI. |
169 |
172 |
170 @param checked state of the checkbox (boolean) |
173 @param checked state of the checkbox |
|
174 @type bool |
171 """ |
175 """ |
172 Preferences.setUI("ShowFilePreviewSSI", checked) |
176 Preferences.setUI("ShowFilePreviewSSI", checked) |
173 self.processEditor() |
177 self.processEditor() |
174 |
178 |
175 @pyqtSlot(str) |
179 @pyqtSlot(str) |
276 @pyqtSlot(str) |
281 @pyqtSlot(str) |
277 def on_previewView_titleChanged(self, title): |
282 def on_previewView_titleChanged(self, title): |
278 """ |
283 """ |
279 Private slot to handle a change of the title. |
284 Private slot to handle a change of the title. |
280 |
285 |
281 @param title new title (string) |
286 @param title new title |
|
287 @type str |
282 """ |
288 """ |
283 if title: |
289 if title: |
284 self.titleLabel.setText(self.tr("Preview - {0}").format(title)) |
290 self.titleLabel.setText(self.tr("Preview - {0}").format(title)) |
285 else: |
291 else: |
286 self.titleLabel.setText(self.tr("Preview")) |
292 self.titleLabel.setText(self.tr("Preview")) |
529 """ |
536 """ |
530 Private method to process the given text for SSI statements. |
537 Private method to process the given text for SSI statements. |
531 |
538 |
532 Note: Only a limited subset of SSI statements are supported. |
539 Note: Only a limited subset of SSI statements are supported. |
533 |
540 |
534 @param txt text to be processed (string) |
541 @param txt text to be processed |
|
542 @type str |
535 @param filename name of the file associated with the given text |
543 @param filename name of the file associated with the given text |
536 (string) |
544 @type str |
537 @param root directory of the document root (string) |
545 @param root directory of the document root |
538 @return processed HTML (string) |
546 @type str |
|
547 @return processed HTML |
|
548 @rtype str |
539 """ |
549 """ |
540 if not filename: |
550 if not filename: |
541 return txt |
551 return txt |
542 |
552 |
543 # SSI include |
553 # SSI include |
613 |
623 |
614 def __convertReST(self, text, useSphinx, restDocutilsHtmlFormat): |
624 def __convertReST(self, text, useSphinx, restDocutilsHtmlFormat): |
615 """ |
625 """ |
616 Private method to convert ReST text into HTML. |
626 Private method to convert ReST text into HTML. |
617 |
627 |
618 @param text text to be processed (string) |
628 @param text text to be processed |
|
629 @type str |
619 @param useSphinx flag indicating to use Sphinx to generate the |
630 @param useSphinx flag indicating to use Sphinx to generate the |
620 ReST preview (boolean) |
631 ReST preview |
|
632 @type bool |
621 @param restDocutilsHtmlFormat HTML format to be generated by docutils |
633 @param restDocutilsHtmlFormat HTML format to be generated by docutils |
622 (string) |
634 @type str |
623 @return processed HTML (string) |
635 @return processed HTML |
|
636 @rtype str |
624 """ |
637 """ |
625 if useSphinx: |
638 if useSphinx: |
626 return self.__convertReSTSphinx(text) |
639 return self.__convertReSTSphinx(text) |
627 else: |
640 else: |
628 return self.__convertReSTDocutils(text, restDocutilsHtmlFormat) |
641 return self.__convertReSTDocutils(text, restDocutilsHtmlFormat) |
629 |
642 |
630 def __convertReSTSphinx(self, text): |
643 def __convertReSTSphinx(self, text): |
631 """ |
644 """ |
632 Private method to convert ReST text into HTML using 'sphinx'. |
645 Private method to convert ReST text into HTML using 'sphinx'. |
633 |
646 |
634 @param text text to be processed (string) |
647 @param text text to be processed |
635 @return processed HTML (string) |
648 @type str |
|
649 @return processed HTML |
|
650 @rtype str |
636 """ |
651 """ |
637 try: |
652 try: |
638 from sphinx.application import ( # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ |
653 from sphinx.application import ( # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ |
639 Sphinx, |
654 Sphinx, |
640 ) |
655 ) |
691 |
706 |
692 def __convertReSTDocutils(self, text, htmlFormat): |
707 def __convertReSTDocutils(self, text, htmlFormat): |
693 """ |
708 """ |
694 Private method to convert ReST text into HTML using 'docutils'. |
709 Private method to convert ReST text into HTML using 'docutils'. |
695 |
710 |
696 @param text text to be processed (string) |
711 @param text text to be processed |
697 @param htmlFormat HTML format to be generated (string) |
712 @type str |
698 @return processed HTML (string) |
713 @param htmlFormat HTML format to be generated |
|
714 @type str |
|
715 @return processed HTML |
|
716 @rtype str |
699 """ |
717 """ |
700 if "sphinx" in sys.modules: |
718 if "sphinx" in sys.modules: |
701 # Make sure any Sphinx polution of docutils has been removed. |
719 # Make sure any Sphinx polution of docutils has been removed. |
702 unloadKeys = [ |
720 unloadKeys = [ |
703 k for k in sys.modules if k.startswith(("docutils", "sphinx")) |
721 k for k in sys.modules if k.startswith(("docutils", "sphinx")) |