Skip to content

Commit 2c30d77

Browse files
author
PyCompiler ARK++
committed
refactor: Simplify UI initialization and enhance layout responsiveness
1 parent db9e2ab commit 2c30d77

3 files changed

Lines changed: 97 additions & 251 deletions

File tree

Core/init_ui.py

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
QPushButton,
2929
QTextEdit,
3030
QVBoxLayout,
31+
QScrollArea,
32+
QSizePolicy,
3133
)
3234

3335
from Core import i18n as _i18n
@@ -133,14 +135,10 @@ def _detect_system_color_scheme() -> str:
133135

134136
def init_ui(self):
135137
loader = QUiLoader()
136-
# Prefer V2 UI (IDE-like). Fallback to legacy if not found.
137-
ui_v2_path = os.path.abspath(
138-
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "ui", "ui_design_v2.ui")
139-
)
140-
ui_legacy_path = os.path.abspath(
138+
# Use legacy UI exclusively
139+
ui_path = os.path.abspath(
141140
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "ui", "ui_design.ui")
142141
)
143-
ui_path = ui_v2_path if os.path.exists(ui_v2_path) else ui_legacy_path
144142

145143
ui_file = QFile(ui_path)
146144
ui_file.open(QFile.ReadOnly)
@@ -190,6 +188,28 @@ def init_ui(self):
190188
actionsPanel = self.ui.findChild(_QW, "actionsPanel")
191189
centerPanel = self.ui.findChild(_QW, "centerPanel")
192190
optionsPanel = self.ui.findChild(_QW, "optionsPanel")
191+
# Ensure side panels are scrollable to avoid overflow on small screens
192+
try:
193+
# QScrollArea already imported at module level; avoid shadowing local
194+
if self.mainSplitter:
195+
# Wrap left actionsPanel
196+
if actionsPanel and actionsPanel.parent() == self.mainSplitter:
197+
sa_left = QScrollArea()
198+
sa_left.setObjectName("actionsPanelScroll")
199+
sa_left.setWidgetResizable(True)
200+
actionsPanel.setParent(None)
201+
sa_left.setWidget(actionsPanel)
202+
self.mainSplitter.insertWidget(0, sa_left)
203+
# Wrap right optionsPanel
204+
if optionsPanel and optionsPanel.parent() == self.mainSplitter:
205+
sa_right = QScrollArea()
206+
sa_right.setObjectName("optionsPanelScroll")
207+
sa_right.setWidgetResizable(True)
208+
optionsPanel.setParent(None)
209+
sa_right.setWidget(optionsPanel)
210+
self.mainSplitter.addWidget(sa_right)
211+
except Exception:
212+
pass
193213
if self.mainSplitter:
194214
try:
195215
self.mainSplitter.setChildrenCollapsible(True)
@@ -198,7 +218,23 @@ def init_ui(self):
198218
self.mainSplitter.setCollapsible(idx, True)
199219
except Exception:
200220
pass
201-
self.mainSplitter.setSizes([260, 700, 360])
221+
try:
222+
from PySide6.QtGui import QGuiApplication
223+
screen = QGuiApplication.primaryScreen()
224+
avail_w = screen.availableGeometry().width() if screen else 1200
225+
except Exception:
226+
avail_w = 1200
227+
# Compute sizes with reasonable proportions and minimums
228+
left = max(200, int(avail_w * 0.22))
229+
right = max(240, int(avail_w * 0.24))
230+
center = max(300, int(avail_w - (left + right)))
231+
self.mainSplitter.setSizes([left, center, right])
232+
try:
233+
self.mainSplitter.setStretchFactor(0, 0)
234+
self.mainSplitter.setStretchFactor(1, 1)
235+
self.mainSplitter.setStretchFactor(2, 0)
236+
except Exception:
237+
pass
202238
except Exception:
203239
pass
204240
# Create a vertical splitter for editor/console inside centerPanel
@@ -225,7 +261,20 @@ def init_ui(self):
225261
centerSplitter.addWidget(consolePanel)
226262
centerLayout.addWidget(centerSplitter)
227263
try:
228-
centerSplitter.setSizes([500, 200])
264+
try:
265+
from PySide6.QtGui import QGuiApplication
266+
screen = QGuiApplication.primaryScreen()
267+
avail_h = screen.availableGeometry().height() if screen else 800
268+
except Exception:
269+
avail_h = 800
270+
editor_h = max(260, int(avail_h * 0.62))
271+
console_h = max(120, int(avail_h * 0.22))
272+
centerSplitter.setSizes([editor_h, console_h])
273+
try:
274+
centerSplitter.setStretchFactor(0, 1)
275+
centerSplitter.setStretchFactor(1, 0)
276+
except Exception:
277+
pass
229278
except Exception:
230279
pass
231280
self.centerSplitter = centerSplitter
@@ -857,6 +906,18 @@ def nuitka_standalone_changed(state):
857906
except Exception:
858907
pass
859908

909+
# Auto-fit main window to screen bounds
910+
try:
911+
from PySide6.QtGui import QGuiApplication
912+
scr = QGuiApplication.primaryScreen()
913+
if scr:
914+
avail = scr.availableGeometry()
915+
target_w = min(max(800, self.width()), max(640, avail.width() - 24))
916+
target_h = min(max(500, self.height()), max(480, avail.height() - 24))
917+
self.resize(target_w, target_h)
918+
except Exception:
919+
pass
920+
860921

861922
def add_pyinstaller_data(self):
862923
import os

ENGINES/cx_freeze/engine.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,10 @@ def create_tab(self, gui):
789789
# Title
790790
try:
791791
title = QLabel(gui.tr("Options cx_Freeze", "cx_Freeze Options"))
792-
layout.addWidget(title)
792+
try:
793+
title.setVisible(False)
794+
except Exception:
795+
pass
793796
self._cx_title = title
794797
except Exception:
795798
self._cx_title = None
@@ -807,6 +810,11 @@ def create_tab(self, gui):
807810
except Exception:
808811
pass
809812
browse_btn = QPushButton(gui.tr("Parcourir…", "Browse…"))
813+
try:
814+
browse_btn.setObjectName("cx_output_browse")
815+
browse_btn.setEnabled(True)
816+
except Exception:
817+
pass
810818
self._cx_out_browse_btn = browse_btn
811819

812820
def _browse():
@@ -909,6 +917,11 @@ def _browse():
909917
self._cx_icon_title = None
910918
icon_edit = QLineEdit()
911919
icon_btn = QPushButton(gui.tr("Parcourir…", "Browse…"))
920+
try:
921+
icon_btn.setObjectName("cx_icon_browse")
922+
icon_btn.setEnabled(True)
923+
except Exception:
924+
pass
912925
self._cx_icon_browse_btn = icon_btn
913926

914927
def _browse_icon():
@@ -1351,17 +1364,20 @@ def on_success(self, gui, file: str) -> None:
13511364
base = getattr(gui, "workspace_dir", None) or os.getcwd()
13521365
out_dir = os.path.join(base, "dist")
13531366
if out_dir and os.path.isdir(out_dir):
1354-
system = platform.system()
1355-
if system == "Windows":
1356-
os.startfile(out_dir)
1357-
elif system == "Linux":
1358-
import subprocess as _sp
1359-
1360-
_sp.run(["xdg-open", out_dir])
1361-
else:
1362-
import subprocess as _sp
1363-
1364-
_sp.run(["open", out_dir])
1367+
try:
1368+
from PySide6.QtCore import QUrl
1369+
from PySide6.QtGui import QDesktopServices
1370+
QDesktopServices.openUrl(QUrl.fromLocalFile(out_dir))
1371+
except Exception:
1372+
system = platform.system()
1373+
if system == "Windows":
1374+
os.startfile(out_dir)
1375+
elif system == "Linux":
1376+
import subprocess as _sp
1377+
_sp.run(["xdg-open", out_dir])
1378+
else:
1379+
import subprocess as _sp
1380+
_sp.run(["open", out_dir])
13651381
except Exception as e:
13661382
try:
13671383
self._log(

0 commit comments

Comments
 (0)