[Companion] Model Setup: Prevent bogus modification signals. (#4896)
* [Companion] Model editor Setup panel: Prevent bogus modification signals, eg. when populating protocols box or when removing focus from some fields w/out the value actually changing; Remove unnecessary function. * [SetupPanel] Fix comparison warning and also a translation issue with Multiprotocols subtype and option names. * [ModelPrinter] Add a missing include.
This commit is contained in:
committed by
Bertrand Songis
parent
24de312a30
commit
e2502772cb
@@ -51,7 +51,6 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
|||||||
// Mode
|
// Mode
|
||||||
ui->mode->setModel(Helpers::getRawSwitchItemModel(&generalSettings, Helpers::TimersContext));
|
ui->mode->setModel(Helpers::getRawSwitchItemModel(&generalSettings, Helpers::TimersContext));
|
||||||
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
||||||
//Helpers::populateSwitchCB(ui->mode, timer.mode, generalSettings, Helpers::TimersContext);
|
|
||||||
|
|
||||||
if (!firmware->getCapability(PermTimers)) {
|
if (!firmware->getCapability(PermTimers)) {
|
||||||
ui->persistent->hide();
|
ui->persistent->hide();
|
||||||
@@ -121,8 +120,11 @@ QWidget * TimerPanel::getLastFocus()
|
|||||||
|
|
||||||
void TimerPanel::on_value_editingFinished()
|
void TimerPanel::on_value_editingFinished()
|
||||||
{
|
{
|
||||||
timer.val = ui->value->time().hour()*3600 + ui->value->time().minute()*60 + ui->value->time().second();
|
unsigned val = ui->value->time().hour()*3600 + ui->value->time().minute()*60 + ui->value->time().second();
|
||||||
emit modified();
|
if (timer.val != val) {
|
||||||
|
timer.val = val;
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerPanel::on_mode_currentIndexChanged(int index)
|
void TimerPanel::on_mode_currentIndexChanged(int index)
|
||||||
@@ -141,9 +143,11 @@ void TimerPanel::on_minuteBeep_toggled(bool checked)
|
|||||||
|
|
||||||
void TimerPanel::on_name_editingFinished()
|
void TimerPanel::on_name_editingFinished()
|
||||||
{
|
{
|
||||||
int length = ui->name->maxLength();
|
if (QString(timer.name) != ui->name->text()) {
|
||||||
strncpy(timer.name, ui->name->text().toLatin1(), length);
|
int length = ui->name->maxLength();
|
||||||
emit modified();
|
strncpy(timer.name, ui->name->text().toLatin1(), length);
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@@ -234,15 +238,15 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
|
|||||||
|
|
||||||
disableMouseScrolling();
|
disableMouseScrolling();
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
connect(ui->protocol, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ModulePanel::onProtocolChanged);
|
||||||
|
connect(ui->multiProtocol, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ModulePanel::onMultiProtocolChanged);
|
||||||
connect(this, &ModulePanel::channelsRangeChanged, this, &ModulePanel::setupFailsafes);
|
connect(this, &ModulePanel::channelsRangeChanged, this, &ModulePanel::setupFailsafes);
|
||||||
connect(ui->btnGrpValueType, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &ModulePanel::onFailsafesDisplayValueTypeChanged);
|
connect(ui->btnGrpValueType, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &ModulePanel::onFailsafesDisplayValueTypeChanged);
|
||||||
|
|
||||||
lock = false;
|
lock = false;
|
||||||
|
|
||||||
// a change will not register if only one item was added
|
|
||||||
if (ui->protocol->count() == 1) {
|
|
||||||
on_protocol_currentIndexChanged(ui->protocol->currentIndex());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModulePanel::~ModulePanel()
|
ModulePanel::~ModulePanel()
|
||||||
@@ -476,7 +480,7 @@ void ModulePanel::update()
|
|||||||
ui->optionValue->setMinimum(pdef.getOptionMin());
|
ui->optionValue->setMinimum(pdef.getOptionMin());
|
||||||
ui->optionValue->setMaximum(pdef.getOptionMax());
|
ui->optionValue->setMaximum(pdef.getOptionMax());
|
||||||
ui->optionValue->setValue(module.multi.optionValue);
|
ui->optionValue->setValue(module.multi.optionValue);
|
||||||
ui->label_option->setText(pdef.optionsstr);
|
ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr)));
|
||||||
}
|
}
|
||||||
ui->multiSubType->setCurrentIndex(module.subType);
|
ui->multiSubType->setCurrentIndex(module.subType);
|
||||||
|
|
||||||
@@ -533,7 +537,7 @@ void ModulePanel::on_trainerMode_currentIndexChanged(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::on_protocol_currentIndexChanged(int index)
|
void ModulePanel::onProtocolChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
module.protocol = ui->protocol->itemData(index).toInt();
|
module.protocol = ui->protocol->itemData(index).toInt();
|
||||||
@@ -562,7 +566,7 @@ void ModulePanel::on_ppmOutputType_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void ModulePanel::on_channelsCount_editingFinished()
|
void ModulePanel::on_channelsCount_editingFinished()
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock && module.channelsCount != ui->channelsCount->value()) {
|
||||||
module.channelsCount = ui->channelsCount->value();
|
module.channelsCount = ui->channelsCount->value();
|
||||||
update();
|
update();
|
||||||
emit channelsRangeChanged();
|
emit channelsRangeChanged();
|
||||||
@@ -572,8 +576,8 @@ void ModulePanel::on_channelsCount_editingFinished()
|
|||||||
|
|
||||||
void ModulePanel::on_channelsStart_editingFinished()
|
void ModulePanel::on_channelsStart_editingFinished()
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock && module.channelsStart != (unsigned)ui->channelsStart->value() - 1) {
|
||||||
module.channelsStart = ui->channelsStart->value() - 1;
|
module.channelsStart = (unsigned)ui->channelsStart->value() - 1;
|
||||||
update();
|
update();
|
||||||
emit channelsRangeChanged();
|
emit channelsRangeChanged();
|
||||||
emit modified();
|
emit modified();
|
||||||
@@ -582,7 +586,7 @@ void ModulePanel::on_channelsStart_editingFinished()
|
|||||||
|
|
||||||
void ModulePanel::on_ppmDelay_editingFinished()
|
void ModulePanel::on_ppmDelay_editingFinished()
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock && module.ppm.delay != ui->ppmDelay->value()) {
|
||||||
// TODO only accept valid values
|
// TODO only accept valid values
|
||||||
module.ppm.delay = ui->ppmDelay->value();
|
module.ppm.delay = ui->ppmDelay->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
@@ -591,14 +595,19 @@ void ModulePanel::on_ppmDelay_editingFinished()
|
|||||||
|
|
||||||
void ModulePanel::on_rxNumber_editingFinished()
|
void ModulePanel::on_rxNumber_editingFinished()
|
||||||
{
|
{
|
||||||
module.modelId = ui->rxNumber->value();
|
if (module.modelId != (unsigned)ui->rxNumber->value()) {
|
||||||
emit modified();
|
module.modelId = (unsigned)ui->rxNumber->value();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::on_ppmFrameLength_editingFinished()
|
void ModulePanel::on_ppmFrameLength_editingFinished()
|
||||||
{
|
{
|
||||||
module.ppm.frameLength = (ui->ppmFrameLength->value()-22.5) / 0.5;
|
int val = (ui->ppmFrameLength->value()-22.5) / 0.5;
|
||||||
emit modified();
|
if (module.ppm.frameLength != val) {
|
||||||
|
module.ppm.frameLength = val;
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::on_failsafeMode_currentIndexChanged(int value)
|
void ModulePanel::on_failsafeMode_currentIndexChanged(int value)
|
||||||
@@ -610,7 +619,7 @@ void ModulePanel::on_failsafeMode_currentIndexChanged(int value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::on_multiProtocol_currentIndexChanged(int index)
|
void ModulePanel::onMultiProtocolChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
lock=true;
|
lock=true;
|
||||||
@@ -627,8 +636,10 @@ void ModulePanel::on_multiProtocol_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void ModulePanel::on_optionValue_editingFinished()
|
void ModulePanel::on_optionValue_editingFinished()
|
||||||
{
|
{
|
||||||
module.multi.optionValue = ui->optionValue->value();
|
if (module.multi.optionValue != ui->optionValue->value()) {
|
||||||
emit modified();
|
module.multi.optionValue = ui->optionValue->value();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::on_multiSubType_currentIndexChanged(int index)
|
void ModulePanel::on_multiSubType_currentIndexChanged(int index)
|
||||||
@@ -855,7 +866,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
|||||||
if (i<firmware->getCapability(Timers)) {
|
if (i<firmware->getCapability(Timers)) {
|
||||||
timers[i] = new TimerPanel(this, model, model.timers[i], generalSettings, firmware, prevFocus);
|
timers[i] = new TimerPanel(this, model, model.timers[i], generalSettings, firmware, prevFocus);
|
||||||
ui->gridLayout->addWidget(timers[i], 1+i, 1);
|
ui->gridLayout->addWidget(timers[i], 1+i, 1);
|
||||||
connect(timers[i], SIGNAL(modified()), this, SLOT(onChildModified()));
|
connect(timers[i], &TimerPanel::modified, this, &SetupPanel::modified);
|
||||||
prevFocus = timers[i]->getLastFocus();
|
prevFocus = timers[i]->getLastFocus();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -987,14 +998,14 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
|||||||
for (int i=0; i<firmware->getCapability(NumModules); i++) {
|
for (int i=0; i<firmware->getCapability(NumModules); i++) {
|
||||||
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
||||||
ui->modulesLayout->addWidget(modules[i]);
|
ui->modulesLayout->addWidget(modules[i]);
|
||||||
connect(modules[i], SIGNAL(modified()), this, SLOT(onChildModified()));
|
connect(modules[i], &ModulePanel::modified, this, &SetupPanel::modified);
|
||||||
connect(this, &SetupPanel::extendedLimitsToggled, modules[i], &ModulePanel::onExtendedLimitsToggled);
|
connect(this, &SetupPanel::extendedLimitsToggled, modules[i], &ModulePanel::onExtendedLimitsToggled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firmware->getCapability(ModelTrainerEnable)) {
|
if (firmware->getCapability(ModelTrainerEnable)) {
|
||||||
modules[CPN_MAX_MODULES] = new ModulePanel(this, model, model.moduleData[CPN_MAX_MODULES], generalSettings, firmware, -1);
|
modules[CPN_MAX_MODULES] = new ModulePanel(this, model, model.moduleData[CPN_MAX_MODULES], generalSettings, firmware, -1);
|
||||||
ui->modulesLayout->addWidget(modules[CPN_MAX_MODULES]);
|
ui->modulesLayout->addWidget(modules[CPN_MAX_MODULES]);
|
||||||
connect(modules[CPN_MAX_MODULES], SIGNAL(modified()), this, SLOT(onChildModified()));
|
connect(modules[CPN_MAX_MODULES], &ModulePanel::modified, this, &SetupPanel::modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
disableMouseScrolling();
|
disableMouseScrolling();
|
||||||
@@ -1048,9 +1059,11 @@ void SetupPanel::on_throttleSource_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void SetupPanel::on_name_editingFinished()
|
void SetupPanel::on_name_editingFinished()
|
||||||
{
|
{
|
||||||
int length = ui->name->maxLength();
|
if (QString(model->name) != ui->name->text()) {
|
||||||
strncpy(model->name, ui->name->text().toLatin1(), length);
|
int length = ui->name->maxLength();
|
||||||
emit modified();
|
strncpy(model->name, ui->name->text().toLatin1(), length);
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_image_currentIndexChanged(int index)
|
void SetupPanel::on_image_currentIndexChanged(int index)
|
||||||
@@ -1293,8 +1306,3 @@ void SetupPanel::onBeepCenterToggled(bool checked)
|
|||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::onChildModified()
|
|
||||||
{
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class ModulePanel : public ModelPanel
|
|||||||
private slots:
|
private slots:
|
||||||
void setupFailsafes();
|
void setupFailsafes();
|
||||||
void on_trainerMode_currentIndexChanged(int index);
|
void on_trainerMode_currentIndexChanged(int index);
|
||||||
void on_protocol_currentIndexChanged(int index);
|
void onProtocolChanged(int index);
|
||||||
void on_ppmDelay_editingFinished();
|
void on_ppmDelay_editingFinished();
|
||||||
void on_channelsCount_editingFinished();
|
void on_channelsCount_editingFinished();
|
||||||
void on_channelsStart_editingFinished();
|
void on_channelsStart_editingFinished();
|
||||||
@@ -81,7 +81,7 @@ class ModulePanel : public ModelPanel
|
|||||||
void on_antennaMode_currentIndexChanged(int index);
|
void on_antennaMode_currentIndexChanged(int index);
|
||||||
void on_rxNumber_editingFinished();
|
void on_rxNumber_editingFinished();
|
||||||
void on_failsafeMode_currentIndexChanged(int value);
|
void on_failsafeMode_currentIndexChanged(int value);
|
||||||
void on_multiProtocol_currentIndexChanged(int index);
|
void onMultiProtocolChanged(int index);
|
||||||
void on_multiSubType_currentIndexChanged(int index);
|
void on_multiSubType_currentIndexChanged(int index);
|
||||||
void on_autoBind_stateChanged(int state);
|
void on_autoBind_stateChanged(int state);
|
||||||
void on_lowPower_stateChanged(int state);
|
void on_lowPower_stateChanged(int state);
|
||||||
@@ -140,7 +140,6 @@ class SetupPanel : public ModelPanel
|
|||||||
void startupSwitchToggled(bool checked);
|
void startupSwitchToggled(bool checked);
|
||||||
void potWarningToggled(bool checked);
|
void potWarningToggled(bool checked);
|
||||||
void on_potWarningMode_currentIndexChanged(int index);
|
void on_potWarningMode_currentIndexChanged(int index);
|
||||||
void onChildModified();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Setup *ui;
|
Ui::Setup *ui;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "modelprinter.h"
|
#include "modelprinter.h"
|
||||||
#include "multiprotocols.h"
|
#include "multiprotocols.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@@ -146,7 +147,7 @@ QString ModelPrinter::printMultiSubType(int rfProtocol, bool custom, unsigned in
|
|||||||
Multiprotocols::MultiProtocolDefinition pdef = multiProtocols.getProtocol(rfProtocol);
|
Multiprotocols::MultiProtocolDefinition pdef = multiProtocols.getProtocol(rfProtocol);
|
||||||
|
|
||||||
if (subType < (unsigned int) pdef.subTypeStrings.size())
|
if (subType < (unsigned int) pdef.subTypeStrings.size())
|
||||||
return pdef.subTypeStrings[subType];
|
return qApp->translate("Multiprotocols", qPrintable(pdef.subTypeStrings[subType]));
|
||||||
else
|
else
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user