feat: implement job service

Log:
This commit is contained in:
heyuming 2023-07-12 10:35:27 +08:00 committed by Comix
parent eac09c2cca
commit fdf01923db
3 changed files with 23 additions and 7 deletions

View File

@ -5,8 +5,8 @@
<annotation
name="org.freedesktop.DBus.Description"
value="Value of `Status` is one of
`pending`, `working`, `done`,
`pasuing`, `paused`, `resuming`,
`started`, `running`, `finished`,
`suspending`, `suspend`,
`canceled` and `failed`."
/>
</property>

View File

@ -13,21 +13,32 @@ JobService::~JobService() {}
QString JobService::status() const
{
// TODO: impl
return {};
if (job.isFinished())
return "finished";
if (job.isCanceled())
return "canceled";
if (job.isSuspended())
return "suspended";
if (job.isSuspending())
return "suspending";
if (job.isStarted())
return "started";
if (job.isRunning())
return "running";
return "failed";
}
void JobService::Cancel()
{
// TODO: impl
job.cancel();
}
void JobService::Pause()
{
// TODO: impl
job.suspend();
}
void JobService::Resume()
{
// TODO: impl
job.resume();
}

View File

@ -6,6 +6,8 @@
#define JOBSERVICE_H
#include <QObject>
#include <QFuture>
#include <QVariant>
class JobService : public QObject
{
@ -22,6 +24,9 @@ public Q_SLOTS:
void Cancel();
void Pause();
void Resume();
private:
QFuture<QVariant> job;
};
#endif