fix: tray icon more legible
This commit is contained in:
@@ -154,50 +154,11 @@ COLORS = {
|
||||
}
|
||||
|
||||
ICON_SIZE = 64
|
||||
ICON_FILE = os.path.join(HERE, "icon.ico")
|
||||
|
||||
# Load base icon once at startup; fall back to None if missing.
|
||||
# When frozen, bundled data files live in sys._MEIPASS.
|
||||
def _load_base_icon():
|
||||
candidates = [ICON_FILE]
|
||||
if getattr(sys, "frozen", False):
|
||||
candidates.insert(0, os.path.join(sys._MEIPASS, "icon.ico"))
|
||||
for path in candidates:
|
||||
try:
|
||||
img = Image.open(path)
|
||||
img = img.convert("RGBA").resize((ICON_SIZE, ICON_SIZE), Image.LANCZOS)
|
||||
return img
|
||||
except Exception:
|
||||
continue
|
||||
return None
|
||||
|
||||
_BASE_ICON = _load_base_icon()
|
||||
|
||||
|
||||
def make_icon(status):
|
||||
"""
|
||||
Use icon.ico as the base and overlay a small status dot in the
|
||||
bottom-right corner. Falls back to a plain colored circle if the
|
||||
ico file is not available.
|
||||
"""
|
||||
"""Draw a plain colored circle for the system tray — clean and readable at 16px."""
|
||||
color = COLORS.get(status, COLORS["starting"])
|
||||
|
||||
if _BASE_ICON is not None:
|
||||
img = _BASE_ICON.copy()
|
||||
draw = ImageDraw.Draw(img)
|
||||
# Dot size and position — bottom-right corner
|
||||
dot_r = ICON_SIZE // 5 # radius ~12px on 64px icon
|
||||
margin = 2
|
||||
x0 = ICON_SIZE - dot_r * 2 - margin
|
||||
y0 = ICON_SIZE - dot_r * 2 - margin
|
||||
x1 = ICON_SIZE - margin
|
||||
y1 = ICON_SIZE - margin
|
||||
# White outline for contrast on dark/light backgrounds
|
||||
draw.ellipse([x0 - 2, y0 - 2, x1 + 2, y1 + 2], fill=(255, 255, 255, 220))
|
||||
draw.ellipse([x0, y0, x1, y1], fill=color + (255,))
|
||||
return img
|
||||
|
||||
# Fallback: plain colored circle
|
||||
img = Image.new("RGBA", (ICON_SIZE, ICON_SIZE), (0, 0, 0, 0))
|
||||
draw = ImageDraw.Draw(img)
|
||||
margin = 6
|
||||
|
||||
Reference in New Issue
Block a user