Skip to content

Commit 225f6d0

Browse files
committed
permettre lutilisation du nouveau logo
1 parent eb45b00 commit 225f6d0

3 files changed

Lines changed: 105 additions & 16 deletions

File tree

OnlyMod/BcaslOnlyMod/gui.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,17 +1537,24 @@ def _clear_log(self):
15371537

15381538
def _log(self, message: str):
15391539
"""Ajoute un message au log."""
1540-
# Vérifier que le widget existe et n'a pas été supprimé
1540+
try:
1541+
from pycompiler_ark import onlymod_log
1542+
1543+
onlymod_log(message, gui=self)
1544+
return
1545+
except Exception:
1546+
pass
1547+
1548+
# Fallback direct (si le centraliseur n'est pas dispo)
15411549
if not self._is_valid(self.log_text):
15421550
return
15431551
try:
15441552
timestamp = datetime.now().strftime("%H:%M:%S")
15451553
self.log_text.append(f"[{timestamp}] {message}")
1546-
# Défiler automatiquement vers le bas
15471554
scrollbar = self.log_text.verticalScrollBar()
15481555
scrollbar.setValue(scrollbar.maximum())
15491556
except (RuntimeError, AttributeError):
1550-
pass # Ignorer si le widget a été supprimé
1557+
pass
15511558

15521559

15531560
def launch_bcasl_gui(

OnlyMod/EngineOnlyMod/gui.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,17 +1384,24 @@ def _clear_log(self):
13841384

13851385
def _log(self, message: str):
13861386
"""Ajoute un message au log."""
1387-
# Vérifier que le widget existe et n'a pas été supprimé
1387+
try:
1388+
from pycompiler_ark import onlymod_log
1389+
1390+
onlymod_log(message, gui=self)
1391+
return
1392+
except Exception:
1393+
pass
1394+
1395+
# Fallback direct (si le centraliseur n'est pas dispo)
13881396
if not self._is_valid(self.log_text):
13891397
return
13901398
try:
13911399
timestamp = datetime.now().strftime("%H:%M:%S")
13921400
self.log_text.append(f"[{timestamp}] {message}")
1393-
# Défiler automatiquement vers le bas
13941401
scrollbar = self.log_text.verticalScrollBar()
13951402
scrollbar.setValue(scrollbar.maximum())
13961403
except (RuntimeError, AttributeError):
1397-
pass # Ignorer si le widget a été supprimé
1404+
pass
13981405

13991406

14001407
def launch_engines_gui(

pycompiler_ark.py

Lines changed: 85 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from pathlib import Path
5757
from typing import Optional, List, Dict, Any
5858
import logging
59+
from datetime import datetime
5960

6061
# Ensure project root has priority on sys.path
6162
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -78,6 +79,49 @@
7879
)
7980
logger = logging.getLogger(__name__)
8081

82+
# Centralized logging for OnlyMod GUIs
83+
_ONLYMOD_LOG_HISTORY: list[str] = []
84+
85+
86+
def onlymod_log(message: str, gui: Optional[object] = None) -> str:
87+
"""Centralized logging for OnlyMod GUIs.
88+
89+
- Adds a timestamp
90+
- Appends to the GUI log widget when provided
91+
- Mirrors to the standard logger
92+
"""
93+
try:
94+
ts = datetime.now().strftime("%H:%M:%S")
95+
except Exception:
96+
ts = ""
97+
line = f"[{ts}] {message}" if ts else str(message)
98+
99+
try:
100+
_ONLYMOD_LOG_HISTORY.append(line)
101+
except Exception:
102+
pass
103+
104+
try:
105+
logger.info("[OnlyMod] %s", message)
106+
except Exception:
107+
pass
108+
109+
# Push to GUI log widget if available
110+
if gui is not None:
111+
try:
112+
log_text = getattr(gui, "log_text", None)
113+
is_valid = getattr(gui, "_is_valid", None)
114+
if callable(is_valid) and not is_valid(log_text):
115+
return line
116+
if log_text is not None:
117+
log_text.append(line)
118+
scrollbar = log_text.verticalScrollBar()
119+
scrollbar.setValue(scrollbar.maximum())
120+
except Exception:
121+
pass
122+
123+
return line
124+
81125
IS_WINDOWS = os.name == "nt" or platform.system().lower().startswith("win")
82126
IS_DARWIN = platform.system().lower().startswith("darwin")
83127
IS_LINUX = platform.system().lower().startswith("linux")
@@ -175,19 +219,50 @@ def _platform_log_dir() -> Path:
175219
pass
176220

177221

178-
def _get_icon_path() -> Optional[str]:
179-
"""Return the best available application icon path."""
222+
def _get_app_icon_path() -> Optional[str]:
223+
"""Return the best available application icon path (non-GUI usage)."""
224+
try:
225+
candidates = [
226+
os.path.join(ROOT_DIR, "logo", "image-6.png"),
227+
os.path.join(ROOT_DIR, "logo", "logo2.png"),
228+
]
229+
for path in candidates:
230+
if os.path.isfile(path):
231+
return path
232+
except Exception:
233+
pass
234+
return None
235+
236+
237+
def _get_window_icon_path() -> Optional[str]:
238+
"""Return the best available window icon path (GUI usage)."""
180239
try:
181-
path = os.path.join(ROOT_DIR, "logo", "logo2.png")
182-
return path if os.path.isfile(path) else None
240+
candidates = [
241+
os.path.join(ROOT_DIR, "logo", "logo2.png"),
242+
os.path.join(ROOT_DIR, "logo", "logo.png"),
243+
]
244+
for path in candidates:
245+
if os.path.isfile(path):
246+
return path
183247
except Exception:
184-
return None
248+
pass
249+
return None
250+
251+
252+
def _set_app_icon(target) -> None:
253+
"""Set the application icon if available."""
254+
try:
255+
icon_path = _get_app_icon_path()
256+
if icon_path:
257+
target.setWindowIcon(QIcon(icon_path))
258+
except Exception:
259+
pass
185260

186261

187262
def _set_window_icon(target) -> None:
188-
"""Set the window/application icon if available."""
263+
"""Set the window (GUI) icon if available."""
189264
try:
190-
icon_path = _get_icon_path()
265+
icon_path = _get_window_icon_path()
191266
if icon_path:
192267
target.setWindowIcon(QIcon(icon_path))
193268
except Exception:
@@ -496,7 +571,7 @@ def launch_bcasl_standalone(workspace_dir: Optional[str] = None) -> int:
496571
app = QApplication(sys.argv)
497572
app.setApplicationName("PyCompiler ARK++ BCASL")
498573
app.setOrganizationName("raidos23")
499-
_set_window_icon(app)
574+
_set_app_icon(app)
500575
window = BcaslStandaloneGui(workspace_dir=workspace_dir)
501576
_set_window_icon(window)
502577
window.show()
@@ -547,7 +622,7 @@ def launch_engines_only_standalone(workspace_dir: Optional[str] = None) -> int:
547622
app = QApplication(sys.argv)
548623
app.setApplicationName("PyCompiler ARK++ Engines")
549624
app.setOrganizationName("raidos23")
550-
_set_window_icon(app)
625+
_set_app_icon(app)
551626
window = EnginesStandaloneGui(workspace_dir=workspace_dir)
552627
_set_window_icon(window)
553628

@@ -582,7 +657,7 @@ def launch_main_application() -> int:
582657
"""
583658
try:
584659
app = QApplication(sys.argv)
585-
_set_window_icon(app)
660+
_set_app_icon(app)
586661

587662
# Splash screen: affiche l'image 'splash.*' depuis le dossier 'logo' si disponible
588663
splash = None

0 commit comments

Comments
 (0)