Skip to content

Commit 3b397af

Browse files
committed
Allège le package IDE GUI en déportant le layout dans le .ui
Supprime les ajustements runtime de dimensions/splitters dans Core/IdeLikeGui/connections.py pour réduire la logique de présentation côté Python. Déclare directement dans ui/ui_ide_design2.ui les contraintes de header, boutons Build/Cancel, panneaux (workspace/tools/logs) et tailles initiales des splitters. Met à jour la documentation IDE-like pour refléter que les contraintes de layout sont désormais portées par le fichier .ui.
1 parent a1c6503 commit 3b397af

3 files changed

Lines changed: 47 additions & 140 deletions

File tree

Core/IdeLikeGui/connections.py

Lines changed: 7 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
QToolButton,
3030
QStatusBar,
3131
QWidget,
32-
QFrame,
33-
QSplitter,
3432
)
3533

3634

@@ -82,9 +80,6 @@ def _prime_expected_attrs(self) -> None:
8280
"compiler_tabs",
8381
"tab_hello",
8482
"toolButton_more",
85-
"mainSplitter",
86-
"rightSplitter",
87-
"topSplitter",
8883
]
8984
for name in names:
9085
if not hasattr(self, name):
@@ -208,9 +203,6 @@ def _find(cls, name: str):
208203
self.btn_select_icon = None
209204
self.btn_nuitka_icon = None
210205
self.toolButton_more = _find(QToolButton, "toolButton_more")
211-
self.mainSplitter = _find(QSplitter, "mainSplitter")
212-
self.rightSplitter = _find(QSplitter, "rightSplitter")
213-
self.topSplitter = _find(QSplitter, "topSplitter")
214206
self.log = _find(QTextEdit, "log")
215207
self.progress = _find(QProgressBar, "progress")
216208
self.statusbar = self.findChild(QStatusBar, "statusbar")
@@ -230,78 +222,6 @@ def _find(cls, name: str):
230222
_setup_status_bar(self)
231223

232224

233-
def _tune_ide_like_layout(self) -> None:
234-
"""Relax tight layout constraints in the IDE-like UI for better label fit."""
235-
header = self.ui.findChild(QFrame, "header")
236-
if header is not None:
237-
try:
238-
header.setMinimumHeight(48)
239-
header.setMaximumHeight(56)
240-
except Exception:
241-
pass
242-
243-
for btn_name in ("compile_btn", "cancel_btn"):
244-
btn = getattr(self, btn_name, None)
245-
if btn is None:
246-
continue
247-
try:
248-
btn.setMinimumSize(124, 34)
249-
except Exception:
250-
pass
251-
252-
workspace_panel = self.ui.findChild(QFrame, "workspace_panel")
253-
if workspace_panel is not None:
254-
try:
255-
workspace_panel.setMinimumWidth(280)
256-
workspace_panel.setMaximumWidth(400)
257-
except Exception:
258-
pass
259-
260-
tools_panel = self.ui.findChild(QFrame, "tools_panel")
261-
if tools_panel is not None:
262-
try:
263-
tools_panel.setMinimumWidth(200)
264-
tools_panel.setMaximumWidth(280)
265-
except Exception:
266-
pass
267-
268-
logs_panel = self.ui.findChild(QFrame, "logs_panel")
269-
if logs_panel is not None:
270-
try:
271-
logs_panel.setMinimumHeight(190)
272-
logs_panel.setMaximumHeight(320)
273-
except Exception:
274-
pass
275-
276-
main_splitter = self.ui.findChild(QSplitter, "mainSplitter")
277-
if main_splitter is not None:
278-
try:
279-
main_splitter.setStretchFactor(0, 0)
280-
main_splitter.setStretchFactor(1, 0)
281-
main_splitter.setStretchFactor(2, 1)
282-
main_splitter.setSizes([52, 300, 1013])
283-
except Exception:
284-
pass
285-
286-
top_splitter = self.ui.findChild(QSplitter, "topSplitter")
287-
if top_splitter is not None:
288-
try:
289-
top_splitter.setStretchFactor(0, 1)
290-
top_splitter.setStretchFactor(1, 0)
291-
top_splitter.setSizes([820, 245])
292-
except Exception:
293-
pass
294-
295-
right_splitter = self.ui.findChild(QSplitter, "rightSplitter")
296-
if right_splitter is not None:
297-
try:
298-
right_splitter.setStretchFactor(0, 1)
299-
right_splitter.setStretchFactor(1, 0)
300-
right_splitter.setSizes([470, 230])
301-
except Exception:
302-
pass
303-
304-
305225
def _setup_ide_like_compiler_tabs(self) -> None:
306226
"""Bind engine tabs to compiler_tabs using existing EngineLoader registry."""
307227
tabs = getattr(self, "compiler_tabs", None)
@@ -632,9 +552,13 @@ def _retranslate_ide_like_actions(self) -> None:
632552
def _connect_ide_like_specific_signals(self) -> None:
633553
"""Connect only IDE-specific signals on top of the classic shared wiring."""
634554

635-
_connect_classic_signals(self)
636-
except Exception:
637-
pass
555+
def _connect_clicked(widget, handler) -> None:
556+
if widget is None or handler is None:
557+
return
558+
try:
559+
widget.clicked.connect(handler)
560+
except Exception:
561+
pass
638562

639563
_connect_clicked(
640564
getattr(self, "activity_btn_deps", None),
@@ -647,7 +571,6 @@ def init_ide_like_ui(self) -> None:
647571
"""Initialize the ide-like UI and wire it to existing Core methods."""
648572
_load_ide_like_ui(self)
649573
_map_ide_like_widgets(self)
650-
_tune_ide_like_layout(self)
651574
_apply_classic_policies(self)
652575
_setup_more_tools_menu(self)
653576
try:
@@ -816,47 +739,3 @@ def _schedule_ide_like_async_init(self) -> None:
816739
QTimer.singleShot(0, lambda: _setup_ide_like_compiler_tabs(self))
817740
except Exception:
818741
_setup_ide_like_compiler_tabs(self)
819-
try:
820-
QTimer.singleShot(0, lambda: _normalize_ide_splitters(self))
821-
except Exception:
822-
_normalize_ide_splitters(self)
823-
824-
825-
def _normalize_ide_splitters(self) -> None:
826-
"""Harmonize IDE panel proportions to avoid cramped labels/panels."""
827-
main_splitter = getattr(self, "mainSplitter", None)
828-
top_splitter = getattr(self, "topSplitter", None)
829-
right_splitter = getattr(self, "rightSplitter", None)
830-
831-
if main_splitter is not None:
832-
try:
833-
main_splitter.setChildrenCollapsible(False)
834-
main_splitter.setStretchFactor(0, 0)
835-
main_splitter.setStretchFactor(1, 0)
836-
main_splitter.setStretchFactor(2, 1)
837-
total = max(1100, self.width())
838-
main_splitter.setSizes([52, 320, max(640, total - 372)])
839-
except Exception:
840-
pass
841-
842-
if top_splitter is not None:
843-
try:
844-
top_splitter.setChildrenCollapsible(False)
845-
top_splitter.setStretchFactor(0, 4)
846-
top_splitter.setStretchFactor(1, 1)
847-
total = max(700, top_splitter.size().width() or self.width())
848-
tools = min(260, max(190, int(total * 0.2)))
849-
top_splitter.setSizes([max(460, total - tools), tools])
850-
except Exception:
851-
pass
852-
853-
if right_splitter is not None:
854-
try:
855-
right_splitter.setChildrenCollapsible(False)
856-
right_splitter.setStretchFactor(0, 4)
857-
right_splitter.setStretchFactor(1, 1)
858-
total_h = max(520, right_splitter.size().height() or self.height())
859-
logs_h = min(220, max(130, int(total_h * 0.24)))
860-
right_splitter.setSizes([max(320, total_h - logs_h), logs_h])
861-
except Exception:
862-
pass

docs/ide_like_gui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ python -m pycompiler_ark --ide-gui
3434
- Keeps IDE-specific affordances:
3535
- `...` activity-bar menu
3636
- dependencies activity button
37-
- Tunes the loaded layout at runtime to reduce label compression in the header, center panel, and logs area.
37+
- Defines IDE layout constraints directly in `ui/ui_ide_design2.ui` (header/buttons/panels/splitters) to keep Python wiring minimal.
3838

3939
## Runtime Switch
4040

ui/ui_ide_design2.ui

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ QProgressBar::chunk { background: #0e639c; }</string>
9191
<property name="minimumSize">
9292
<size>
9393
<width>0</width>
94-
<height>42</height>
94+
<height>48</height>
9595
</size>
9696
</property>
9797
<property name="maximumSize">
9898
<size>
9999
<width>16777215</width>
100-
<height>42</height>
100+
<height>56</height>
101101
</size>
102102
</property>
103103
<property name="frameShape">
@@ -146,8 +146,8 @@ QProgressBar::chunk { background: #0e639c; }</string>
146146
<widget class="QPushButton" name="compile_btn">
147147
<property name="minimumSize">
148148
<size>
149-
<width>110</width>
150-
<height>30</height>
149+
<width>124</width>
150+
<height>34</height>
151151
</size>
152152
</property>
153153
<property name="text">
@@ -159,8 +159,8 @@ QProgressBar::chunk { background: #0e639c; }</string>
159159
<widget class="QPushButton" name="cancel_btn">
160160
<property name="minimumSize">
161161
<size>
162-
<width>110</width>
163-
<height>30</height>
162+
<width>124</width>
163+
<height>34</height>
164164
</size>
165165
</property>
166166
<property name="text">
@@ -176,9 +176,19 @@ QProgressBar::chunk { background: #0e639c; }</string>
176176
<property name="orientation">
177177
<enum>Qt::Orientation::Horizontal</enum>
178178
</property>
179+
<property name="childrenCollapsible">
180+
<bool>false</bool>
181+
</property>
179182
<property name="handleWidth">
180183
<number>1</number>
181184
</property>
185+
<property name="sizes">
186+
<list>
187+
<number>52</number>
188+
<number>320</number>
189+
<number>993</number>
190+
</list>
191+
</property>
182192
<widget class="QFrame" name="activity_bar">
183193
<property name="minimumSize">
184194
<size>
@@ -270,7 +280,7 @@ QProgressBar::chunk { background: #0e639c; }</string>
270280
</property>
271281
<property name="maximumSize">
272282
<size>
273-
<width>380</width>
283+
<width>400</width>
274284
<height>16777215</height>
275285
</size>
276286
</property>
@@ -390,16 +400,34 @@ QProgressBar::chunk { background: #0e639c; }</string>
390400
<property name="orientation">
391401
<enum>Qt::Orientation::Vertical</enum>
392402
</property>
403+
<property name="childrenCollapsible">
404+
<bool>false</bool>
405+
</property>
393406
<property name="handleWidth">
394407
<number>1</number>
395408
</property>
409+
<property name="sizes">
410+
<list>
411+
<number>470</number>
412+
<number>230</number>
413+
</list>
414+
</property>
396415
<widget class="QSplitter" name="topSplitter">
397416
<property name="orientation">
398417
<enum>Qt::Orientation::Horizontal</enum>
399418
</property>
419+
<property name="childrenCollapsible">
420+
<bool>false</bool>
421+
</property>
400422
<property name="handleWidth">
401423
<number>1</number>
402424
</property>
425+
<property name="sizes">
426+
<list>
427+
<number>820</number>
428+
<number>245</number>
429+
</list>
430+
</property>
403431
<widget class="QTabWidget" name="compiler_tabs">
404432
<property name="currentIndex">
405433
<number>-1</number>
@@ -408,13 +436,13 @@ QProgressBar::chunk { background: #0e639c; }</string>
408436
<widget class="QFrame" name="tools_panel">
409437
<property name="minimumSize">
410438
<size>
411-
<width>170</width>
439+
<width>200</width>
412440
<height>0</height>
413441
</size>
414442
</property>
415443
<property name="maximumSize">
416444
<size>
417-
<width>260</width>
445+
<width>280</width>
418446
<height>16777215</height>
419447
</size>
420448
</property>
@@ -537,13 +565,13 @@ QProgressBar::chunk { background: #0e639c; }</string>
537565
<property name="minimumSize">
538566
<size>
539567
<width>0</width>
540-
<height>130</height>
568+
<height>190</height>
541569
</size>
542570
</property>
543571
<property name="maximumSize">
544572
<size>
545573
<width>16777215</width>
546-
<height>210</height>
574+
<height>320</height>
547575
</size>
548576
</property>
549577
<property name="frameShape">

0 commit comments

Comments
 (0)