fix: Windows taskbar icon support
- Added set_windows_taskbar_icon() function using ctypes - Sets AppUserModelID to ensure Windows taskbar shows custom icon - Icon is now set on QApplication for proper taskbar display - Works on Windows 7/8/10/11
This commit is contained in:
parent
c1f9dd8475
commit
172cfd212a
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue