Commit 72094323 authored by Lukáš Tinkl's avatar Lukáš Tinkl

implement resumeFromSuspend()

parent 51181d4c
/*
Copyright 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
Copyright 2014 Lukáš Tinkl <ltinkl@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -23,21 +24,27 @@
#include <QDebug>
#include <QDBusConnection>
#include <QtDBus/QDBusConnection>
Solid::FDPowerNotifier::FDPowerNotifier(QObject* parent): PowerNotifier(parent)
{
auto conn = QDBusConnection::systemBus();
conn.connect(QStringLiteral("org.freedesktop.UPower"),
QStringLiteral("/org/freedesktop/UPower"),
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("PropertiesChanged"),
this,
SLOT(propertiesChanged(QString, QVariantMap, QStringList))
);
QStringLiteral("/org/freedesktop/UPower"),
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("PropertiesChanged"),
this,
SLOT(upowerPropertiesChanged(QString, QVariantMap, QStringList))
);
conn.connect(QStringLiteral("org.freedesktop.login1"),
QStringLiteral("/org/freedesktop/login1"),
QStringLiteral("org.freedesktop.login1.Manager"),
QStringLiteral("PrepareForSleep"),
this,
SLOT(login1Resuming(bool))
);
}
void Solid::FDPowerNotifier::propertiesChanged(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidated)
void Solid::FDPowerNotifier::upowerPropertiesChanged(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidated)
{
if (interface != QStringLiteral("org.freedesktop.UPower")) {
return;
......@@ -52,3 +59,10 @@ void Solid::FDPowerNotifier::propertiesChanged(const QString &interface, const Q
qDebug() << "Invalidated" << invalidated;
}
}
void Solid::FDPowerNotifier::login1Resuming(bool active)
{
if (!active) {
Q_EMIT resumeFromSuspend();
}
}
......@@ -32,8 +32,9 @@ class FDPowerNotifier : public PowerNotifier
public:
explicit FDPowerNotifier(QObject* parent = 0);
public Q_SLOTS:
void propertiesChanged(const QString& interface, const QVariantMap& changedProperties, const QStringList& invalidated);
private Q_SLOTS:
void upowerPropertiesChanged(const QString& interface, const QVariantMap& changedProperties, const QStringList& invalidated);
void login1Resuming(bool active);
};
}
......
......@@ -33,6 +33,7 @@ public:
Q_SIGNALS:
void acPluggedChanged(bool plugged);
void resumeFromSuspend();
};
}
......
......@@ -45,8 +45,10 @@ Power* Power::self()
Power::Power(QObject* parent) : QObject(parent), d(new Private)
{
qRegisterMetaType<Solid::Inhibition::State>("Inhibition::State");
d->notifier = PowerBackendLoader::notifier();
connect(d->notifier, &PowerNotifier::acPluggedChanged, this, &Power::acPluggedChanged);
connect(d->notifier, &PowerNotifier::resumeFromSuspend, this, &Power::resumeFromSuspend);
}
AcPluggedJob* Power::isAcPlugged(QObject* parent)
......
......@@ -112,6 +112,11 @@ Q_SIGNALS:
*/
void acPluggedChanged(bool plugged);
/**
* Emitted when the system has just resumed from being suspended/hibernated
*/
void resumeFromSuspend();
private:
class Private;
Private * const d;
......
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