fix: Windows taskbar icon support

This commit is contained in:
LemonNexus 2026-02-11 19:14:34 +00:00
parent d130550c68
commit 344c4687c9
1 changed files with 31 additions and 6 deletions

View File

@ -1024,14 +1024,39 @@ class IconExtractorWindow(QMainWindow):
def set_app_icon(app: QApplication): def set_app_icon(app: QApplication):
"""Set application icon (window icon is set per-window in _load_icon).""" """Set application icon for window and taskbar."""
# Icon is loaded per-window in IconExtractorWindow._load_icon() # Try to load icon from various locations
# This function is kept for compatibility but doesn't need to do anything icon_paths = [
Path(__file__).parent / "assets" / "icon.ico",
Path(__file__).parent / "assets" / "icon.png",
Path(__file__).parent / "icon.ico",
Path(__file__).parent / "icon.png",
]
for icon_path in icon_paths:
if icon_path.exists():
app.setWindowIcon(QIcon(str(icon_path)))
return True
return False
def set_windows_taskbar_icon():
"""Set Windows taskbar icon properly."""
if sys.platform == 'win32':
# Set the AppUserModelID to ensure taskbar shows our icon
try:
import ctypes
myappid = 'impulsivefps.euiconextractor.1.0'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
except Exception:
pass pass
def main(): def main():
"""Main entry point.""" """Main entry point."""
# Set Windows taskbar icon before creating QApplication
set_windows_taskbar_icon()
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setStyle('Fusion') app.setStyle('Fusion')
@ -1040,10 +1065,10 @@ def main():
app.setApplicationVersion(APP_VERSION) app.setApplicationVersion(APP_VERSION)
app.setOrganizationName("ImpulsiveFPS") app.setOrganizationName("ImpulsiveFPS")
# Try to set icon # Set app icon (for taskbar and window)
set_app_icon(app) set_app_icon(app)
# Dark theme with better readability # Dark theme by default
app.setStyleSheet(""" app.setStyleSheet("""
QMainWindow, QDialog { QMainWindow, QDialog {
background-color: #1e1e1e; background-color: #1e1e1e;