HwSettingsWidget
HwSettingsWidget is an embeddable QWidget that renders the settings registered
in the HardwareRegistry for a specific hardware type and driver. It
appears in two places in the hardware workflow:
AddProfileDialog (Create mode) — shown when the user creates a new hardware profile. Required settings are presented as editable typed widgets so the user can supply construction-time values before the hardware object is instantiated.
HWDialog (Edit mode) — shown when the user opens an existing profile for editing via the Hardware Menu or the Hardware and Library Configuration pages. Required settings are rendered as read-only text rows because they must not change after the hardware object has been constructed.
See the Hardware Profiles page for the full profile creation and editing workflow.
Required / Important / Optional tiers
Settings are organized into three priority tiers driven by the
HwSettingPriority values (documented on the
HardwareRegistry page) and registered in the
HardwareRegistry:
Required — construction-time settings that identify the hardware instance (port, address, channel assignment, etc.). Rendered in a
QFormLayoutat the top of the widget. Editable in Create mode; read-only in Edit mode.Important — settings with sensible defaults that the user should review. Rendered in an always-visible two-column table.
Optional — rarely changed settings. Rendered in a collapsible two-column table inside a
QGroupBoxlabeled Advanced Settings in the UI.
Array settings
Settings declared as array types (HwArraySettingDef) appear as a table row showing
the current entry count and an Edit button. Pressing the button opens
HwArrayEditDialog, which lets the user add, remove, and reorder the array entries.
The updated entries are stored in the widget and returned by arrayValues().
Extracting values
After the user closes the parent dialog, the caller retrieves the entered data through two methods:
values()— returns all scalar settings as aQHash<QString, QVariant>keyed bySettingsStoragekey. In Create mode this covers all tiers; in Edit mode it covers the Important and Optional tiers only (Required settings are read-only).arrayValues()— returns array settings as aQMap<QString, std::vector<SettingsStorage::SettingsMap>>.
In Edit mode the caller can alternatively call saveToStorage(storageKey) to write
both scalar and array values directly to SettingsStorage.
API Reference
-
enum class HwSettingsMode
Display mode for HwSettingsWidget.
Create: Required settings are shown as editable typed widgets (for AddProfileDialog, before the hardware object is constructed).
Edit: Required settings are shown as read-only text rows (for HWDialog, where Required settings must not change post-creation).
Values:
-
enumerator Create
-
enumerator Edit
-
class HwSettingsWidget : public QWidget
Embeddable widget that renders hardware settings from the HardwareRegistry grouped by priority.
Settings are drawn from the HardwareRegistry for a given hardware type and driver and are presented in three tiers:
Required — editable QFormLayout in Create mode; read-only text rows in Edit mode.
Important — always-visible two-column table.
Optional/Advanced — collapsible two-column table inside a QGroupBox.
Array settings appear as a table row with an inline entry count and an Edit button that opens HwArrayEditDialog.
Public Functions
-
explicit HwSettingsWidget(const QString &hwType, const QString &impl, HwSettingsMode mode, const QString &storageKey = {}, QWidget *parent = nullptr)
Construct the settings widget.
- Parameters:
hwType – Hardware type key (e.g., “FtmwDigitizer”)
impl – Implementation key (e.g., “VirtualFtmwDigitizer”)
mode – Create or Edit mode (controls Required section editability)
storageKey – SettingsStorage key to pre-populate current values from. Pass an empty string in Create mode to use registry defaults.
parent – Parent widget
-
QHash<QString, QVariant> values() const
Return current scalar values keyed by SettingsStorage key.
In Create mode returns all priority tiers. In Edit mode returns Important and Optional values only (Required are read-only).
-
QMap<QString, std::vector<SettingsStorage::SettingsMap>> arrayValues() const
Return current array values keyed by array key.
-
void saveToStorage(const QString &storageKey) const
Write all scalar and array values to SettingsStorage.
- Parameters:
storageKey – The SettingsStorage key for the hardware instance.
Private Functions
-
void populate(const QString &storageKey)
-
QWidget *makeScalarWidget(const HwSettingDef &def, const QVariant ¤tValue)
-
QVariant readWidget(QWidget *widget, const QVariant &defaultValue) const
-
QVariant scalarValueForStorage(const HwSettingDef &def) const
-
void addArrayTableRow(SettingsTable *table, const HwArraySettingDef &def)
-
QStringList subKeysForArray(const HwArraySettingDef &def) const
-
void linkDisplayUnitScalars(const QVector<HwSettingDef> &settingDefs)
Link the display-unit-aware scalar boxes registered via HwSettingDef::displayUnitKey to their sibling LaserUnit combo boxes, converting the box’s registered cm⁻¹ range/value to the combo’s currently-selected display unit.
Called once after the scalar-widget loop in populate() so build order within d_scalarWidgets does not matter. Only settings whose displayUnitKey names a sibling widget that resolves to a BC::LifConv::LaserUnit are linked; anything else is left as a plain cm⁻¹ box.
-
void applyDisplayUnit(UnitLinkedScalar &linked, BC::LifConv::LaserUnit u, double canonicalValue)
Reconfigure a display-unit-linked box (range, suffix, decimals, value) for display unit u, converting the caller-supplied canonical cm⁻¹ value canonicalValue into the new unit.
-
void pushGatedRow(const QString &gateKey, const QVariant &gateValue, std::function<void(bool)> setVisible)
Record a gated row for later processing by applyGates().
No-op when gateKey is empty (the common, ungated case), so call sites do not need their own emptiness check.
- Parameters:
gateKey – Sibling enum setting key (HwSettingDef::gateKey / HwArraySettingDef::gateKey).
gateValue – Enum value gateKey must hold for the row to be visible.
setVisible – Closure that shows/hides this specific row.
-
void applyGates()
Resolve each recorded GatedRow’s gate widget and wire it to show/hide the row on change, applying the initial visibility immediately.
Called once after both the scalar and array setting loops in populate(), mirroring linkDisplayUnitScalars(): a gated row’s gate widget is always a scalar (an EnumComboBoxBase-backed combo in d_scalarWidgets), and by the time this runs the scalar loop has already populated d_scalarWidgets regardless of whether the gated row itself came from the scalar or array loop. A gateKey that does not resolve to a combo box (absent, or a non-enum widget) leaves the row visible, matching linkDisplayUnitScalars’s handling of a mismatched displayUnitKey.
Private Members
-
QString d_hwType
-
QString d_impl
-
HwSettingsMode d_mode
-
QTabWidget *p_tabWidget = {nullptr}
-
QLabel *p_noSettingsLabel = {nullptr}
-
QFormLayout *p_requiredLayout = {nullptr}
-
QGroupBox *p_requiredGroup = {nullptr}
-
SettingsTable *p_importantTable = {nullptr}
-
QGroupBox *p_importantGroup = {nullptr}
-
SettingsTable *p_advancedTable = {nullptr}
-
QHash<QString, QWidget*> d_scalarWidgets
-
QMap<QString, std::vector<SettingsStorage::SettingsMap>> d_arrayValues
-
std::vector<UnitLinkedScalar> d_unitLinkedScalars
-
struct GatedRow
Bookkeeping for one gated row (HwSettingDef::gateKey / HwArraySettingDef::gateKey): which sibling enum setting gates it, the value it must hold, and how to show/hide the row itself.
setVisibleis a closure over whichever widget(s) make up that row (a QFormLayout field for Required settings, or a SettingsTable row index for Important/Optional settings and arrays) so applyGates() does not need to know the layout details of each tier.
-
struct UnitLinkedScalar
Bookkeeping for one HwSettingDef::displayUnitKey-linked scalar box: which double box, which sibling unit combo, and the display unit it is currently configured for (needed so a unit change can convert from the previous display value rather than re-deriving from the stale registered cm⁻¹ bounds).
Public Members
-
ScientificSpinBox *box
The double-typed setting’s widget (makeScalarWidget always uses ScientificSpinBox for QMetaType::Double defs; it is a QAbstractSpinBox, not a QDoubleSpinBox).
-
QComboBox *unitCombo
Sibling LaserUnit combo box (EnumComboBoxBase).
-
QString settingKey
def.key for the linked double box.
-
BC::LifConv::LaserUnit displayedUnit
Unit the box is currently showing.
-
QVariant minCm1
Registered def.minimum (canonical cm⁻¹), may be invalid.
-
QVariant maxCm1
Registered def.maximum (canonical cm⁻¹), may be invalid.
-
ScientificSpinBox *box