diff --git a/lxqtpower/lxqtpower.cpp b/lxqtpower/lxqtpower.cpp index 742793b..3585227 100644 --- a/lxqtpower/lxqtpower.cpp +++ b/lxqtpower/lxqtpower.cpp @@ -34,8 +34,10 @@ using namespace LXQt; Power::Power(QObject *parent) : - QObject(parent) + QObject(parent), + mScreenSaver(this) { + connect(&mScreenSaver, SIGNAL(done()), &mLoop, SLOT(quit())); mProviders.append(new CustomProvider(this)); mProviders.append(new SystemdProvider(this)); mProviders.append(new UPowerProvider(this)); @@ -66,11 +68,18 @@ bool Power::doAction(Power::Action action) { foreach(PowerProvider* provider, mProviders) { - if (provider->canAction(action) && - provider->doAction(action) - ) + if (provider->canAction(action)) { - return true; + if (action == PowerSuspend || action == PowerHibernate) + { + mScreenSaver.lockScreen(); + mLoop.exec(); + } + if (provider->doAction(action)) + { + return true; + } + return false; } } return false; diff --git a/lxqtpower/lxqtpower.h b/lxqtpower/lxqtpower.h index f738b46..c85e2e2 100644 --- a/lxqtpower/lxqtpower.h +++ b/lxqtpower/lxqtpower.h @@ -31,6 +31,8 @@ #include #include +#include +#include "lxqtscreensaver.h" #include "lxqtglobals.h" namespace LXQt @@ -101,6 +103,8 @@ public slots: private: QList mProviders; + LXQt::ScreenSaver mScreenSaver; + QEventLoop mLoop; }; } // namespace LXQt