fix: bundle icons + set app window icon and Windows AppUserModelID (#20)
CI / Lint (ruff) (pull_request) Successful in 7s
CI / Tests (py3.10) (pull_request) Successful in 9s
CI / Tests (py3.12) (pull_request) Successful in 10s

This commit is contained in:
Cowork Supervisor
2026-07-08 11:59:57 -04:00
parent 3b5379a2b8
commit 6d91c709a7
3 changed files with 56 additions and 4 deletions
+40 -3
View File
@@ -1253,6 +1253,31 @@ class LogViewerDialog(QDialog):
super().closeEvent(event)
# --------------------------------------------------------------------------- #
# Bundled assets (icons) — resolves both a normal source run and a frozen
# PyInstaller build (onefile extracts assets under sys._MEIPASS).
# --------------------------------------------------------------------------- #
def _asset_dir() -> Path:
base = getattr(sys, "_MEIPASS", None)
return Path(base) if base else Path(__file__).resolve().parent
def _app_icon() -> QIcon:
"""Multi-resolution app/window icon from the bundled PNGs (falls back to
the .ico). Returns a null QIcon if no asset is found."""
icon = QIcon()
base = _asset_dir() / "icons" / "twin-gears" / "rounded"
for size in (16, 32, 48, 64, 128, 256, 512):
f = base / f"icon-{size}.png"
if f.is_file():
icon.addFile(str(f))
if icon.isNull():
ico = _asset_dir() / "icons" / "app.ico"
if ico.is_file():
icon.addFile(str(ico))
return icon
# --------------------------------------------------------------------------- #
# About dialog
# --------------------------------------------------------------------------- #
@@ -1274,9 +1299,7 @@ class AboutDialog(QDialog):
self._worker: UpdateCheckWorker | None = None
self._release_url: str | None = None
icon_path = (
Path(__file__).resolve().parent / "icons" / "twin-gears" / "rounded" / "icon-128.png"
)
icon_path = _asset_dir() / "icons" / "twin-gears" / "rounded" / "icon-128.png"
if icon_path.is_file():
self.setWindowIcon(QIcon(str(icon_path)))
@@ -2366,9 +2389,23 @@ class MainWindow(QMainWindow):
def main():
if sys.platform == "win32":
# Without an explicit AppUserModelID, Windows taskbar groups the app
# under the default host/Python icon instead of our own window icon.
try:
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
"io.avezzano.better-claude-config"
)
except Exception:
pass
app = QApplication(sys.argv)
app.setApplicationName("Better Claude Config")
app.setApplicationDisplayName("Better Claude Config")
icon = _app_icon()
if not icon.isNull():
app.setWindowIcon(icon)
app.setStyleSheet(STYLESHEET)
win = MainWindow()
win.show()