Changeset View
Changeset View
Standalone View
Standalone View
daemon/powerdevilcore.cpp
Show First 20 Lines • Show All 505 Lines • ▼ Show 20 Line(s) | |||||
506 | { | 506 | { | ||
507 | using namespace Solid; | 507 | using namespace Solid; | ||
508 | Device device(udi); | 508 | Device device(udi); | ||
509 | Battery *b = qobject_cast<Battery *>(device.asDeviceInterface(DeviceInterface::Battery)); | 509 | Battery *b = qobject_cast<Battery *>(device.asDeviceInterface(DeviceInterface::Battery)); | ||
510 | 510 | | |||
511 | if (b && !b->isPowerSupply()) { | 511 | if (b && !b->isPowerSupply()) { | ||
512 | // if you leave the device out of reach or it has not been initialized yet | 512 | // if you leave the device out of reach or it has not been initialized yet | ||
513 | // it won't be "there" and report 0%, don't show anything in this case | 513 | // it won't be "there" and report 0%, don't show anything in this case | ||
514 | if (!b->isPresent() || b->chargeState() != Battery::Discharging) { | 514 | if (!b->isPresent() || b->chargePercent() == 0) { | ||
515 | return false; | ||||
516 | } | ||||
517 | | ||||
518 | // Bluetooth devices don't report charge state, so it's "NoCharge" in all cases for them | ||||
519 | if (b->chargeState() != Battery::Discharging && b->chargeState() != Battery::NoCharge) { | ||||
515 | return false; | 520 | return false; | ||
516 | } | 521 | } | ||
517 | 522 | | |||
518 | if (currentPercent <= PowerDevilSettings::peripheralBatteryLowLevel() && | 523 | if (currentPercent <= PowerDevilSettings::peripheralBatteryLowLevel() && | ||
519 | previousPercent > PowerDevilSettings::peripheralBatteryLowLevel()) { | 524 | previousPercent > PowerDevilSettings::peripheralBatteryLowLevel()) { | ||
520 | 525 | | |||
521 | QString name = device.product(); | 526 | QString name = device.product(); | ||
522 | if (!device.vendor().isEmpty()) { | 527 | if (!device.vendor().isEmpty()) { | ||
▲ Show 20 Lines • Show All 386 Lines • Show Last 20 Lines |