mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
* Initial commit for new UI * Initial commit for new UI * WIP * Status bar updates and has an icon for online / offline * Add log_viewer.py * Use JSON for delete_engine_download API * Fix class issue with Downloaders * Move Config class to new ui * Add engine_browser.py * Add a close event handler to the main window * Fix issue with engine manager not deleting engines properly * Rearrange all the files * Add icons and resources * Cache system info in RenderServerProxy * Toolbar polish * Fix resource path in status bar * Add config_dir to misc_helper.py * Add try block to zeroconf setup * Add add_job.py * Add raw args to add_job.py
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
''' app/ui/widgets/statusbar.py '''
|
|
import os.path
|
|
import socket
|
|
import threading
|
|
import time
|
|
|
|
from PyQt6.QtCore import Qt, QTimer
|
|
from PyQt6.QtGui import QPixmap
|
|
from PyQt6.QtWidgets import QStatusBar, QLabel
|
|
|
|
from src.api.server_proxy import RenderServerProxy
|
|
from src.utilities.misc_helper import resources_dir
|
|
|
|
|
|
class StatusBar(QStatusBar):
|
|
"""
|
|
Initialize the status bar.
|
|
|
|
Args:
|
|
parent: The parent widget.
|
|
"""
|
|
|
|
def __init__(self, parent) -> None:
|
|
super().__init__(parent)
|
|
|
|
def background_update():
|
|
|
|
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
|
|
time.sleep(1)
|
|
|
|
background_thread = threading.Thread(target=background_update,)
|
|
background_thread.daemon = True
|
|
background_thread.start()
|
|
|
|
# Create a label that holds an image
|
|
self.label = QLabel()
|
|
image_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'resources', 'icons',
|
|
'RedSquare.png')
|
|
pixmap = (QPixmap(image_path).scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio))
|
|
self.label.setPixmap(pixmap)
|
|
self.addWidget(self.label)
|
|
|
|
# Create a label for the message
|
|
self.messageLabel = QLabel()
|
|
self.addWidget(self.messageLabel)
|
|
|
|
# Call this method to display a message
|
|
self.messageLabel.setText("Loading...")
|