Skip to content

Commit 35cfe9d

Browse files
committed
Style two-field rows and value widgets
Refactor _make_two_field_row to provide clear label/value styling instead of hard minimum widths. Adds a label_min_width parameter, muted label alignment, and a QSS-based style for value widgets (bolder text, subtle background, border and padding) that also supports custom widgets like ElidingPathLabel. Adjusts widget ordering and spacing for a compact two-field layout. Also wires the detected resolution/FPS labels into the new two-field row layout (removing commented-out addRow calls) for a consistent appearance.
1 parent 7f5de83 commit 35cfe9d

1 file changed

Lines changed: 44 additions & 10 deletions

File tree

dlclivegui/gui/camera_config_dialog.py

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,59 @@ def _make_two_field_row(
322322
right_widget: QWidget,
323323
left_stretch: int = 1,
324324
right_stretch: int = 1,
325+
*,
326+
label_min_width: int = 30,
325327
) -> QWidget:
326-
"""Create a compact two-field row widget: (label+widget) (label+widget)."""
328+
"""Create a compact two-field row widget: (label+value) (label+value), with clear label/value styling."""
327329
row = QWidget()
328330
layout = QHBoxLayout(row)
329331
layout.setContentsMargins(0, 0, 0, 0)
330332
layout.setSpacing(8)
331333

332-
l1 = QLabel(left_label)
333-
l1.setMinimumWidth(30)
334-
layout.addWidget(l1, 0)
335-
layout.addWidget(left_widget, left_stretch)
334+
def style_key(lbl: QLabel):
335+
# Muted label styling
336+
lbl.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
337+
# lbl.setMinimumWidth(label_min_width)
338+
# lbl.setStyleSheet(
339+
# """
340+
# QLabel {
341+
# color: rgba(255,255,255,0.65); /* works OK on dark themes */
342+
# color: palette(mid); /* fallback on light themes */
343+
# font-weight: 500;
344+
# }
345+
# """
346+
# )
347+
348+
def style_value(w: QWidget):
349+
# Make values stand out (works for QLabel and custom value widgets like ElidingPathLabel)
350+
# Using QSS that gives a subtle "field" look.
351+
w.setStyleSheet(
352+
"""
353+
QLabel, ElidingPathLabel {
354+
font-weight: 700;
355+
color: palette(text);
356+
background-color: rgba(127,127,127,0.12);
357+
border: 1px solid rgba(127,127,127,0.18);
358+
border-radius: 6px;
359+
padding: 2px 6px;
360+
}
361+
"""
362+
)
363+
if isinstance(w, QLabel):
364+
w.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
336365

337-
layout.addSpacing(8)
366+
l1 = QLabel(left_label)
367+
style_key(l1)
368+
style_value(left_widget)
338369

339370
l2 = QLabel(right_label)
340-
l2.setMinimumWidth(30)
341-
layout.addWidget(l2, 0)
371+
style_key(l2)
372+
style_value(right_widget)
373+
374+
layout.addWidget(l1, 1)
375+
layout.addWidget(left_widget, left_stretch)
376+
layout.addSpacing(8)
377+
layout.addWidget(l2, 1)
342378
layout.addWidget(right_widget, right_stretch)
343379

344380
return row
@@ -499,11 +535,9 @@ def _setup_ui(self) -> None:
499535
# --- Detected read-only labels (do NOT change requested values) ---
500536
self.detected_resolution_label = QLabel("—")
501537
self.detected_resolution_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
502-
# self.settings_form.addRow("Detected res:", self.detected_resolution_label)
503538

504539
self.detected_fps_label = QLabel("—")
505540
self.detected_fps_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
506-
# self.settings_form.addRow("Detected FPS:", self.detected_fps_label)
507541
detected_row = self._make_two_field_row(
508542
"Detected resolution:", self.detected_resolution_label, "Detected FPS:", self.detected_fps_label
509543
)

0 commit comments

Comments
 (0)