mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-18 01:08:12 +00:00
Report Engine Download Status in UI (#64)
* Report downloads in status bar * Update engine_browser.py UI with any active downloads
This commit is contained in:
@@ -9,6 +9,7 @@ from PyQt6.QtGui import QPixmap
|
||||
from PyQt6.QtWidgets import QStatusBar, QLabel
|
||||
|
||||
from src.api.server_proxy import RenderServerProxy
|
||||
from src.engines.engine_manager import EngineManager
|
||||
from src.utilities.misc_helper import resources_dir
|
||||
|
||||
|
||||
@@ -28,17 +29,23 @@ class StatusBar(QStatusBar):
|
||||
proxy = RenderServerProxy(socket.gethostname())
|
||||
proxy.start_background_update()
|
||||
image_names = {'Ready': 'GreenCircle.png', 'Offline': "RedSquare.png"}
|
||||
last_update = None
|
||||
|
||||
# Check for status change every 1s on background thread
|
||||
while True:
|
||||
new_status = proxy.status()
|
||||
if new_status is not last_update:
|
||||
new_image_name = image_names.get(new_status, 'Synchronize.png')
|
||||
image_path = os.path.join(resources_dir(), 'icons', new_image_name)
|
||||
self.label.setPixmap((QPixmap(image_path).scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)))
|
||||
self.messageLabel.setText(new_status)
|
||||
last_update = new_status
|
||||
new_image_name = image_names.get(new_status, 'Synchronize.png')
|
||||
image_path = os.path.join(resources_dir(), 'icons', new_image_name)
|
||||
self.label.setPixmap((QPixmap(image_path).scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)))
|
||||
|
||||
# add download status
|
||||
if EngineManager.download_tasks:
|
||||
if len(EngineManager.download_tasks) == 1:
|
||||
task = EngineManager.download_tasks[0]
|
||||
new_status = f"{new_status} | Downloading {task.engine.capitalize()} {task.version}..."
|
||||
else:
|
||||
new_status = f"{new_status} | Downloading {len(EngineManager.download_tasks)} engines"
|
||||
|
||||
self.messageLabel.setText(new_status)
|
||||
time.sleep(1)
|
||||
|
||||
background_thread = threading.Thread(target=background_update,)
|
||||
|
||||
Reference in New Issue
Block a user