Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9472b36b authored by Filip Mirosław's avatar Filip Mirosław Committed by Albert Astals Cid

Added a feature to execute the next task after the previous one finishes.

This feature enables the user to select a "Consecutive" checkbox for a task, and this would mean that this task will be automatically started after the previous one finishes.

FEATURE: 380445

Reviewers: #kde_applications, kde-utils-devel, aacid

Reviewed By: #kde_applications, aacid

Subscribers: lueck, kde-doc-english, aacid, bcooksley, kde-utils-devel

Tags: #kde_applications

Differential Revision: https://phabricator.kde.org/D10186
parent 3b6639b6
......@@ -188,6 +188,7 @@ void KTimerPref::currentChanged( QTreeWidgetItem *i , QTreeWidgetItem * /* old *
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 @@ void KTimerPref::currentChanged( QTreeWidgetItem *i , QTreeWidgetItem * /* old *
connect(m_delay, static_cast<void (QSpinBox::*)(int)>(&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 @@ void KTimerPref::currentChanged( QTreeWidgetItem *i , QTreeWidgetItem * /* old *
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 @@ void KTimerPref::jobFinished( KTimerJob *job, bool error )
{
KTimerJobItem *item = static_cast<KTimerJobItem*>(job->user());
item->setStatus( error );
if( m_list->itemBelow(m_list->currentItem())!=nullptr && (static_cast<KTimerJobItem*>(m_list->itemBelow( m_list->currentItem() )))->job()->consecutive() ) {
m_list->setCurrentItem( m_list->itemBelow( m_list->currentItem() ) );
(static_cast<KTimerJobItem*>(m_list->currentItem()))->job()->start();
}
m_list->update();
}
......@@ -328,6 +335,7 @@ struct KTimerJobPrivate {
QString command;
bool loop;
bool oneInstance;
bool consecutive;
unsigned value;
KTimerJob::States state;
QList<QProcess *> processes;
......@@ -345,6 +353,7 @@ KTimerJob::KTimerJob( QObject *parent)
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 @@ void KTimerJob::save( KConfig *cfg, const QString& grp )
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 @@ void KTimerJob::load( KConfig *cfg, const QString& grp )
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 @@ void KTimerJob::setOneInstance( bool one )
}
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::processExited(int, QProcess::ExitStatus status)
}
void KTimerJob::fire()
{
if( !d->oneInstance || d->processes.isEmpty() ) {
......
......@@ -40,6 +40,7 @@ class KTimerJob : public QObject {
QString command() const;
bool loop() const;
bool oneInstance() const;
bool consecutive() const;
unsigned value() const;
States state() const;
void *user();
......@@ -58,6 +59,7 @@ class KTimerJob : public QObject {
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 @@ class KTimerJob : public QObject {
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 );
......
......@@ -249,6 +249,19 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="8">
<widget class="QCheckBox" name="m_consecutive">
<property name="toolTip">
<string>Check this box if you want to execute this task after the previous one finishes</string>
</property>
<property name="whatsThis">
<string>Check this box if you want to execute this task after the previous one finishes</string>
</property>
<property name="text">
<string>Consecutive task</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QLabel" name="TextLabel3">
<property name="text">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment