Skip to content

Commit

Permalink
Adjust button colors + Add tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
vietanhdev committed Sep 29, 2024
1 parent 1213e19 commit c2faf58
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
38 changes: 18 additions & 20 deletions llama_assistant/llama_assistant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import markdown
from importlib import resources
from pathlib import Path

from PyQt6.QtWidgets import (
QApplication,
QMainWindow,
Expand Down Expand Up @@ -35,8 +36,8 @@
QDropEvent,
QFont,
QBitmap,
QTextCursor,
)

from llama_assistant.wake_word_detector import WakeWordDetector
from llama_assistant.custom_plaintext_editor import CustomPlainTextEdit
from llama_assistant.global_hotkey import GlobalHotkey
Expand Down Expand Up @@ -213,12 +214,12 @@ def init_ui(self):
self.mic_button.setStyleSheet(
"""
QPushButton {
background-color: rgba(255, 255, 255, 0.3);
background-color: rgba(100, 100, 100, 200);
border: none;
border-radius: 20px;
}
QPushButton:hover {
background-color: rgba(255, 255, 255, 0.5);
background-color: rgba(100, 100, 100, 230);
}
"""
)
Expand All @@ -229,7 +230,7 @@ def init_ui(self):
close_button.setStyleSheet(
"""
QPushButton {
background-color: rgba(255, 0, 0, 0.7);
background-color: rgba(255, 0, 0, 150);
color: white;
border: none;
border-radius: 15px;
Expand All @@ -239,7 +240,7 @@ def init_ui(self):
height: 30px;
}
QPushButton:hover {
background-color: rgba(255, 0, 0, 0.9);
background-color: rgba(255, 0, 0, 200);
}
"""
)
Expand Down Expand Up @@ -316,12 +317,12 @@ def init_ui(self):
}
QScrollBar:vertical {
border: none;
background: rgba(255, 255, 255, 0.1);
background: rgba(255, 255, 255, 200);
width: 10px;
margin: 0px 0px 0px 0px;
}
QScrollBar::handle:vertical {
background: rgba(255, 255, 255, 0.3);
background: rgba(255, 255, 255, 230);
min-height: 20px;
border-radius: 5px;
}
Expand Down Expand Up @@ -420,7 +421,7 @@ def center_on_screen(self):

def init_tray(self):
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(self.create_tray_icon())
self.tray_icon.setIcon(self.load_tray_icon())

tray_menu = QMenu()
show_action = tray_menu.addAction("Show")
Expand All @@ -438,14 +439,10 @@ def tray_icon_activated(self, reason):
if reason == QSystemTrayIcon.ActivationReason.Trigger:
self.toggle_visibility()

def create_tray_icon(self):
pixmap = QPixmap(48, 48)
pixmap.fill(Qt.GlobalColor.black)
painter = QPainter(pixmap)
painter.setPen(QPen(Qt.GlobalColor.white))
painter.setFont(QFont("Arial", 30, QFont.Weight.Bold))
painter.drawText(pixmap.rect(), Qt.AlignmentFlag.AlignCenter, "L")
painter.end()
def load_tray_icon(self):
with resources.path("llama_assistant.resources", "logo.png") as path:
pixmap = QPixmap(str(path))
pixmap = pixmap.scaled(48, 48, Qt.AspectRatioMode.KeepAspectRatio)
return QIcon(pixmap)

def toggle_visibility(self):
Expand Down Expand Up @@ -569,7 +566,7 @@ def show_image_thumbnail(self, image_path):
remove_button.setStyleSheet(
"""
QPushButton {
background-color: rgba(128, 128, 128, 0.7);
background-color: rgba(50, 50, 50, 200);
color: white;
border: none;
border-radius: 8px;
Expand All @@ -579,7 +576,7 @@ def show_image_thumbnail(self, image_path):
height: 16px;
}
QPushButton:hover {
background-color: rgba(128, 128, 128, 0.9);
background-color: rgba(50, 50, 50, 230);
}
"""
)
Expand Down Expand Up @@ -697,7 +694,8 @@ def on_speech_error(self, error_message):
self.stop_voice_input()

def closeEvent(self, event):
self.wake_word_detector.stop()
if self.wake_word_detector is not None:
self.wake_word_detector.stop()
super().closeEvent(event)


Expand Down
Binary file added llama_assistant/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "llama-assistant"
version = "0.1.20"
version = "0.1.21"
authors = [
{name = "Viet-Anh Nguyen", email = "[email protected]"},
]
Expand Down Expand Up @@ -52,7 +52,7 @@ include = ["llama_assistant*"]
exclude = ["tests*"]

[tool.setuptools.package-data]
"llama_assistant.resources" = ["*.onnx"]
"llama_assistant.resources" = ["*.png", "*.onnx"]


[tool.black]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ python_requires = >=3.8
where = .

[options.package_data]
llama_assistant.resources = *.onnx
llama_assistant.resources = *.png, *.onnx

0 comments on commit c2faf58

Please sign in to comment.