|
|
@ -34,8 +34,10 @@
|
|
|
|
using namespace LXQt;
|
|
|
|
using namespace LXQt;
|
|
|
|
|
|
|
|
|
|
|
|
Power::Power(QObject *parent) :
|
|
|
|
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 CustomProvider(this));
|
|
|
|
mProviders.append(new SystemdProvider(this));
|
|
|
|
mProviders.append(new SystemdProvider(this));
|
|
|
|
mProviders.append(new UPowerProvider(this));
|
|
|
|
mProviders.append(new UPowerProvider(this));
|
|
|
@ -66,12 +68,19 @@ bool Power::doAction(Power::Action action)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach(PowerProvider* provider, mProviders)
|
|
|
|
foreach(PowerProvider* provider, mProviders)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (provider->canAction(action) &&
|
|
|
|
if (provider->canAction(action))
|
|
|
|
provider->doAction(action)
|
|
|
|
{
|
|
|
|
)
|
|
|
|
if (action == PowerSuspend || action == PowerHibernate)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mScreenSaver.lockScreen();
|
|
|
|
|
|
|
|
mLoop.exec();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (provider->doAction(action))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|