Correctly refresh Engines list after downloading new engine

This commit is contained in:
Brett Williams
2025-12-27 22:53:50 -06:00
parent 9cf76e5a56
commit f22a51099a

View File

@@ -6,7 +6,7 @@ import socket
from datetime import datetime from datetime import datetime
from PyQt6 import QtCore from PyQt6 import QtCore
from PyQt6.QtCore import Qt, QSettings, pyqtSignal as Signal, QThread, pyqtSignal from PyQt6.QtCore import Qt, QSettings, pyqtSignal as Signal, QThread, pyqtSignal, QTimer
from PyQt6.QtGui import QIcon from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QApplication, QMainWindow, QListWidget, QListWidgetItem, QStackedWidget, QVBoxLayout, \ from PyQt6.QtWidgets import QApplication, QMainWindow, QListWidget, QListWidgetItem, QStackedWidget, QVBoxLayout, \
QWidget, QLabel, QCheckBox, QLineEdit, \ QWidget, QLabel, QCheckBox, QLineEdit, \
@@ -105,6 +105,10 @@ class SettingsWindow(QMainWindow):
self.setMinimumSize(700, 400) self.setMinimumSize(700, 400)
# timers for background download UI updates
self.timer = QTimer(self)
self.timer.timeout.connect(self.update_engine_download_status)
def add_sidebar_item(self, name, icon_path): def add_sidebar_item(self, name, icon_path):
"""Add an item with an icon to the sidebar.""" """Add an item with an icon to the sidebar."""
item = QListWidgetItem(QIcon(icon_path), name) item = QListWidgetItem(QIcon(icon_path), name)
@@ -388,7 +392,7 @@ class SettingsWindow(QMainWindow):
if msg_result == QMessageBox.StandardButton.Yes: if msg_result == QMessageBox.StandardButton.Yes:
EngineManager.download_engine(engine=engine.name(), version=result['version'], background=True, EngineManager.download_engine(engine=engine.name(), version=result['version'], background=True,
ignore_system=ignore_system) ignore_system=ignore_system)
self.update_engine_download_status() self.timer.start(1000)
if not messagebox_shown: if not messagebox_shown:
msg_box = QMessageBox() msg_box = QMessageBox()
@@ -404,6 +408,8 @@ class SettingsWindow(QMainWindow):
def update_engine_download_status(self): def update_engine_download_status(self):
running_tasks = [x for x in EngineManager.download_tasks if x.is_alive()] running_tasks = [x for x in EngineManager.download_tasks if x.is_alive()]
if not running_tasks: if not running_tasks:
self.timer.stop()
self.installed_engines_table.update_engines_table(use_cached=False)
self.update_last_checked_label() self.update_last_checked_label()
return return