eric6/QScintilla/Exporters/ExporterTEX.py

changeset 7771
787a6b3f8c9f
parent 7360
9190402e4505
child 7781
607a6098cb44
diff -r 49f3377aebf1 -r 787a6b3f8c9f eric6/QScintilla/Exporters/ExporterTEX.py
--- a/eric6/QScintilla/Exporters/ExporterTEX.py	Fri Oct 09 17:19:29 2020 +0200
+++ b/eric6/QScintilla/Exporters/ExporterTEX.py	Sat Oct 10 12:20:51 2020 +0200
@@ -13,12 +13,10 @@
 
 import os
 
-from PyQt5.QtCore import Qt
-from PyQt5.QtGui import QCursor
-from PyQt5.QtWidgets import QApplication
 from PyQt5.Qsci import QsciScintilla
 
 from E5Gui import E5MessageBox
+from E5Gui.E5OverrideCursor import E5OverrideCursor
 
 from .ExporterBase import ExporterBase
 
@@ -115,54 +113,51 @@
         if not filename:
             return
         
+        self.editor.recolor(0, -1)
+        
+        tabSize = self.editor.getEditorConfig("TabWidth")
+        if tabSize == 0:
+            tabSize = 4
+        
+        onlyStylesUsed = Preferences.getEditorExporter(
+            "TeX/OnlyStylesUsed")
+        titleFullPath = Preferences.getEditorExporter(
+            "TeX/FullPathAsTitle")
+        
+        lex = self.editor.getLexer()
+        self.defaultPaper = (
+            lex and
+            lex.paper(QsciScintilla.STYLE_DEFAULT) or
+            self.editor.paper().name()
+        )
+        self.defaultColor = (
+            lex and
+            lex.color(QsciScintilla.STYLE_DEFAULT) or
+            self.editor.color().name()
+        )
+        self.defaultFont = (
+            lex and
+            lex.color(QsciScintilla.STYLE_DEFAULT) or
+            Preferences.getEditorOtherFonts("DefaultFont")
+        )
+        
+        lengthDoc = self.editor.length()
+        styleIsUsed = {}
+        if onlyStylesUsed:
+            for index in range(QsciScintilla.STYLE_MAX + 1):
+                styleIsUsed[index] = False
+            # check the used styles
+            pos = 0
+            while pos < lengthDoc:
+                styleIsUsed[self.editor.styleAt(pos) & 0x7F] = True
+                pos += 1
+        else:
+            for index in range(QsciScintilla.STYLE_MAX + 1):
+                styleIsUsed[index] = True
+        styleIsUsed[QsciScintilla.STYLE_DEFAULT] = True
+        
         try:
-            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
-            QApplication.processEvents()
-            
-            self.editor.recolor(0, -1)
-            
-            tabSize = self.editor.getEditorConfig("TabWidth")
-            if tabSize == 0:
-                tabSize = 4
-            
-            onlyStylesUsed = Preferences.getEditorExporter(
-                "TeX/OnlyStylesUsed")
-            titleFullPath = Preferences.getEditorExporter(
-                "TeX/FullPathAsTitle")
-            
-            lex = self.editor.getLexer()
-            self.defaultPaper = (
-                lex and
-                lex.paper(QsciScintilla.STYLE_DEFAULT) or
-                self.editor.paper().name()
-            )
-            self.defaultColor = (
-                lex and
-                lex.color(QsciScintilla.STYLE_DEFAULT) or
-                self.editor.color().name()
-            )
-            self.defaultFont = (
-                lex and
-                lex.color(QsciScintilla.STYLE_DEFAULT) or
-                Preferences.getEditorOtherFonts("DefaultFont")
-            )
-            
-            lengthDoc = self.editor.length()
-            styleIsUsed = {}
-            if onlyStylesUsed:
-                for index in range(QsciScintilla.STYLE_MAX + 1):
-                    styleIsUsed[index] = False
-                # check the used styles
-                pos = 0
-                while pos < lengthDoc:
-                    styleIsUsed[self.editor.styleAt(pos) & 0x7F] = True
-                    pos += 1
-            else:
-                for index in range(QsciScintilla.STYLE_MAX + 1):
-                    styleIsUsed[index] = True
-            styleIsUsed[QsciScintilla.STYLE_DEFAULT] = True
-            
-            try:
+            with E5OverrideCursor():
                 f = open(filename, "w", encoding="utf-8")
                 
                 f.write("\\documentclass[a4paper]{article}\n")
@@ -279,14 +274,11 @@
                 # close last empty style macros and document too
                 f.write("}\n} %end tiny\n\n\\end{document}\n")
                 f.close()
-            except IOError as err:
-                QApplication.restoreOverrideCursor()
-                E5MessageBox.critical(
-                    self.editor,
-                    self.tr("Export source"),
-                    self.tr(
-                        """<p>The source could not be exported to"""
-                        """ <b>{0}</b>.</p><p>Reason: {1}</p>""")
-                    .format(filename, str(err)))
-        finally:
-            QApplication.restoreOverrideCursor()
+        except IOError as err:
+            E5MessageBox.critical(
+                self.editor,
+                self.tr("Export source"),
+                self.tr(
+                    """<p>The source could not be exported to"""
+                    """ <b>{0}</b>.</p><p>Reason: {1}</p>""")
+                .format(filename, str(err)))

eric ide

mercurial