diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 7d887173f..cb4312965 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -48,8 +48,13 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G int length = firmware->getCapability(TimersName); if (length == 0) ui->name->hide(); - else + else { ui->name->setField(timer.name, length, this); + connect(ui->name, SIGNAL(currentDataChanged()), this, SLOT(onNameChanged())); + } + + ui->value->setField(timer.val, this); + ui->value->setMaximumTime(firmware->getMaxTimerStart()); // Mode ui->mode->setModel(panelFilteredModels->getItemModel(FIM_TIMERSWITCH)); @@ -60,8 +65,6 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G 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)) { @@ -100,11 +103,7 @@ void TimerPanel::update() ui->name->updateValue(); ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue())); - - int hour = timer.val / 3600; - int min = (timer.val - (hour * 3600)) / 60; - int sec = (timer.val - (hour * 3600)) % 60; - ui->value->setTime(QTime(hour, min, sec)); + ui->value->updateValue(); ui->countdownBeep->updateValue(); ui->minuteBeep->updateValue(); @@ -129,17 +128,6 @@ QWidget * TimerPanel::getLastFocus() return ui->persistent; } -void TimerPanel::on_value_editingFinished() -{ - if (!lock) { - unsigned val = ui->value->time().hour() * 3600 + ui->value->time().minute() * 60 + ui->value->time().second(); - if (timer.val != val) { - timer.val = val; - emit modified(); - } - } -} - void TimerPanel::onModeChanged(int index) { if (!lock) { @@ -173,6 +161,11 @@ void TimerPanel::onItemModelUpdateComplete() } } +void TimerPanel::onNameChanged() +{ + emit nameChanged(); +} + void TimerPanel::onCountdownBeepDataChanged(int index) { timer.countdownBeepChanged(); diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 41c3b45c7..67c97f669 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -47,7 +47,7 @@ class TimerPanel : public ModelPanel private slots: void onModeChanged(int index); - void on_value_editingFinished(); + void onNameChanged(); void onItemModelAboutToBeUpdated(); void onItemModelUpdateComplete(); void onCountdownBeepDataChanged(int index); diff --git a/companion/src/modeledit/setup_timer.ui b/companion/src/modeledit/setup_timer.ui index 989e7074e..a772c6d30 100644 --- a/companion/src/modeledit/setup_timer.ui +++ b/companion/src/modeledit/setup_timer.ui @@ -43,7 +43,7 @@ - + true @@ -126,6 +126,11 @@ QCheckBox
autocheckbox.h
+ + AutoTimeEdit + QTimeEdit +
autotimeedit.h
+
diff --git a/companion/src/shared/autotimeedit.h b/companion/src/shared/autotimeedit.h index ef419ac95..8e2dff2d8 100644 --- a/companion/src/shared/autotimeedit.h +++ b/companion/src/shared/autotimeedit.h @@ -37,21 +37,21 @@ class AutoTimeEdit: public QTimeEdit connect(this, SIGNAL(timeChanged(QTime)), this, SLOT(onTimeChanged(QTime))); } - void setField(int & field, GenericPanel * panel = nullptr) + void setField(unsigned int & field, GenericPanel * panel = nullptr) { this->field = &field; this->panel = panel; updateValue(); } - void setMinimumTime(QTime time) + void setMinimumTime(const QTime time) { - QTimeEdit::setMinimumTime(QTime time); + QTimeEdit::setMinimumTime(time); } - void setMaximumTime(QTime time) + void setMaximumTime(const QTime time) { - QTimeEdit::setMaximumTime(QTime time); + QTimeEdit::setMaximumTime(time); } void setEnabled(bool enabled) @@ -90,7 +90,7 @@ class AutoTimeEdit: public QTimeEdit } protected: - int *field = nullptr; + unsigned int *field = nullptr; GenericPanel *panel = nullptr; bool lock = false; };