fix(icon): force Win32 WM_SETICON before window creation and bust desktop shortcut icon cache
This commit is contained in:
parent
3dd1e04f29
commit
8b500db276
3 changed files with 65 additions and 21 deletions
BIN
assets/logo.ico
BIN
assets/logo.ico
Binary file not shown.
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 197 KiB |
|
|
@ -23,7 +23,9 @@ PrivilegesRequiredOverridesAllowed=dialog
|
||||||
OutputDir=dist
|
OutputDir=dist
|
||||||
OutputBaseFilename=LDownloader-v{#MyAppVersion}-Setup
|
OutputBaseFilename=LDownloader-v{#MyAppVersion}-Setup
|
||||||
SetupIconFile=assets\logo.ico
|
SetupIconFile=assets\logo.ico
|
||||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
UninstallDisplayIcon={app}\assets\ld_v35_icon.ico
|
||||||
|
ChangesAssociations=yes
|
||||||
|
CloseApplications=force
|
||||||
Compression=lzma2/ultra64
|
Compression=lzma2/ultra64
|
||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
WizardStyle=modern
|
WizardStyle=modern
|
||||||
|
|
@ -38,11 +40,12 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
|
||||||
[Files]
|
[Files]
|
||||||
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "assets\logo.ico"; DestDir: "{app}\assets"; Flags: ignoreversion
|
Source: "assets\logo.ico"; DestDir: "{app}\assets"; Flags: ignoreversion
|
||||||
|
Source: "assets\logo.ico"; DestDir: "{app}\assets"; DestName: "ld_v35_icon.ico"; Flags: ignoreversion
|
||||||
Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
|
||||||
[Icons]
|
[Icons]
|
||||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\{#MyAppExeName}"
|
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\assets\ld_v35_icon.ico"
|
||||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\assets\ld_v35_icon.ico"; Tasks: desktopicon
|
||||||
|
|
||||||
[Run]
|
[Run]
|
||||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||||
|
|
|
||||||
77
ui/app.py
77
ui/app.py
|
|
@ -34,7 +34,7 @@ class LDownloaderApp(tk.Tk):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("lildosto.ldownloader.v35.icon")
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("lildosto.ldownloader.v35.ldicon2")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -44,6 +44,12 @@ class LDownloaderApp(tk.Tk):
|
||||||
self.minsize(880, 580)
|
self.minsize(880, 580)
|
||||||
self.configure(bg=BG)
|
self.configure(bg=BG)
|
||||||
|
|
||||||
|
# İkon ve Logo — Pencere ekranda oluşturulmadan (update_idletasks öncesi) yüklenmelidir
|
||||||
|
self._ico_path = None
|
||||||
|
self._hicon_big = None
|
||||||
|
self._hicon_sm = None
|
||||||
|
self._load_icons()
|
||||||
|
|
||||||
# Ekranı ortala
|
# Ekranı ortala
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
sw = self.winfo_screenwidth()
|
sw = self.winfo_screenwidth()
|
||||||
|
|
@ -54,8 +60,9 @@ class LDownloaderApp(tk.Tk):
|
||||||
y = max(0, (sh - height) // 2)
|
y = max(0, (sh - height) // 2)
|
||||||
self.geometry(f"{width}x{height}+{x}+{y}")
|
self.geometry(f"{width}x{height}+{x}+{y}")
|
||||||
|
|
||||||
# İkon ve Logo
|
# Win32 HWND oluştuktan hemen sonra görev çubuğu (WM_SETICON) ikonunu zorla
|
||||||
self._load_icons()
|
self._apply_win32_icon()
|
||||||
|
self.after(100, self._apply_win32_icon)
|
||||||
|
|
||||||
# Tema ve stiller
|
# Tema ve stiller
|
||||||
apply_theme(self, config.get("theme", "dark"))
|
apply_theme(self, config.get("theme", "dark"))
|
||||||
|
|
@ -78,14 +85,19 @@ class LDownloaderApp(tk.Tk):
|
||||||
ico_path = os.path.join(app_dir, "assets", "logo.ico")
|
ico_path = os.path.join(app_dir, "assets", "logo.ico")
|
||||||
if not os.path.isfile(ico_path):
|
if not os.path.isfile(ico_path):
|
||||||
ico_path = os.path.join(app_dir, "logo.ico")
|
ico_path = os.path.join(app_dir, "logo.ico")
|
||||||
|
ico_loaded = False
|
||||||
if os.path.isfile(ico_path):
|
if os.path.isfile(ico_path):
|
||||||
|
self._ico_path = os.path.abspath(ico_path)
|
||||||
try:
|
try:
|
||||||
self.iconbitmap(default=ico_path)
|
self.iconbitmap(self._ico_path)
|
||||||
|
ico_loaded = True
|
||||||
except Exception:
|
except Exception:
|
||||||
try:
|
pass
|
||||||
self.iconbitmap(ico_path)
|
try:
|
||||||
except Exception:
|
self.iconbitmap(default=self._ico_path)
|
||||||
pass
|
ico_loaded = True
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
self.logo_img = None
|
self.logo_img = None
|
||||||
self.window_icon_img = None
|
self.window_icon_img = None
|
||||||
|
|
@ -97,29 +109,58 @@ class LDownloaderApp(tk.Tk):
|
||||||
try:
|
try:
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
pil_img = Image.open(png_path).convert("RGBA")
|
pil_img = Image.open(png_path).convert("RGBA")
|
||||||
# Kenar boşluğu kalmışsa otomatik kırp
|
|
||||||
bbox = pil_img.getbbox()
|
bbox = pil_img.getbbox()
|
||||||
if bbox:
|
if bbox:
|
||||||
pil_img = pil_img.crop(bbox)
|
pil_img = pil_img.crop(bbox)
|
||||||
for sz in (256, 64, 48, 32, 16):
|
|
||||||
self.window_icon_imgs.append(
|
|
||||||
ImageTk.PhotoImage(pil_img.resize((sz, sz), Image.Resampling.LANCZOS))
|
|
||||||
)
|
|
||||||
self.window_icon_img = self.window_icon_imgs[0]
|
|
||||||
self.iconphoto(True, *self.window_icon_imgs)
|
|
||||||
self.logo_img = ImageTk.PhotoImage(
|
self.logo_img = ImageTk.PhotoImage(
|
||||||
pil_img.resize((28, 28), Image.Resampling.LANCZOS)
|
pil_img.resize((30, 30), Image.Resampling.LANCZOS)
|
||||||
)
|
)
|
||||||
|
if not ico_loaded or sys.platform != "win32":
|
||||||
|
for sz in (64, 48, 32, 16):
|
||||||
|
self.window_icon_imgs.append(
|
||||||
|
ImageTk.PhotoImage(pil_img.resize((sz, sz), Image.Resampling.LANCZOS))
|
||||||
|
)
|
||||||
|
self.window_icon_img = self.window_icon_imgs[0]
|
||||||
|
self.iconphoto(True, *self.window_icon_imgs)
|
||||||
except Exception:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
raw = tk.PhotoImage(file=png_path)
|
raw = tk.PhotoImage(file=png_path)
|
||||||
self.window_icon_img = raw
|
self.window_icon_img = raw
|
||||||
self.iconphoto(True, raw)
|
if not ico_loaded or sys.platform != "win32":
|
||||||
factor = max(1, raw.width() // 28)
|
self.iconphoto(True, raw)
|
||||||
|
factor = max(1, raw.width() // 30)
|
||||||
self.logo_img = raw.subsample(factor, factor)
|
self.logo_img = raw.subsample(factor, factor)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _apply_win32_icon(self):
|
||||||
|
if sys.platform != "win32" or not self._ico_path or not os.path.isfile(self._ico_path):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
user32 = ctypes.windll.user32
|
||||||
|
hwnd = user32.GetParent(self.winfo_id()) or self.winfo_id()
|
||||||
|
if not hwnd:
|
||||||
|
return
|
||||||
|
LR_LOADFROMFILE = 0x00000010
|
||||||
|
IMAGE_ICON = 1
|
||||||
|
WM_SETICON = 0x0080
|
||||||
|
ICON_SMALL = 0
|
||||||
|
ICON_BIG = 1
|
||||||
|
GCLP_HICON = -14
|
||||||
|
GCLP_HICONSM = -34
|
||||||
|
if not self._hicon_big:
|
||||||
|
self._hicon_big = user32.LoadImageW(0, self._ico_path, IMAGE_ICON, 256, 256, LR_LOADFROMFILE)
|
||||||
|
if not self._hicon_sm:
|
||||||
|
self._hicon_sm = user32.LoadImageW(0, self._ico_path, IMAGE_ICON, 32, 32, LR_LOADFROMFILE)
|
||||||
|
if self._hicon_big:
|
||||||
|
user32.SendMessageW(hwnd, WM_SETICON, ICON_BIG, self._hicon_big)
|
||||||
|
user32.SetClassLongPtrW(hwnd, GCLP_HICON, self._hicon_big)
|
||||||
|
if self._hicon_sm:
|
||||||
|
user32.SendMessageW(hwnd, WM_SETICON, ICON_SMALL, self._hicon_sm)
|
||||||
|
user32.SetClassLongPtrW(hwnd, GCLP_HICONSM, self._hicon_sm)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def _build_layout(self):
|
def _build_layout(self):
|
||||||
# ── Birleşik Üst Çubuk (Logo + Sekmeler + Durum) ────────────
|
# ── Birleşik Üst Çubuk (Logo + Sekmeler + Durum) ────────────
|
||||||
top_bar = tk.Frame(self, bg=TAB_BG, padx=24, pady=8)
|
top_bar = tk.Frame(self, bg=TAB_BG, padx=24, pady=8)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue