diff --git a/ktimer.h b/ktimer.h --- a/ktimer.h +++ b/ktimer.h @@ -40,6 +40,7 @@ QString command() const; bool loop() const; bool oneInstance() const; + bool consecutive() const; unsigned value() const; States state() const; void *user(); @@ -58,6 +59,7 @@ void setCommand( const QString &cmd ); void setLoop( bool loop ); void setOneInstance( bool one ); + void setConsecutive( bool consecutive ); void setValue( unsigned int value ); void setValue( int value ); void setState( States state ); @@ -72,6 +74,7 @@ void commandChanged( KTimerJob *job, const QString &cmd ); void loopChanged( KTimerJob *job, bool loop ); void oneInstanceChanged( KTimerJob *job, bool one ); + void consecutiveChanged( KTimerJob *job, bool consecutive ); void valueChanged( KTimerJob *job, unsigned int value ); void changed( KTimerJob *job ); diff --git a/ktimer.cpp b/ktimer.cpp --- a/ktimer.cpp +++ b/ktimer.cpp @@ -188,6 +188,7 @@ m_delay->disconnect(); m_loop->disconnect(); m_one->disconnect(); + m_consecutive->disconnect(); m_start->disconnect(); m_pause->disconnect(); m_stop->disconnect(); @@ -210,6 +211,7 @@ connect(m_delay, static_cast(&QSpinBox::valueChanged), this, &KTimerPref::delayChanged); connect(m_loop, &QCheckBox::toggled, job, &KTimerJob::setLoop); connect(m_one, &QCheckBox::toggled, job, &KTimerJob::setOneInstance); + connect(m_consecutive, &QCheckBox::toggled, job, &KTimerJob::setConsecutive); connect(m_stop, &QToolButton::clicked, job, &KTimerJob::stop); connect(m_pause, &QToolButton::clicked, job, &KTimerJob::pause); connect(m_start, &QToolButton::clicked, job, &KTimerJob::start); @@ -220,6 +222,7 @@ m_commandLine->lineEdit()->setText( job->command() ); m_loop->setChecked( job->loop() ); m_one->setChecked( job->oneInstance() ); + m_consecutive->setChecked( job->consecutive() ); m_counter->display( (int)job->value() ); m_slider->setMaximum( job->delay() ); m_slider->setValue( job->value() ); @@ -254,6 +257,10 @@ { KTimerJobItem *item = static_cast(job->user()); item->setStatus( error ); + if( m_list->itemBelow(m_list->currentItem())!=nullptr && (static_cast(m_list->itemBelow( m_list->currentItem() )))->job()->consecutive() ) { + m_list->setCurrentItem( m_list->itemBelow( m_list->currentItem() ) ); + (static_cast(m_list->currentItem()))->job()->start(); + } m_list->update(); } @@ -328,6 +335,7 @@ QString command; bool loop; bool oneInstance; + bool consecutive; unsigned value; KTimerJob::States state; QList processes; @@ -345,6 +353,7 @@ d->delay = 100; d->loop = false; d->oneInstance = true; + d->consecutive = false; d->value = 100; d->state = Stopped; d->user = 0; @@ -367,6 +376,7 @@ groupcfg.writePathEntry( "Command", d->command ); groupcfg.writeEntry( "Loop", d->loop ); groupcfg.writeEntry( "OneInstance", d->oneInstance ); + groupcfg.writeEntry( "Consecutive", d->consecutive ); groupcfg.writeEntry( "State", (int)d->state ); } @@ -378,6 +388,7 @@ setCommand( groupcfg.readPathEntry( "Command", QString() ) ); setLoop( groupcfg.readEntry( "Loop", false ) ); setOneInstance( groupcfg.readEntry( "OneInstance", d->oneInstance ) ); + setConsecutive( groupcfg.readEntry( "Consecutive", d->consecutive ) ); setState( (States)groupcfg.readEntry( "State", (int)Stopped ) ); } @@ -513,6 +524,22 @@ } +bool KTimerJob::consecutive() const +{ + return d->consecutive; +} + + +void KTimerJob::setConsecutive( bool consecutive ) +{ + if( d->consecutive!=consecutive ) { + d->consecutive = consecutive; + emit consecutiveChanged( this, consecutive ); + emit changed( this ); + } +} + + unsigned KTimerJob::value() const { return d->value; @@ -581,8 +608,6 @@ } - - void KTimerJob::fire() { if( !d->oneInstance || d->processes.isEmpty() ) { diff --git a/prefwidget.ui b/prefwidget.ui --- a/prefwidget.ui +++ b/prefwidget.ui @@ -249,6 +249,19 @@ + + + + Check this box if you want to execute this task after the previous one finishes + + + Check this box if you want to execute this task after the previous one finishes + + + Consecutive task + + +