diff --git a/channelwidget.cpp b/channelwidget.cpp index f3cc2f7..5c32f45 100644 --- a/channelwidget.cpp +++ b/channelwidget.cpp @@ -1,4 +1,3 @@ - #include "channelwidget.h" #include #include @@ -27,7 +26,6 @@ ChannelWidget::ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber, line.setFrameShadow(QFrame::Sunken); vlayout.addWidget(&line); - // Add Unganged option first gangcombo.addItem("Unganged"); hlayout.addStretch(); @@ -35,7 +33,6 @@ ChannelWidget::ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber, hlayout.addWidget(&gangcombo); hlayout.addWidget(&checkbox); - // Connect signals connect(&checkbox, &QCheckBox::toggled, this, &ChannelWidget::onChannelToggled); connect(&gangcombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ChannelWidget::onGangComboChanged); @@ -47,7 +44,7 @@ ChannelWidget::ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber, ChannelWidget::~ChannelWidget() { - // Nothing to clean up + } uint16_t ChannelWidget::getDeviceSerial() const @@ -83,7 +80,7 @@ void ChannelWidget::onChannelToggled(bool checked) qWarning() << "Failed to connect channel" << channelNumber << "on device" << deviceSerial; checkbox.blockSignals(true); checkbox.setChecked(false); - setEnabled(false); // Gray out the widget + setEnabled(false); } } else @@ -95,7 +92,7 @@ void ChannelWidget::onChannelToggled(bool checked) qWarning() << "Failed to disconnect channel" << channelNumber << "on device" << deviceSerial; checkbox.blockSignals(true); checkbox.setChecked(true); - setEnabled(false); // Gray out the widget + setEnabled(false); } } @@ -107,11 +104,11 @@ void ChannelWidget::onGangComboChanged(int index) { if (index == 0) { // Unganged selected - reset ganged channel tracking - gangedDeviceSerial = 0; - gangedChannelNumber = 0; + gangedDeviceSerial = -1; + gangedChannelNumber = -1; checkbox.setEnabled(true); checkbox.setChecked(false); - checkbox.setChecked(false); // Reset to false to avoid leaving it checked when unganged + checkbox.setChecked(false); } else { // A ganged channel was selected QString currentText = gangcombo.currentText(); @@ -149,12 +146,9 @@ void ChannelWidget::updateGangCombo() void ChannelWidget::updateCheckboxState() { - // If we're ganged, update our state to match the ganged channel - if (gangedDeviceSerial != 0 && gangedChannelNumber != 0) { + if (gangedDeviceSerial >= 0 && gangedChannelNumber >= 0) { checkbox.setEnabled(false); - // We need to check the state of the ganged channel and sync - // This would typically be done by querying the actual channel state - // but for now we'll assume the ganged channel's state is known + // TODO check current ganged channel state } else { checkbox.setEnabled(true); } diff --git a/channelwidget.h b/channelwidget.h index 0c00e3f..959ad86 100644 --- a/channelwidget.h +++ b/channelwidget.h @@ -1,5 +1,3 @@ - - #ifndef CHANNELWIDGET_H #define CHANNELWIDGET_H @@ -58,8 +56,8 @@ private: QVBoxLayout labellayout; // Track the channel this one is ganged to (if any) - uint16_t gangedDeviceSerial = 0; - uint16_t gangedChannelNumber = 0; + int gangedDeviceSerial = -1; + int gangedChannelNumber = -1; }; #endif // CHANNELWIDGET_H diff --git a/mainwindow.cpp b/mainwindow.cpp index bb51f00..b69934e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,5 +1,3 @@ - - #include #include #include "mainwindow.h"