Skip to content

Commit

Permalink
feat(ui): add theming support and CPU usage bar
Browse files Browse the repository at this point in the history
- add theming support
- add CPU usage bar
- add Save Preset and Load Preset menu bar options under File tab
  • Loading branch information
leafspark committed Aug 17, 2024
1 parent 66e7e39 commit 3a43486
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/AutoGGUF.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/ui_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3a43486

Please sign in to comment.