src/hbcore/decorators/hbbatteryindicator.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
--- a/src/hbcore/decorators/hbbatteryindicator.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbcore/decorators/hbbatteryindicator.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -128,6 +128,34 @@
 
 }
 
+int HbBatteryIndicator::level() const
+{ 
+    Q_D(const HbBatteryIndicator);
+    return d->mLevelPercent;
+}
+
+bool HbBatteryIndicator::isCharging() const
+{
+    Q_D(const HbBatteryIndicator);
+    // Cannot use mChargingOn only because this function must work
+    // reliably even when called while being in setLevel(). On the
+    // other hand the timer is stopped while being in sleep mode. So
+    // check both.
+    return d->mChargingTimer.isActive() || d->mChargingOn;
+}
+
+void HbBatteryIndicator::chargingEvent(bool start)
+{
+    Q_D(HbBatteryIndicator);
+    if (start) {
+        if (d->mChargingOn) {
+            d->mChargingTimer.start(250, this);
+        }
+    } else {
+        d->mChargingTimer.stop();
+    }
+}
+
 void HbBatteryIndicator::createPrimitives()
 {
     Q_D(HbBatteryIndicator);
@@ -146,12 +174,6 @@
     HbStylePrivate::updatePrimitive(d->mBatteryLevelIcon, HbStylePrivate::P_BatteryLevel_icon, &option);
 }
 
-int HbBatteryIndicator::level() const
-{ 
-    Q_D(const HbBatteryIndicator);
-    return d->mLevelPercent;
-}
-
 /*  
     set battery strength level. \a level value should be between 0 and 100
     \a level value is ignored if out of range.
@@ -222,16 +244,6 @@
     option->batteryValue = d->mLevelPercent;
 }
 
-bool HbBatteryIndicator::isCharging() const
-{
-    Q_D(const HbBatteryIndicator);
-    // Cannot use mChargingOn only because this function must work
-    // reliably even when called while being in setLevel(). On the
-    // other hand the timer is stopped while being in sleep mode. So
-    // check both.
-    return d->mChargingTimer.isActive() || d->mChargingOn;
-}
-
 /*!
     \reimp
 */