Commit 39051155 authored by Leslie Zhai's avatar Leslie Zhai

Implement preventing from going into suspend/hibernate by system.

but waiting for KF5::Solid WITH_NEW_SOLID_JOB WIP: Base class for
 Solid Asynchronous apis https://cgit.kde.org/solid.git/tree/CMakeLists.txt#n79

BUG: 280134
parent a3591739
......@@ -72,6 +72,12 @@ endif()
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
option(WITH_NEW_SOLID_JOB "WIP: base Job class" Off)
add_feature_info(Solid::Job WITH_NEW_SOLID_JOB "WIP: Base class for Solid Asynchronous apis")
if(WITH_NEW_SOLID_JOB)
add_definitions(-DWITH_NEW_SOLID_JOB)
endif()
find_package(Iconv)
set(HAVE_ICONV "${ICONV_FOUND}")
......
......@@ -31,6 +31,9 @@
#include <KConfigCore/KConfig>
#include <KConfigCore/KConfigGroup>
#ifdef WITH_NEW_SOLID_JOB
#include <Solid/Power>
#endif
#include <QtCore/QCoreApplication>
#include <QtCore/QEvent>
......@@ -107,6 +110,11 @@ public:
QList<K3b::Job*> runningJobs;
QList<K3b::Device::Device*> blockedDevices;
#ifdef WITH_NEW_SOLID_JOB
Solid::InhibitionJob *inhibitSleepJob = nullptr;
Solid::InhibitionJob *inhibitNoneJob = nullptr;
#endif
};
......@@ -234,21 +242,35 @@ void K3b::Core::saveSettings( KSharedConfig::Ptr c )
}
void K3b::Core::registerJob( K3b::Job* job )
void K3b::Core::registerJob(K3b::Job* job)
{
d->runningJobs.append( job );
emit jobStarted( job );
if( K3b::BurnJob* bj = dynamic_cast<K3b::BurnJob*>( job ) )
emit burnJobStarted( bj );
d->runningJobs.append(job);
emit jobStarted(job);
if (K3b::BurnJob* bj = dynamic_cast<K3b::BurnJob*>(job)) {
#ifdef WITH_NEW_SOLID_JOB
d->inhibitSleepJob = Solid::Power::inhibit(Solid::Power::Sleep,
i18n("Inhibiting sleep for disc writing"));
if (d->inhibitSleepJob)
d->inhibitSleepJob->start();
#endif
emit burnJobStarted(bj);
}
}
void K3b::Core::unregisterJob( K3b::Job* job )
void K3b::Core::unregisterJob(K3b::Job* job)
{
d->runningJobs.removeAll( job );
emit jobFinished( job );
if( K3b::BurnJob* bj = dynamic_cast<K3b::BurnJob*>( job ) )
emit burnJobFinished( bj );
d->runningJobs.removeAll(job);
emit jobFinished(job);
if (K3b::BurnJob* bj = dynamic_cast<K3b::BurnJob*>(job)) {
#ifdef WITH_NEW_SOLID_JOB
d->inhibitNoneJob = Solid::Power::inhibit(Solid::None,
i18n("Inhibiting none for disc writing"));
if (d->inhibitNoneJob)
d->inhibitNoneJob->start();
#endif
emit burnJobFinished(bj);
}
}
......
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