Use autotimeedit in setup timers
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTimeEdit" name="value">
|
||||
<widget class="AutoTimeEdit" name="value">
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -126,6 +126,11 @@
|
||||
<extends>QCheckBox</extends>
|
||||
<header>autocheckbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoTimeEdit</class>
|
||||
<extends>QTimeEdit</extends>
|
||||
<header>autotimeedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user