From e51e6bf1ae9392f0f82c1416a708c002417cfd83 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 12 Jun 2025 09:46:26 +0200 Subject: [PATCH] =?UTF-8?q?Optimizaci=C3=B3n=20del=20launcher=20de=20la=20?= =?UTF-8?q?calculadora=20MAV=20eliminando=20verificaciones=20de=20dependen?= =?UTF-8?q?cias=20y=20WebEngine=20al=20inicio.=20Se=20mejora=20la=20gesti?= =?UTF-8?q?=C3=B3n=20del=20panel=20LaTeX,=20asegurando=20que=20solo=20se?= =?UTF-8?q?=20actualice=20si=20est=C3=A1=20visible.=20Se=20implementa=20in?= =?UTF-8?q?icializaci=C3=B3n=20perezosa=20para=20WebEngine=20y=20se=20ajus?= =?UTF-8?q?ta=20la=20configuraci=C3=B3n=20de=20MathJax=20para=20SVG,=20mej?= =?UTF-8?q?orando=20el=20rendimiento=20y=20la=20experiencia=20del=20usuari?= =?UTF-8?q?o.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui_evaluation.py | 11 ++++-- app/gui_latex.py | 86 +++++++++++++++++++++++++++++-------------- app/gui_main.py | 26 ++++++++++++- app/gui_settings.py | 2 +- calc.py | 66 +++------------------------------ 5 files changed, 96 insertions(+), 95 deletions(-) diff --git a/app/gui_evaluation.py b/app/gui_evaluation.py index a2aab35..ce5ba3c 100644 --- a/app/gui_evaluation.py +++ b/app/gui_evaluation.py @@ -70,9 +70,12 @@ class EvaluationManager: self.main_window.engine.variables.clear() self.logger.debug("Contexto del motor limpiado") - # Limpiar panel LaTeX solo cuando hay contenido nuevo para evaluar + # Limpiar ecuaciones LaTeX en memoria self._latex_equations.clear() - self.main_window.latex_panel.clear_equations() + + # Solo limpiar panel visual si está visible + if self.main_window.latex_panel_visible: + self.main_window.latex_panel.clear_equations() lines = input_content.splitlines() self._evaluate_lines(lines) @@ -213,7 +216,9 @@ class EvaluationManager: 'content': latex_content }) - self.main_window.latex_panel.add_equation(equation_type, latex_content) + # Solo actualizar el panel si está visible/activo + if self.main_window.latex_panel_visible: + self.main_window.latex_panel.add_equation(equation_type, latex_content) # Actualizar indicador visual self._update_latex_indicator() diff --git a/app/gui_latex.py b/app/gui_latex.py index 07fbc4e..b8eb2bc 100644 --- a/app/gui_latex.py +++ b/app/gui_latex.py @@ -23,12 +23,11 @@ class LatexPanel(QWidget): self._mathjax_ready = False self._pending_equations = [] self._parent_calculator = parent + self._webview_initialized = False self._setup_ui() - # Timer para verificar si MathJax está listo - self._mathjax_check_timer = QTimer() - self._mathjax_check_timer.timeout.connect(self._check_mathjax_ready) - self._mathjax_check_timer.start(500) # Verificar cada 500ms + # Timer para verificar si MathJax está listo (inicializado bajo demanda) + self._mathjax_check_timer = None def _setup_ui(self): """Configura la UI del panel""" @@ -67,9 +66,9 @@ class LatexPanel(QWidget): self._webview_available = False def _setup_webview(self): - """Configura WebEngineView con MathJax""" - html_content = self._generate_mathjax_html() - self.webview.setHtml(html_content) + """Configura WebEngineView con MathJax (inicialización perezosa)""" + # No cargar HTML inmediatamente para optimizar tiempo de inicio + pass def _setup_text_browser(self): """Configura el browser de texto como fallback""" @@ -108,14 +107,14 @@ class LatexPanel(QWidget): """) def _generate_mathjax_html(self): - """Genera HTML base con MathJax""" + """Genera HTML base con MathJax configurado para SVG""" return """ - +