Add support for PyInstaller bundle in main_window.py
- Updated icon path handling to support both development mode and PyInstaller bundle. - Modified script path loading to accommodate PyInstaller bundle structure. - Adjusted download interceptor path to work with PyInstaller bundle.
This commit is contained in:
parent
d799339d93
commit
0c276b9022
3 changed files with 2912 additions and 2877 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -4,6 +4,7 @@ import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
@ -280,7 +281,14 @@ class MainWindow(QMainWindow):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set window icon
|
# Set window icon
|
||||||
|
# Support both development mode and PyInstaller bundle
|
||||||
|
if hasattr(sys, '_MEIPASS'):
|
||||||
|
# Running as PyInstaller bundle
|
||||||
|
icon_path = Path(sys._MEIPASS) / "resources" / "icons" / "app.ico" # type: ignore
|
||||||
|
else:
|
||||||
|
# Running in development mode
|
||||||
icon_path = Path(__file__).parent.parent.parent.parent / "resources" / "icons" / "app.ico"
|
icon_path = Path(__file__).parent.parent.parent.parent / "resources" / "icons" / "app.ico"
|
||||||
|
|
||||||
if icon_path.exists():
|
if icon_path.exists():
|
||||||
self.setWindowIcon(QIcon(str(icon_path)))
|
self.setWindowIcon(QIcon(str(icon_path)))
|
||||||
logger.debug(f"Window icon set from {icon_path}")
|
logger.debug(f"Window icon set from {icon_path}")
|
||||||
|
|
@ -441,13 +449,24 @@ class MainWindow(QMainWindow):
|
||||||
|
|
||||||
# Load bridge script from file
|
# Load bridge script from file
|
||||||
# Using intercept script - prevents browser drag, hands off to Qt
|
# Using intercept script - prevents browser drag, hands off to Qt
|
||||||
|
# Support both development mode and PyInstaller bundle
|
||||||
|
if hasattr(sys, '_MEIPASS'):
|
||||||
|
# Running as PyInstaller bundle
|
||||||
|
script_path = Path(sys._MEIPASS) / "webdrop_bridge" / "ui" / "bridge_script_intercept.js" # type: ignore
|
||||||
|
else:
|
||||||
|
# Running in development mode
|
||||||
script_path = Path(__file__).parent / "bridge_script_intercept.js"
|
script_path = Path(__file__).parent / "bridge_script_intercept.js"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(script_path, 'r', encoding='utf-8') as f:
|
with open(script_path, 'r', encoding='utf-8') as f:
|
||||||
bridge_code = f.read()
|
bridge_code = f.read()
|
||||||
|
|
||||||
# Load download interceptor
|
# Load download interceptor
|
||||||
|
if hasattr(sys, '_MEIPASS'):
|
||||||
|
download_interceptor_path = Path(sys._MEIPASS) / "webdrop_bridge" / "ui" / "download_interceptor.js" # type: ignore
|
||||||
|
else:
|
||||||
download_interceptor_path = Path(__file__).parent / "download_interceptor.js"
|
download_interceptor_path = Path(__file__).parent / "download_interceptor.js"
|
||||||
|
|
||||||
download_interceptor_code = ""
|
download_interceptor_code = ""
|
||||||
try:
|
try:
|
||||||
with open(download_interceptor_path, 'r', encoding='utf-8') as f:
|
with open(download_interceptor_path, 'r', encoding='utf-8') as f:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue