homescreenapp/examples/batterywidgetplugin/src/batterywidget.cpp
changeset 85 35368b604b28
parent 61 2b1b11a301d2
equal deleted inserted replaced
77:4b195f3bea29 85:35368b604b28
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Example of home screen widget
    14 * Description:  Example of home screen widget
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 
       
    19 //#define OWN_TESTING
       
    20 
       
    21 
    17 
    22 #include <QGraphicsLinearLayout>
    18 #include <QGraphicsLinearLayout>
    23 #include <QPainter>
    19 #include <QPainter>
    24 #include <QTimer>
    20 #include <QTimer>
    25 #include "BatteryWidget.h"
    21 #include "BatteryWidget.h"
   244 {
   240 {
   245     mDeviceInfo->disconnect(this);
   241     mDeviceInfo->disconnect(this);
   246     mChargingTimer->stop();
   242     mChargingTimer->stop();
   247     mChargingTimer->disconnect(this);
   243     mChargingTimer->disconnect(this);
   248     connect(mDeviceInfo, SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), SLOT(powerStateChanged(QSystemDeviceInfo::PowerState)));
   244     connect(mDeviceInfo, SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), SLOT(powerStateChanged(QSystemDeviceInfo::PowerState)));
   249 #ifdef OWN_TESTING
       
   250     connect(mChargingTimer, SIGNAL(timeout()), this, SLOT(updateChargingBatteryValue()));
       
   251     mChargingTimer->start(1000);
       
   252 #else
       
   253     if (mDeviceInfo->currentPowerState() == QSystemDeviceInfo::WallPowerChargingBattery) {
   245     if (mDeviceInfo->currentPowerState() == QSystemDeviceInfo::WallPowerChargingBattery) {
   254         connect(mChargingTimer, SIGNAL(timeout()), this, SLOT(updateChargingBatteryValue()));
   246         connect(mChargingTimer, SIGNAL(timeout()), this, SLOT(updateChargingBatteryValue()));
   255         mChargingTimer->start(500);
   247         mChargingTimer->start(500);
   256     } else {
   248     } else {
   257         connect(mDeviceInfo, SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)), SLOT(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)));
       
   258         connect(mDeviceInfo, SIGNAL(batteryLevelChanged(int)), SLOT(batteryLevelChanged(int)));
   249         connect(mDeviceInfo, SIGNAL(batteryLevelChanged(int)), SLOT(batteryLevelChanged(int)));
   259         mBatteryValue = mDeviceInfo->batteryLevel();
   250         mBatteryValue = mDeviceInfo->batteryLevel();
   260     }
   251     }
   261 #endif    
       
   262     drawBatteryImage();
   252     drawBatteryImage();
   263     update();
   253     update();
   264 }
   254 }
   265 
   255