From 3a434865bc25259165ca926531fa9190b814b02b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 16 Aug 2024 18:59:37 -0700 Subject: [PATCH] feat(ui): add theming support and CPU usage bar - add theming support - add CPU usage bar - add Save Preset and Load Preset menu bar options under File tab --- src/AutoGGUF.py | 33 +++++++++++++++++++++++++++++++-- src/ui_update.py | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/AutoGGUF.py b/src/AutoGGUF.py index 190c8ce..2ac571f 100644 --- a/src/AutoGGUF.py +++ b/src/AutoGGUF.py @@ -150,7 +150,15 @@ def __init__(self): close_action = QAction("&Close", self) close_action.setShortcut(QKeySequence("Alt+F4")) close_action.triggered.connect(self.close) + save_preset_action = QAction("&Save Preset", self) + save_preset_action.setShortcut(QKeySequence("Ctrl+S")) + save_preset_action.triggered.connect(self.save_preset) + load_preset_action = QAction("&Load Preset", self) + load_preset_action.setShortcut(QKeySequence("Ctrl+S")) + load_preset_action.triggered.connect(self.load_preset) file_menu.addAction(close_action) + file_menu.addAction(save_preset_action) + file_menu.addAction(load_preset_action) # Help menu help_menu = self.menubar.addMenu("&Help") @@ -203,11 +211,13 @@ def __init__(self): # System info self.ram_bar = QProgressBar() - self.cpu_label = QLabel(CPU_USAGE) + self.cpu_bar = QProgressBar() + self.cpu_label = QLabel() self.gpu_monitor = GPUMonitor() left_layout.addWidget(QLabel(RAM_USAGE)) left_layout.addWidget(self.ram_bar) - left_layout.addWidget(self.cpu_label) + left_layout.addWidget(QLabel(CPU_USAGE)) + left_layout.addWidget(self.cpu_bar) left_layout.addWidget(QLabel(GPU_USAGE)) left_layout.addWidget(self.gpu_monitor) @@ -764,6 +774,25 @@ def __init__(self): self.refresh_releases() self.refresh_backends() + # Load theme based on environment variable + theme_path = os.environ.get("AUTOGGUF_THEME") + if theme_path: + try: + with open(theme_path, "r") as f: + theme = f.read() + self.setStyleSheet(theme) + except (FileNotFoundError, OSError): + # If the specified theme file is not found or inaccessible, + # fall back to the default theme + with open(resource_path("assets/default.css"), "r") as f: + default_theme = f.read() + self.setStyleSheet(default_theme) + else: + # If the environment variable is not set, use the default theme + with open(resource_path("assets/default.css"), "r") as f: + default_theme = f.read() + self.setStyleSheet(default_theme) + # Load models self.load_models() self.logger.info(AUTOGGUF_INITIALIZATION_COMPLETE) diff --git a/src/ui_update.py b/src/ui_update.py index abb262b..48c3a8c 100644 --- a/src/ui_update.py +++ b/src/ui_update.py @@ -17,6 +17,7 @@ def update_system_info(self): ) ) self.cpu_label.setText(CPU_USAGE_FORMAT.format(cpu)) + self.cpu_bar.setValue(int(cpu)) def update_download_progress(self, progress):