Changeset View
Changeset View
Standalone View
Standalone View
daemon/powerdevilcore.cpp
Show First 20 Lines • Show All 420 Lines • ▼ Show 20 Line(s) | 415 | { | |||
---|---|---|---|---|---|
421 | using namespace Solid; | 421 | using namespace Solid; | ||
422 | Device device(udi); | 422 | Device device(udi); | ||
423 | Battery *b = qobject_cast<Battery *>(device.asDeviceInterface(DeviceInterface::Battery)); | 423 | Battery *b = qobject_cast<Battery *>(device.asDeviceInterface(DeviceInterface::Battery)); | ||
424 | 424 | | |||
425 | if (!b) { | 425 | if (!b) { | ||
426 | return; | 426 | return; | ||
427 | } | 427 | } | ||
428 | 428 | | |||
429 | connect(b, &Battery::chargePercentChanged, this, &Core::onBatteryChargePercentChanged); | ||||
430 | connect(b, &Battery::chargeStateChanged, this, &Core::onBatteryChargeStateChanged); | ||||
431 | | ||||
429 | qCDebug(POWERDEVIL) << "Battery with UDI" << udi << "was detected"; | 432 | qCDebug(POWERDEVIL) << "Battery with UDI" << udi << "was detected"; | ||
430 | 433 | | |||
431 | if (b->isPowerSupply()) { | 434 | if (b->isPowerSupply()) { | ||
432 | m_batteriesPercent[udi] = b->chargePercent(); | 435 | m_batteriesPercent[udi] = b->chargePercent(); | ||
433 | m_batteriesCharged[udi] = (b->chargeState() == Solid::Battery::FullyCharged); | 436 | m_batteriesCharged[udi] = (b->chargeState() == Solid::Battery::FullyCharged); | ||
434 | } else { // non-power supply batteries are treated separately | 437 | } else { // non-power supply batteries are treated separately | ||
435 | m_peripheralBatteriesPercent[udi] = b->chargePercent(); | 438 | m_peripheralBatteriesPercent[udi] = b->chargePercent(); | ||
436 | 439 | | |||
▲ Show 20 Lines • Show All 461 Lines • Show Last 20 Lines |