diff --git a/companion/src/firmwares/timerdata.cpp b/companion/src/firmwares/timerdata.cpp index eeac00b69..9034ed7e0 100644 --- a/companion/src/firmwares/timerdata.cpp +++ b/companion/src/firmwares/timerdata.cpp @@ -78,10 +78,9 @@ QString TimerData::valToString() const return valToString(val); } -void TimerData::setCountdownBeep(const unsigned int value) +void TimerData::countdownBeepChanged() { - countdownBeep = value; - if (value == COUNTDOWNBEEP_SILENT) + if (countdownBeep == COUNTDOWNBEEP_SILENT) countdownStart = 0; } @@ -166,7 +165,7 @@ AbstractStaticItemModel * TimerData::countdownStartItemModel() AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); mdl->setName(AIM_TIMER_COUNTDOWNSTART); - for (int i = COUNTDOWNSTART_LAST - 1; i >= COUNTDOWNSTART_FIRST; i--) { + for (int i = COUNTDOWNSTART_LAST; i >= COUNTDOWNSTART_FIRST; i--) { mdl->appendToItemList(countdownStartToString(i), i); } diff --git a/companion/src/firmwares/timerdata.h b/companion/src/firmwares/timerdata.h index 03694120c..07cc1eedd 100644 --- a/companion/src/firmwares/timerdata.h +++ b/companion/src/firmwares/timerdata.h @@ -84,7 +84,7 @@ class TimerData { QString persistentToString(const bool verbose = true) const; QString pvalueToString() const; QString valToString() const; - void setCountdownBeep(const unsigned int value); + void countdownBeepChanged(); static QString countdownBeepToString(const int value); static QString countdownStartToString(const int value); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 43c7cbaca..7d887173f 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -33,7 +33,7 @@ constexpr char FIM_TIMERSWITCH[] {"Timer Switch"}; constexpr char FIM_THRSOURCE[] {"Throttle Source"}; -TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, +TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels): ModelPanel(parent, model, generalSettings, firmware), timer(timer), @@ -58,19 +58,20 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge ui->countdownBeep->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNBEEP)); ui->countdownBeep->setField(timer.countdownBeep, this); + connect(ui->countdownBeep, SIGNAL(currentDataChanged(int)), this, SLOT(onCountdownBeepDataChanged(int))); ui->value->setMaximumTime(firmware->getMaxTimerStart()); ui->minuteBeep->setField(timer.minuteBeep, this); - if (!firmware->getCapability(PermTimers)) { - ui->persistent->hide(); - ui->persistentValue->hide(); - } - else { + if (firmware->getCapability(PermTimers)) { ui->persistent->setModel(panelItemModels->getItemModel(AIM_TIMER_PERSISTENT)); ui->persistent->setField(timer.persistent, this); } + else { + ui->persistent->hide(); + ui->persistentValue->hide(); + } ui->countdownStart->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNSTART)); ui->countdownStart->setField(timer.countdownStart, this); @@ -107,12 +108,8 @@ void TimerPanel::update() ui->countdownBeep->updateValue(); ui->minuteBeep->updateValue(); - if (firmware->getCapability(PermTimers)) { - ui->persistent->updateValue(); - ui->persistentValue->setText(timer.pvalueToString()); - } ui->countdownStart->updateValue(); - if(timer.countdownBeep == TimerData::COUNTDOWNBEEP_SILENT) { + if (timer.countdownBeep == TimerData::COUNTDOWNBEEP_SILENT) { ui->countdownStartLabel->setEnabled(false); ui->countdownStart->setEnabled(false); } @@ -120,6 +117,10 @@ void TimerPanel::update() ui->countdownStartLabel->setEnabled(true); ui->countdownStart->setEnabled(true); } + if (firmware->getCapability(PermTimers)) { + ui->persistent->updateValue(); + ui->persistentValue->setText(timer.pvalueToString()); + } lock = false; } @@ -172,6 +173,12 @@ void TimerPanel::onItemModelUpdateComplete() } } +void TimerPanel::onCountdownBeepDataChanged(int index) +{ + timer.countdownBeepChanged(); + update(); +} + /******************************************************************************/ #define FAILSAFE_CHANNEL_HOLD 2000 diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index b4e3b19c7..41c3b45c7 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -38,8 +38,8 @@ class TimerPanel : public ModelPanel Q_OBJECT public: - TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, - QWidget *prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels); + TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, + QWidget * prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels); virtual ~TimerPanel(); virtual void update(); @@ -50,6 +50,7 @@ class TimerPanel : public ModelPanel void on_value_editingFinished(); void onItemModelAboutToBeUpdated(); void onItemModelUpdateComplete(); + void onCountdownBeepDataChanged(int index); signals: void nameChanged();