Commit d8215d54 authored by ivan tkachenko's avatar ivan tkachenko Committed by Nate Graham
Browse files

[dataengines/powermanagement] Ensure Battery.Percent data is always an integer

It used to have inconsistent types depending on internal conditions
(sometimes double, sometimes int), but now it's fixed.
parent 271bdc25
Pipeline #125435 passed with stage
in 7 minutes and 17 seconds
......@@ -630,13 +630,13 @@ void PowermanagementEngine::updateOverallBattery()
// Energy is sometimes way off causing us to show rubbish; this is a UPower issue
// but anyway having just one battery and the tooltip showing strange readings
// compared to the popup doesn't look polished.
setData(QStringLiteral("Battery"), QStringLiteral("Percent"), totalPercentage);
setData(QStringLiteral("Battery"), QStringLiteral("Percent"), qRound(totalPercentage));
} else if (totalEnergy > 0) {
setData(QStringLiteral("Battery"), QStringLiteral("Percent"), qRound(energy / totalEnergy * 100));
} else if (count > 0) { // UPS don't have energy, see Bug 348588
setData(QStringLiteral("Battery"), QStringLiteral("Percent"), qRound(totalPercentage / static_cast<qreal>(count)));
} else {
setData(QStringLiteral("Battery"), QStringLiteral("Percent"), 0);
setData(QStringLiteral("Battery"), QStringLiteral("Percent"), int(0));
}
if (hasCumulative) {
......
Supports Markdown
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