[Kde-hardware-devel] [kde-workspace] powerdevil/kcmodule/profiles: Early exit battery loop. Disregard non-powersupply batteries for profile config.
Kai Uwe Broulik
kde at privat.broulik.de
Thu Jun 13 14:13:09 UTC 2013
Git commit faa8548ec43265771ceddf0fe81b3ebf98cbbc50 by Kai Uwe Broulik.
Committed on 13/06/2013 at 16:12.
Pushed by broulik into branch 'master'.
Early exit battery loop. Disregard non-powersupply batteries for profile config.
CCMAIL: kde-hardware-devel at kde.org
M +5 -6 powerdevil/kcmodule/profiles/EditPage.cpp
http://commits.kde.org/kde-workspace/faa8548ec43265771ceddf0fe81b3ebf98cbbc50
diff --git a/powerdevil/kcmodule/profiles/EditPage.cpp b/powerdevil/kcmodule/profiles/EditPage.cpp
index 4f89adb..0865b90 100644
--- a/powerdevil/kcmodule/profiles/EditPage.cpp
+++ b/powerdevil/kcmodule/profiles/EditPage.cpp
@@ -127,17 +127,16 @@ EditPage::EditPage(QWidget *parent, const QVariantList &args)
connect(watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(onServiceRegistered(QString)));
connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(onServiceUnregistered(QString)));
- int batteryCount = 0;
-
+ bool hasBattery = false;
foreach(const Solid::Device &device, Solid::Device::listFromType(Solid::DeviceInterface::Battery, QString())) {
const Solid::Battery *b = qobject_cast<const Solid::Battery*> (device.asDeviceInterface(Solid::DeviceInterface::Battery));
- if(b->type() != Solid::Battery::PrimaryBattery && b->type() != Solid::Battery::UpsBattery) {
- continue;
+ if (b->isPowerSupply() && (b->type() == Solid::Battery::PrimaryBattery || b->type() == Solid::Battery::UpsBattery)) {
+ hasBattery = true;
+ break;
}
- ++batteryCount;
}
- if (batteryCount == 0) {
+ if (!hasBattery) {
tabWidget->setTabEnabled(1, false);
tabWidget->setTabEnabled(2, false);
tabWidget->setTabBarHidden(true);
More information about the Kde-hardware-devel
mailing list