|
|
@ -34,22 +34,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
Lid::Lid()
|
|
|
|
Lid::Lid()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mUPowerInterface = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower",
|
|
|
|
mUPowerInterface = new QDBusInterface("org.freedesktop.UPower",
|
|
|
|
QDBusConnection::systemBus(), this);
|
|
|
|
"/org/freedesktop/UPower",
|
|
|
|
mUPowerPropertiesInterface = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties",
|
|
|
|
"org.freedesktop.UPower",
|
|
|
|
QDBusConnection::systemBus(), this);
|
|
|
|
QDBusConnection::systemBus(), this);
|
|
|
|
if (! connect(mUPowerInterface, SIGNAL(Changed()), this, SLOT(uPowerChange())))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qDebug() << "Could not connect to org.freedesktop.UPower.changed(), connecting to org.freedesktop.DBus.Properties.PropertiesChanged(..) instead";
|
|
|
|
|
|
|
|
QDBusConnection::systemBus().connect("org.freedesktop.UPower",
|
|
|
|
|
|
|
|
"/org/freedesktop/UPower",
|
|
|
|
|
|
|
|
"org.freedesktop.DBus.Properties",
|
|
|
|
|
|
|
|
"PropertiesChanged",
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
SLOT(uPowerChange()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mIsClosed = mUPowerPropertiesInterface->property("LidIsClosed").toBool();
|
|
|
|
mUPowerPropertiesInterface = new QDBusInterface("org.freedesktop.UPower",
|
|
|
|
|
|
|
|
"/org/freedesktop/UPower",
|
|
|
|
|
|
|
|
"org.freedesktop.DBus.Properties",
|
|
|
|
|
|
|
|
QDBusConnection::systemBus(), this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!QDBusConnection::systemBus().connect("org.freedesktop.UPower",
|
|
|
|
|
|
|
|
"/org/freedesktop/UPower",
|
|
|
|
|
|
|
|
"org.freedesktop.DBus.Properties",
|
|
|
|
|
|
|
|
"PropertiesChanged",
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
SLOT(uPowerChange())))
|
|
|
|
|
|
|
|
qDebug() << "Could not connect to org.freedesktop.DBus.Properties.PropertiesChanged()";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mIsClosed = mUPowerPropertiesInterface->property("LidIsClosed").toBool();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Lid::haveLid()
|
|
|
|
bool Lid::haveLid()
|
|
|
@ -62,7 +65,6 @@ bool Lid::onBattery()
|
|
|
|
return mUPowerInterface->property("OnBattery").toBool();
|
|
|
|
return mUPowerInterface->property("OnBattery").toBool();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Lid::uPowerChange()
|
|
|
|
void Lid::uPowerChange()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool newIsClosed = mUPowerInterface->property("LidIsClosed").toBool();
|
|
|
|
bool newIsClosed = mUPowerInterface->property("LidIsClosed").toBool();
|
|
|
|