summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeslie Zhai <[email protected]>2017-09-07 11:43:31 +0800
committerLeslie Zhai <[email protected]>2017-09-07 11:43:31 +0800
commit39051155b116c317608181e78b843373615054ef (patch)
tree230c2448b37a5e1bbb4e879ba4367af4f9c6d366
parenta359173975e574c4cae62214f7de28648d14167c (diff)
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
-rw-r--r--CMakeLists.txt6
-rw-r--r--libk3b/core/k3bcore.cpp42
2 files changed, 38 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00968b3..af9ae72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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}")
diff --git a/libk3b/core/k3bcore.cpp b/libk3b/core/k3bcore.cpp
index 97e4797..7eb7eb9 100644
--- a/libk3b/core/k3bcore.cpp
+++ b/libk3b/core/k3bcore.cpp
@@ -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);
+ }
}