fix(ai-outfit): stop combos from clipping the left column (§10.1)
Constrain the 样本行 and AI 模型 combos (AdjustToMinimumContentsLengthWithIcon + minimumContentsLength + Ignored size policy) so long items elide instead of inflating the column's min width. Left scroll h-policy AlwaysOff -> AsNeeded as a safety net; trim splitter initial sizes to fit the default window. Measured: left inner minimumSizeHint 829px -> 200px (viewport ~398), no clip. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,7 @@ from PySide6.QtWidgets import (
|
||||
QProgressBar,
|
||||
QPushButton,
|
||||
QScrollArea,
|
||||
QSizePolicy,
|
||||
QSpinBox,
|
||||
QSplitter,
|
||||
QTableWidget,
|
||||
@@ -161,13 +162,15 @@ class AiOutfitPanel(QWidget):
|
||||
splitter.setStretchFactor(0, 0)
|
||||
splitter.setStretchFactor(1, 1)
|
||||
splitter.setStretchFactor(2, 0)
|
||||
splitter.setSizes([430, 760, 300])
|
||||
splitter.setSizes([400, 600, 300])
|
||||
outer.addWidget(splitter)
|
||||
|
||||
def _build_left(self):
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
# AsNeeded (not AlwaysOff): if a child ever exceeds the column it scrolls
|
||||
# instead of being clipped under the center panel (docs/11 §10.1).
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
scroll.setMinimumWidth(360)
|
||||
inner = QWidget()
|
||||
col = QVBoxLayout(inner)
|
||||
@@ -190,6 +193,7 @@ class AiOutfitPanel(QWidget):
|
||||
ov.addLayout(self._path_row(self._output_edit, self._browse_output))
|
||||
ov.addWidget(QLabel("AI 模型"))
|
||||
self._model_combo = QComboBox()
|
||||
self._compact_combo(self._model_combo)
|
||||
ov.addWidget(self._model_combo)
|
||||
col.addWidget(out)
|
||||
|
||||
@@ -217,6 +221,7 @@ class AiOutfitPanel(QWidget):
|
||||
srow = QHBoxLayout()
|
||||
srow.addWidget(QLabel("样本行"))
|
||||
self._sample_combo = QComboBox()
|
||||
self._compact_combo(self._sample_combo)
|
||||
self._sample_combo.currentIndexChanged.connect(self._refresh_preview)
|
||||
srow.addWidget(self._sample_combo, stretch=1)
|
||||
pvw.addLayout(srow)
|
||||
@@ -281,6 +286,13 @@ class AiOutfitPanel(QWidget):
|
||||
v.addWidget(widget)
|
||||
return cell
|
||||
|
||||
def _compact_combo(self, combo):
|
||||
"""Keep a combo from dictating column width: elide long items instead of
|
||||
expanding its minimum size hint (docs/11 §10.1)."""
|
||||
combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||
combo.setMinimumContentsLength(6)
|
||||
combo.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
|
||||
|
||||
def _path_row(self, line_edit, on_browse):
|
||||
row = QHBoxLayout()
|
||||
row.addWidget(line_edit, stretch=1)
|
||||
|
||||
Reference in New Issue
Block a user