feat(radio): refactor of switch handling to better support customisable switches (#6095)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
3djc
elecpower
parent
28833f42e6
commit
0c8c39b134
@@ -219,12 +219,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
|
||||
// Startup switches warnings
|
||||
for (int i = 0; i < Boards::getBoardCapability(board, Board::Switches); i++) {
|
||||
GeneralSettings::SwitchConfig &swcfg = generalSettings.switchConfig[i];
|
||||
|
||||
if (Boards::isSwitchFunc(i, board) || !generalSettings.isSwitchAvailable(i) || swcfg.type == Board::SWITCH_TOGGLE) {
|
||||
model.switchWarningEnable |= (1 << i);
|
||||
continue;
|
||||
}
|
||||
Board::SwitchType swType = model.getSwitchType(i, generalSettings);
|
||||
|
||||
RawSource src(RawSourceType::SOURCE_TYPE_SWITCH, i + 1);
|
||||
QLabel * label = new QLabel(this);
|
||||
@@ -242,7 +237,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
slider->setPageStep(1);
|
||||
slider->setTickInterval(1);
|
||||
label->setText(src.toString(&model, &generalSettings));
|
||||
slider->setMaximum(swcfg.type == Board::SWITCH_3POS ? 2 : 1);
|
||||
slider->setMaximum(swType == Board::SWITCH_3POS ? 2 : 1);
|
||||
cb->setProperty("index", i);
|
||||
ui->switchesStartupLayout->addWidget(label, 0, i + 1);
|
||||
ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter);
|
||||
@@ -252,6 +247,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
ui->switchesStartupLayout->setAlignment(cb, Qt::AlignCenter);
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool)));
|
||||
startupSwitchesLabels << label;
|
||||
startupSwitchesSliders << slider;
|
||||
startupSwitchesCheckboxes << cb;
|
||||
QWidget::setTabOrder(prevFocus, slider);
|
||||
@@ -338,6 +334,12 @@ SetupPanel::~SetupPanel()
|
||||
delete panelItemModels;
|
||||
}
|
||||
|
||||
bool SetupPanel::canSwitchHaveWarning(int sw)
|
||||
{
|
||||
Board::SwitchType type = model->getSwitchType(sw, generalSettings);
|
||||
return (type == Board::SWITCH_2POS) || (type == Board::SWITCH_3POS);
|
||||
}
|
||||
|
||||
void SetupPanel::on_extendedLimits_toggled(bool checked)
|
||||
{
|
||||
model->extendedLimits = checked;
|
||||
@@ -510,23 +512,20 @@ void SetupPanel::updateStartupSwitches()
|
||||
uint64_t value;
|
||||
|
||||
for (int i = 0; i < startupSwitchesSliders.size(); i++) {
|
||||
QLabel * label = startupSwitchesLabels[i];
|
||||
QSlider * slider = startupSwitchesSliders[i];
|
||||
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
||||
int index = slider->property("index").toInt();
|
||||
bool enabled = !(model->switchWarningEnable & (1 << index));
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard())) {
|
||||
value = (switchStates >> (2 * index)) & 0x03;
|
||||
if (generalSettings.switchConfig[index].type != Board::SWITCH_3POS && value == 2) {
|
||||
value = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = (i == 0 ? switchStates & 0x3 : switchStates & 0x1);
|
||||
switchStates >>= (i == 0 ? 2 : 1);
|
||||
}
|
||||
slider->setValue(value);
|
||||
value = (switchStates >> (2 * index)) & 0x03;
|
||||
bool enabled = value != 0;
|
||||
if (model->getSwitchType(i, generalSettings) == Board::SWITCH_2POS && value == 3) value = 2;
|
||||
slider->setValue((value > 0) ? value - 1 : 0);
|
||||
slider->setEnabled(enabled);
|
||||
cb->setChecked(enabled);
|
||||
bool vis = canSwitchHaveWarning(i);
|
||||
label->setVisible(vis);
|
||||
slider->setVisible(vis);
|
||||
cb->setVisible(vis);
|
||||
}
|
||||
|
||||
lock = false;
|
||||
@@ -539,31 +538,14 @@ void SetupPanel::startupSwitchEdited(int value)
|
||||
uint64_t mask;
|
||||
int index = sender()->property("index").toInt();
|
||||
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard())) {
|
||||
shift = index * 2;
|
||||
mask = 0x03ull << shift;
|
||||
}
|
||||
else {
|
||||
if (index == 0) {
|
||||
mask = 0x03;
|
||||
}
|
||||
else {
|
||||
shift = index + 1;
|
||||
mask = 0x01ull << shift;
|
||||
}
|
||||
}
|
||||
shift = index * 2;
|
||||
mask = 0x03ull << shift;
|
||||
|
||||
model->switchWarningStates &= ~mask;
|
||||
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard()) && generalSettings.switchConfig[index].type != Board::SWITCH_3POS) {
|
||||
if (value == 1) {
|
||||
value = 2;
|
||||
}
|
||||
}
|
||||
if (model->getSwitchType(index, generalSettings) == Board::SWITCH_2POS && value == 1) value = 2;
|
||||
|
||||
if (value) {
|
||||
model->switchWarningStates |= ((uint64_t)value << shift);
|
||||
}
|
||||
model->switchWarningStates |= ((uint64_t)(value + 1) << shift);
|
||||
|
||||
updateStartupSwitches();
|
||||
emit modified();
|
||||
@@ -576,9 +558,9 @@ void SetupPanel::startupSwitchToggled(bool checked)
|
||||
int index = sender()->property("index").toInt();
|
||||
|
||||
if (checked)
|
||||
model->switchWarningEnable &= ~(1 << index);
|
||||
model->switchWarningStates |= (1 << (index * 2));
|
||||
else
|
||||
model->switchWarningEnable |= (1 << index);
|
||||
model->switchWarningStates &= ~(3 << (index * 2));
|
||||
|
||||
updateStartupSwitches();
|
||||
emit modified();
|
||||
@@ -866,5 +848,6 @@ void SetupPanel::onModuleUpdateItemModels()
|
||||
|
||||
void SetupPanel::onFunctionSwitchesUpdateItemModels()
|
||||
{
|
||||
updateStartupSwitches();
|
||||
sharedItemModels->update(AbstractItemModel::IMUE_FunctionSwitches);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ class SetupPanel : public ModelPanel
|
||||
|
||||
private:
|
||||
Ui::Setup *ui;
|
||||
QVector<QLabel *> startupSwitchesLabels;
|
||||
QVector<QSlider *> startupSwitchesSliders;
|
||||
QVector<QCheckBox *> startupSwitchesCheckboxes;
|
||||
QVector<QCheckBox *> potWarningCheckboxes;
|
||||
@@ -97,6 +98,7 @@ class SetupPanel : public ModelPanel
|
||||
TimerPanel * timers[CPN_MAX_TIMERS];
|
||||
FunctionSwitchesPanel * funcswitches;
|
||||
|
||||
bool canSwitchHaveWarning(int sw);
|
||||
void updateStartupSwitches();
|
||||
void updatePotWarnings();
|
||||
void updateBeepCenter();
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ui_setup_function_switches.h"
|
||||
#include "namevalidator.h"
|
||||
#include "autolineedit.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
@@ -42,13 +43,16 @@ bool FilteredGroupSwitchesModel::filterAcceptsRow(int sourceRow, const QModelInd
|
||||
bool FilteredSwitchGroupsModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
|
||||
{
|
||||
if (sourceRow == 0) return true;
|
||||
if (m_model->getFuncSwitchConfig(m_switch) == ModelData::FUNC_SWITCH_CONFIG_NONE) return false;
|
||||
if (m_model->getFuncSwitchConfig(m_switch) == Board::SWITCH_NOT_AVAILABLE) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FilteredSwitchConfigsModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
|
||||
{
|
||||
if (sourceRow == ModelData::FUNC_SWITCH_CONFIG_NONE || sourceRow == ModelData::FUNC_SWITCH_CONFIG_2POS) return true;
|
||||
if (sourceRow == Board::SWITCH_3POS)
|
||||
return false;
|
||||
if (sourceRow == Board::SWITCH_NOT_AVAILABLE || sourceRow == Board::SWITCH_2POS || sourceRow == Board::SWITCH_GLOBAL)
|
||||
return true;
|
||||
return !m_model->getFuncSwitchAlwaysOnGroupForSwitch(m_switch);
|
||||
}
|
||||
|
||||
@@ -70,51 +74,122 @@ FunctionSwitchesPanel::FunctionSwitchesPanel(QWidget * parent, ModelData & model
|
||||
|
||||
fsGroupStart = ModelData::funcSwitchGroupStartSwitchModel(switchcnt);
|
||||
|
||||
for (int i = 0; i < switchcnt; i++) {
|
||||
QLabel * lblSwitchId = new QLabel(this);
|
||||
lblSwitchId->setText(tr("SW%1").arg(i + 1));
|
||||
|
||||
AutoLineEdit * aleName = new AutoLineEdit(this);
|
||||
aleName->setProperty("index", i);
|
||||
aleName->setValidator(new NameValidator(board, this));
|
||||
aleName->setField((char *)model.functionSwitchNames[i], 3);
|
||||
|
||||
QComboBox * cboConfig = new QComboBox(this);
|
||||
cboConfig->setProperty("index", i);
|
||||
auto configFilter = new FilteredSwitchConfigsModel(fsConfig, i, &model);
|
||||
cboConfig->setModel(configFilter);
|
||||
filterSwitchConfigs << configFilter;
|
||||
|
||||
QComboBox * cboStartPosn = new QComboBox(this);
|
||||
cboStartPosn->setProperty("index", i);
|
||||
cboStartPosn->setModel(fsStart);
|
||||
|
||||
QComboBox * cboGroup = new QComboBox(this);
|
||||
cboGroup->setProperty("index", i);
|
||||
auto groupFilter = new FilteredSwitchGroupsModel(fsGroups, i, &model);
|
||||
cboGroup->setModel(groupFilter);
|
||||
filterSwitchGroups << groupFilter;
|
||||
|
||||
int row = 0;
|
||||
int coloffset = 1;
|
||||
ui->gridSwitches->addWidget(lblSwitchId, row++, i + coloffset);
|
||||
ui->gridSwitches->addWidget(aleName, row++, i + coloffset);
|
||||
ui->gridSwitches->addWidget(cboConfig, row++, i + coloffset);
|
||||
ui->gridSwitches->addWidget(cboStartPosn, row++, i + coloffset);
|
||||
ui->gridSwitches->addWidget(cboGroup, row++, i + coloffset);
|
||||
|
||||
connect(aleName, &AutoLineEdit::currentDataChanged, this, &FunctionSwitchesPanel::on_nameEditingFinished);
|
||||
connect(cboConfig, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FunctionSwitchesPanel::on_configCurrentIndexChanged);
|
||||
connect(cboStartPosn, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FunctionSwitchesPanel::on_startPosnCurrentIndexChanged);
|
||||
connect(cboGroup, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FunctionSwitchesPanel::on_groupChanged);
|
||||
|
||||
aleNames << aleName;
|
||||
cboConfigs << cboConfig;
|
||||
cboStartupPosns << cboStartPosn;
|
||||
cboGroups << cboGroup;
|
||||
if (Boards::getCapability(board, Board::FunctionSwitchColors)) {
|
||||
QLabel * lblOffColor = new QLabel(this);
|
||||
lblOffColor->setText(tr("Off color"));
|
||||
ui->gridSwitches->addWidget(lblOffColor, 5, 0);
|
||||
QLabel * lblOffLua = new QLabel(this);
|
||||
lblOffLua->setText(tr(" Allow Lua override"));
|
||||
ui->gridSwitches->addWidget(lblOffLua, 6, 0);
|
||||
QLabel * lblOnColor = new QLabel(this);
|
||||
lblOnColor->setText(tr("On color"));
|
||||
ui->gridSwitches->addWidget(lblOnColor, 7, 0);
|
||||
QLabel * lblOnLua = new QLabel(this);
|
||||
lblOnLua->setText(tr(" Allow Lua override"));
|
||||
ui->gridSwitches->addWidget(lblOnLua, 8, 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i += 1) {
|
||||
for (int sw = 0, col = 0; sw < Boards::getCapability(board, Board::Switches); sw++) {
|
||||
int i = Boards::getCFSIndexForSwitch(sw);
|
||||
if (i >= 0) {
|
||||
QLabel * lblSwitchId = new QLabel(this);
|
||||
lblSwitchId->setText(Boards::getSwitchName(sw));
|
||||
|
||||
AutoLineEdit * aleName = new AutoLineEdit(this);
|
||||
aleName->setProperty("index", i);
|
||||
aleName->setValidator(new NameValidator(board, this));
|
||||
aleName->setField((char *)model.customSwitches[i].name, 3);
|
||||
|
||||
QComboBox * cboConfig = new QComboBox(this);
|
||||
cboConfig->setProperty("index", i);
|
||||
auto configFilter = new FilteredSwitchConfigsModel(fsConfig, i, &model);
|
||||
cboConfig->setModel(configFilter);
|
||||
filterSwitchConfigs << configFilter;
|
||||
|
||||
QComboBox * cboStartPosn = new QComboBox(this);
|
||||
cboStartPosn->setProperty("index", i);
|
||||
cboStartPosn->setModel(fsStart);
|
||||
|
||||
QComboBox * cboGroup = new QComboBox(this);
|
||||
cboGroup->setProperty("index", i);
|
||||
auto groupFilter = new FilteredSwitchGroupsModel(fsGroups, i, &model);
|
||||
cboGroup->setModel(groupFilter);
|
||||
filterSwitchGroups << groupFilter;
|
||||
|
||||
int row = 0;
|
||||
int coloffset = 1;
|
||||
ui->gridSwitches->addWidget(lblSwitchId, row++, col + coloffset);
|
||||
ui->gridSwitches->addWidget(aleName, row++, col + coloffset);
|
||||
ui->gridSwitches->addWidget(cboConfig, row++, col + coloffset);
|
||||
ui->gridSwitches->addWidget(cboStartPosn, row++, col + coloffset);
|
||||
ui->gridSwitches->addWidget(cboGroup, row++, col + coloffset);
|
||||
|
||||
if (Boards::getCapability(board, Board::FunctionSwitchColors)) {
|
||||
const QString qss = QString("border-style: outset; border-width: 2px; border-radius: 5px; border-color: darkgrey; padding: 2px; background-color: %1;");
|
||||
QPushButton * btnOffColor = new QPushButton(tr(""));
|
||||
QColor off = this->model->customSwitches[i].offColor.getQColor();
|
||||
btnOffColor->setStyleSheet(QString(qss).arg(off.name()));
|
||||
connect(btnOffColor, &QPushButton::clicked, [=]() {
|
||||
QColorDialog *dlg = new QColorDialog();
|
||||
QColor color = dlg->getColor(this->model->customSwitches[i].offColor.getQColor());
|
||||
if (color.isValid()) {
|
||||
this->model->customSwitches[i].offColor.setColor(color.red(), color.green(), color.blue());
|
||||
btnOffColor->setStyleSheet(QString(qss).arg(color.name()));
|
||||
emit modified();
|
||||
}
|
||||
});
|
||||
ui->gridSwitches->addWidget(btnOffColor, row++, col + coloffset);
|
||||
btnOffColors << btnOffColor;
|
||||
|
||||
QCheckBox * cbOffLuaOverride = new QCheckBox(this);
|
||||
cbOffLuaOverride->setChecked(this->model->customSwitches[i].offColorLuaOverride);
|
||||
connect(cbOffLuaOverride, &QCheckBox::toggled, [=](int value) {
|
||||
this->model->customSwitches[i].offColorLuaOverride = value;
|
||||
emit modified();
|
||||
});
|
||||
ui->gridSwitches->addWidget(cbOffLuaOverride, row++, col + coloffset);
|
||||
cbOffLuaOverrides << cbOffLuaOverride;
|
||||
|
||||
QPushButton * btnOnColor = new QPushButton(tr(""));
|
||||
QColor on = this->model->customSwitches[i].onColor.getQColor();
|
||||
btnOnColor->setStyleSheet(QString(qss).arg(on.name()));
|
||||
connect(btnOnColor, &QPushButton::clicked, [=]() {
|
||||
QColorDialog *dlg = new QColorDialog();
|
||||
QColor color = dlg->getColor(this->model->customSwitches[i].onColor.getQColor());
|
||||
if (color.isValid()) {
|
||||
this->model->customSwitches[i].onColor.setColor(color.red(), color.green(), color.blue());
|
||||
btnOnColor->setStyleSheet(QString(qss).arg(color.name()));
|
||||
emit modified();
|
||||
}
|
||||
});
|
||||
ui->gridSwitches->addWidget(btnOnColor, row++, col + coloffset);
|
||||
btnOnColors << btnOnColor;
|
||||
|
||||
QCheckBox * cbOnLuaOverride = new QCheckBox(this);
|
||||
cbOnLuaOverride->setChecked(this->model->customSwitches[i].onColorLuaOverride);
|
||||
connect(cbOnLuaOverride, &QCheckBox::toggled, [=](int value) {
|
||||
this->model->customSwitches[i].onColorLuaOverride = value;
|
||||
emit modified();
|
||||
});
|
||||
ui->gridSwitches->addWidget(cbOnLuaOverride, row++, col + coloffset);
|
||||
cbOnLuaOverrides << cbOnLuaOverride;
|
||||
}
|
||||
|
||||
connect(aleName, &AutoLineEdit::currentDataChanged, this, &FunctionSwitchesPanel::on_nameEditingFinished);
|
||||
connect(cboConfig, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FunctionSwitchesPanel::on_configCurrentIndexChanged);
|
||||
connect(cboStartPosn, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FunctionSwitchesPanel::on_startPosnCurrentIndexChanged);
|
||||
connect(cboGroup, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FunctionSwitchesPanel::on_groupChanged);
|
||||
|
||||
aleNames << aleName;
|
||||
cboConfigs << cboConfig;
|
||||
cboStartupPosns << cboStartPosn;
|
||||
cboGroups << cboGroup;
|
||||
|
||||
col += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Boards::getCapability(board, Board::FunctionSwitchGroups); i += 1) {
|
||||
QLabel * lblGroupId = new QLabel(this);
|
||||
lblGroupId->setText(tr("Group %1").arg(i + 1));
|
||||
|
||||
@@ -154,22 +229,37 @@ void FunctionSwitchesPanel::update()
|
||||
{
|
||||
lock = true;
|
||||
|
||||
for (int i = 0; i < switchcnt; i++) {
|
||||
filterSwitchConfigs[i]->invalidate();
|
||||
filterSwitchGroups[i]->invalidate();
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
aleNames[i]->update();
|
||||
cboConfigs[i]->setCurrentIndex(filterSwitchConfigs[i]->mapFromSource(fsConfig->index(model->getFuncSwitchConfig(i), 0)).row());
|
||||
cboStartupPosns[i]->setCurrentIndex(model->getFuncSwitchStart(i));
|
||||
unsigned int grp = model->getFuncSwitchGroup(i);
|
||||
cboGroups[i]->setCurrentIndex(grp);
|
||||
for (int sw = 0, col = 0; sw < Boards::getCapability(firmware->getBoard(), Board::Switches); sw++) {
|
||||
int i = Boards::getCFSIndexForSwitch(sw);
|
||||
if (i >= 0) {
|
||||
filterSwitchConfigs[col]->invalidate();
|
||||
filterSwitchGroups[col]->invalidate();
|
||||
|
||||
cboStartupPosns[i]->setEnabled(cboConfigs[i]->currentIndex() >= ModelData::FUNC_SWITCH_CONFIG_2POS && (grp == 0));
|
||||
unsigned int cfg = model->getFuncSwitchConfig(i);
|
||||
unsigned int grp = model->getFuncSwitchGroup(i);
|
||||
|
||||
cboGroups[i]->setEnabled(cboConfigs[i]->currentIndex() >= ModelData::FUNC_SWITCH_CONFIG_TOGGLE);
|
||||
aleNames[col]->update();
|
||||
cboConfigs[col]->setCurrentIndex(filterSwitchConfigs[col]->mapFromSource(fsConfig->index(cfg, 0)).row());
|
||||
cboStartupPosns[col]->setCurrentIndex(model->getFuncSwitchStart(i));
|
||||
cboGroups[col]->setCurrentIndex(grp);
|
||||
|
||||
cboStartupPosns[col]->setEnabled(cfg == Board::SWITCH_2POS && (grp == 0));
|
||||
cboGroups[col]->setEnabled(cfg >= Board::SWITCH_TOGGLE && cfg < Board::SWITCH_GLOBAL);
|
||||
|
||||
if (Boards::getCapability(board, Board::FunctionSwitchColors)) {
|
||||
btnOffColors[col]->setEnabled(cfg != Board::SWITCH_NOT_AVAILABLE && cfg != Board::SWITCH_GLOBAL);
|
||||
cbOffLuaOverrides[col]->setEnabled(cfg != Board::SWITCH_NOT_AVAILABLE && cfg != Board::SWITCH_GLOBAL);
|
||||
btnOnColors[col]->setEnabled(cfg != Board::SWITCH_NOT_AVAILABLE && cfg != Board::SWITCH_GLOBAL);
|
||||
cbOnLuaOverrides[col]->setEnabled(cfg != Board::SWITCH_NOT_AVAILABLE && cfg != Board::SWITCH_GLOBAL);
|
||||
}
|
||||
|
||||
col += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i += 1) {
|
||||
for (int i = 0; i < Boards::getCapability(board, Board::FunctionSwitchGroups); i += 1) {
|
||||
filterGroupSwitches[i]->invalidate();
|
||||
|
||||
model->setGroupSwitchState(i + 1, switchcnt);
|
||||
@@ -200,10 +290,10 @@ void FunctionSwitchesPanel::on_configCurrentIndexChanged(int index)
|
||||
unsigned int sw = sender()->property("index").toInt(&ok);
|
||||
unsigned int config = filterSwitchConfigs[sw]->mapToSource(filterSwitchConfigs[sw]->index(index, 0)).row();
|
||||
if (ok && model->getFuncSwitchConfig(sw) != config) {
|
||||
model->setFuncSwitchConfig(sw, config);
|
||||
if (config != ModelData::FUNC_SWITCH_CONFIG_2POS) {
|
||||
model->setFuncSwitchConfig(sw, (Board::SwitchType)config);
|
||||
if (config != Board::SWITCH_2POS && config != Board::SWITCH_GLOBAL) {
|
||||
model->setFuncSwitchStart(sw, ModelData::FUNC_SWITCH_START_PREVIOUS);
|
||||
if ((config == ModelData::FUNC_SWITCH_CONFIG_NONE) || model->getFuncSwitchAlwaysOnGroupForSwitch(sw))
|
||||
if ((config == Board::SWITCH_NOT_AVAILABLE) || model->getFuncSwitchAlwaysOnGroupForSwitch(sw))
|
||||
model->setFuncSwitchGroup(sw, 0);
|
||||
}
|
||||
update();
|
||||
@@ -270,8 +360,8 @@ void FunctionSwitchesPanel::on_groupChanged(int value)
|
||||
if (ok && model->getFuncSwitchGroup(sw) != grp) {
|
||||
unsigned oldGrp = model->getFuncSwitchGroup(sw);
|
||||
if (model->getFuncSwitchAlwaysOnGroup(grp)) {
|
||||
if (model->getFuncSwitchConfig(sw) == ModelData::FUNC_SWITCH_CONFIG_TOGGLE)
|
||||
model->setFuncSwitchConfig(sw, ModelData::FUNC_SWITCH_CONFIG_2POS);
|
||||
if (model->getFuncSwitchConfig(sw) == Board::SWITCH_TOGGLE)
|
||||
model->setFuncSwitchConfig(sw, Board::SWITCH_2POS);
|
||||
}
|
||||
if ((grp == 0) || (model->getFuncGroupSwitchStart(grp, switchcnt) == 0))
|
||||
model->setFuncSwitchStart(sw, ModelData::FUNC_SWITCH_START_PREVIOUS);
|
||||
@@ -304,8 +394,8 @@ void FunctionSwitchesPanel::on_alwaysOnGroupChanged(int value)
|
||||
model->setFuncSwitchAlwaysOnGroup(grp, (unsigned int)value);
|
||||
if (value) {
|
||||
for (int i = 0; i < switchcnt; i += 1) {
|
||||
if (((int)model->getFuncSwitchGroup(i) == grp) && (model->getFuncSwitchConfig(i) == ModelData::FUNC_SWITCH_CONFIG_TOGGLE))
|
||||
model->setFuncSwitchConfig(i, ModelData::FUNC_SWITCH_CONFIG_2POS);
|
||||
if (((int)model->getFuncSwitchGroup(i) == grp) && (model->getFuncSwitchConfig(i) == Board::SWITCH_TOGGLE))
|
||||
model->setFuncSwitchConfig(i, Board::SWITCH_2POS);
|
||||
}
|
||||
if ((int)model->getFuncGroupSwitchStart(grp, switchcnt) == switchcnt + 1) {
|
||||
for (int i = 0; i < switchcnt; i += 1) {
|
||||
|
||||
@@ -157,6 +157,10 @@ class FunctionSwitchesPanel : public ModelPanel
|
||||
QVector<QComboBox *> cboGroups;
|
||||
QVector<QCheckBox *> cbAlwaysOnGroups;
|
||||
QVector<QComboBox *> cboGroupStartupPosns;
|
||||
QVector<QPushButton *> btnOffColors;
|
||||
QVector<QCheckBox *> cbOffLuaOverrides;
|
||||
QVector<QPushButton *> btnOnColors;
|
||||
QVector<QCheckBox *> cbOnLuaOverrides;
|
||||
QVector<FilteredGroupSwitchesModel *> filterGroupSwitches;
|
||||
QVector<FilteredSwitchGroupsModel *> filterSwitchGroups;
|
||||
QVector<FilteredSwitchConfigsModel *> filterSwitchConfigs;
|
||||
|
||||
Reference in New Issue
Block a user