Allow multiple widgets in config form
This commit is contained in:
@@ -589,16 +589,8 @@ class GuiPreferences(QDialog):
|
|||||||
self.altDialogClose.setAlignment(QtAlignCenter)
|
self.altDialogClose.setAlignment(QtAlignCenter)
|
||||||
self.altDialogClose.setText(CONFIG.altDialogClose)
|
self.altDialogClose.setText(CONFIG.altDialogClose)
|
||||||
|
|
||||||
self.altDialogBox = QHBoxLayout()
|
|
||||||
self.altDialogBox.addWidget(self.altDialogOpen)
|
|
||||||
self.altDialogBox.addWidget(self.altDialogClose)
|
|
||||||
self.altDialogBox.setContentsMargins(0, 0, 0, 0)
|
|
||||||
|
|
||||||
self.altDialog = QWidget(self)
|
|
||||||
self.altDialog.setLayout(self.altDialogBox)
|
|
||||||
|
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
self.tr("Alternative dialog symbols"), self.altDialog,
|
self.tr("Alternative dialog symbols"), [self.altDialogOpen, self.altDialogClose],
|
||||||
self.tr("Custom highlighting of dialog text.")
|
self.tr("Custom highlighting of dialog text.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -180,16 +180,26 @@ class NScrollableForm(QScrollArea):
|
|||||||
self._sections[identifier] = qLabel
|
self._sections[identifier] = qLabel
|
||||||
return
|
return
|
||||||
|
|
||||||
def addRow(self, label: str, widget: QWidget, helpText: str = "", unit: str | None = None,
|
def addRow(self, label: str, widget: QWidget | list[QWidget], helpText: str = "",
|
||||||
button: QWidget | None = None, editable: str | None = None,
|
unit: str | None = None, button: QWidget | None = None, editable: str | None = None,
|
||||||
stretch: tuple[int, int] = (1, 0)) -> None:
|
stretch: tuple[int, int] = (1, 0)) -> None:
|
||||||
"""Add a label and a widget as a new row of the form."""
|
"""Add a label and a widget as a new row of the form."""
|
||||||
row = QHBoxLayout()
|
row = QHBoxLayout()
|
||||||
row.setSpacing(CONFIG.pxInt(12))
|
row.setSpacing(CONFIG.pxInt(12))
|
||||||
|
|
||||||
|
if isinstance(widget, list):
|
||||||
|
wBox = QHBoxLayout()
|
||||||
|
wBox.setContentsMargins(0, 0, 0, 0)
|
||||||
|
for item in widget:
|
||||||
|
wBox.addWidget(item)
|
||||||
|
qWidget = QWidget(self)
|
||||||
|
qWidget.setLayout(wBox)
|
||||||
|
else:
|
||||||
|
qWidget = widget
|
||||||
|
|
||||||
qLabel = QLabel(label, self)
|
qLabel = QLabel(label, self)
|
||||||
qLabel.setIndent(self._indent)
|
qLabel.setIndent(self._indent)
|
||||||
qLabel.setBuddy(widget)
|
qLabel.setBuddy(qWidget)
|
||||||
|
|
||||||
if helpText:
|
if helpText:
|
||||||
qHelp = NColourLabel(
|
qHelp = NColourLabel(
|
||||||
@@ -208,19 +218,19 @@ class NScrollableForm(QScrollArea):
|
|||||||
|
|
||||||
if isinstance(unit, str):
|
if isinstance(unit, str):
|
||||||
box = QHBoxLayout()
|
box = QHBoxLayout()
|
||||||
box.addWidget(widget, 1)
|
box.addWidget(qWidget, 1)
|
||||||
box.addWidget(QLabel(unit, self), 0)
|
box.addWidget(QLabel(unit, self), 0)
|
||||||
row.addLayout(box, stretch[1])
|
row.addLayout(box, stretch[1])
|
||||||
elif isinstance(button, QAbstractButton):
|
elif isinstance(button, QAbstractButton):
|
||||||
box = QHBoxLayout()
|
box = QHBoxLayout()
|
||||||
box.addWidget(widget, 1)
|
box.addWidget(qWidget, 1)
|
||||||
box.addWidget(button, 0)
|
box.addWidget(button, 0)
|
||||||
row.addLayout(box, stretch[1])
|
row.addLayout(box, stretch[1])
|
||||||
else:
|
else:
|
||||||
row.addWidget(widget, stretch[1])
|
row.addWidget(qWidget, stretch[1])
|
||||||
|
|
||||||
self._layout.addLayout(row)
|
self._layout.addLayout(row)
|
||||||
self._index[label.strip()] = widget
|
self._index[label.strip()] = qWidget
|
||||||
self._first = False
|
self._first = False
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user