[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/battery
From: Christopher Blauvelt <cblauvelt () gmail ! com>
Date: 2007-06-28 17:36:37
Message-ID: 1183052197.163734.28889.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 681351 by cblauvelt:
Convert the battery applet to use the soliddevice engine.
M +15 -9 battery.cpp
M +1 -0 battery.h
--- trunk/playground/base/plasma/applets/battery/battery.cpp #681350:681351
@@ -57,12 +57,18 @@
m_theme->setContentType(Plasma::Svg::SingleImage);
m_theme->resize(m_pixelSize, m_pixelSize);
- dataEngine("battery")->connectSource(I18N_NOOP("Battery"), this);
- dataEngine("battery")->connectSource(I18N_NOOP("AC Adapter"), this);
+ //get list of devices
+ dataEngine("soliddevice")->connectSource(I18N_NOOP("Devices"), this);
+ Plasma::DataEngine::Data devicelist = \
dataEngine("soliddevice")->query(I18N_NOOP("Devices")); + //connect to battery source
+ batterylist = devicelist["BatteryList"].toList();
+ acadapterlist = devicelist["AcAdapterList"].toList();
+ dataEngine("soliddevice")->connectSource(I18N_NOOP(batterylist[0].toString()), \
this); + dataEngine("soliddevice")->connectSource(I18N_NOOP(acadapterlist[0].toString()), \
this);
constraintsUpdated();
- updated(I18N_NOOP("Battery"), \
dataEngine("battery")->query(I18N_NOOP("Battery")));
- updated(I18N_NOOP("AC Adapter"), dataEngine("battery")->query(I18N_NOOP("AC \
Adapter"))); + updated(batterylist[0].toString(), \
dataEngine("soliddevice")->query(I18N_NOOP(batterylist[0].toString()))); \
+ updated(acadapterlist[0].toString(), \
dataEngine("soliddevice")->query(I18N_NOOP(acadapterlist[0].toString()))); }
QRectF Battery::boundingRect() const
@@ -79,12 +85,12 @@
void Battery::updated(const QString& source, const Plasma::DataEngine::Data &data)
{
- if (source == I18N_NOOP("Battery")) {
- m_battery_percent = data[I18N_NOOP("Percent")].toInt();
- m_battery_percent_label = data[I18N_NOOP("Percent")].toString();
+ if (source == I18N_NOOP(batterylist[0].toString())) {
+ m_battery_percent = data[I18N_NOOP("ChargePercent")].toInt();
+ m_battery_percent_label = data[I18N_NOOP("ChargePercent")].toString();
kDebug() << "Battery::updated " << m_battery_percent << endl;
- } else if (source == I18N_NOOP("AC Adapter")) {
- m_acadapter_plugged = data[I18N_NOOP("Plugged in")].toBool();
+ } else if (source == I18N_NOOP(acadapterlist[0].toString())) {
+ m_acadapter_plugged = data[I18N_NOOP("Plugged")].toBool();
kDebug() << "AC Adapter updated: " << m_acadapter_plugged << endl;
} else {
kDebug() << "Dunno what to do with " << source << endl;
--- trunk/playground/base/plasma/applets/battery/battery.h #681350:681351
@@ -68,6 +68,7 @@
KDialog *m_dialog;
QCheckBox *m_showBatteryStringCheckBox;
QSpinBox *m_spinSize;
+ QList<QVariant> batterylist, acadapterlist;
};
K_EXPORT_PLASMA_APPLET(battery, Battery)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic