homescreenapp/examples/batterywidgetplugin/inc/batterywidget.h
changeset 62 341166945d65
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Example of home screen widget
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BatteryWidget_H
       
    19 #define BatteryWidget_H
       
    20 
       
    21 #include <HbWidget>
       
    22 
       
    23 #include <qsysteminfo.h>
       
    24 QTM_USE_NAMESPACE
       
    25 
       
    26 
       
    27 class BatteryWidget : public HbWidget
       
    28 {
       
    29     Q_OBJECT
       
    30 // Start of snippet 1
       
    31     Q_PROPERTY(QString rootPath READ rootPath WRITE setRootPath)
       
    32 // End of snippet 1
       
    33 
       
    34 public:
       
    35     BatteryWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
       
    36     ~BatteryWidget();
       
    37     
       
    38 // Start of snippet 2
       
    39 public:
       
    40     QString rootPath() const;
       
    41     void setRootPath(QString &rootPath);
       
    42 // End of snippet 2
       
    43 
       
    44 public:
       
    45     QRectF boundingRect() const;
       
    46     QPainterPath shape() const;
       
    47     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
       
    48     
       
    49 public slots: // from home screen widget model
       
    50     void onShow();
       
    51     void onHide();
       
    52     void onInitialize();
       
    53     void onUninitialize();
       
    54 
       
    55 public slots:
       
    56     void batteryLevelChanged(int level);
       
    57     void powerStateChanged(QSystemDeviceInfo::PowerState powerState);
       
    58     void updateChargingBatteryValue();
       
    59 
       
    60 signals:
       
    61     void error();
       
    62 
       
    63 private:
       
    64     void drawBatteryImage();
       
    65     void stateChanged();
       
    66     
       
    67 private:
       
    68     Q_DISABLE_COPY(BatteryWidget)
       
    69     QString mRootPath;
       
    70     QSystemDeviceInfo *mDeviceInfo;
       
    71     int mBatteryValue;
       
    72     QPixmap mBatteryBackgroundBitmap;
       
    73     QPixmap mUnifiedBatteryBitmap;
       
    74     QTimer *mChargingTimer;
       
    75 };
       
    76 
       
    77 #endif // BatteryWidget_H