homescreenapp/examples/batterywidgetplugin/src/batterywidget.cpp
changeset 81 7dd137878ff8
parent 62 341166945d65
equal deleted inserted replaced
76:3916af29624a 81:7dd137878ff8
    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