Use autotimeedit in setup timers

This commit is contained in:
elecpower
2021-03-17 20:26:11 +11:00
parent 3eed78dbd5
commit 521bdde1fd
4 changed files with 25 additions and 27 deletions
+12 -19
View File
@@ -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();