Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / plasma / applets / battery / battery.h
blobd0f98aa962c9760d8be5354d362d48d1ac4bbbd7
1 /***************************************************************************
2 * Copyright (C) 2005,2006,2007 by Siraj Razick <siraj@kdemail.net> *
3 * Copyright (C) 2007 by Sebastian Kuegler <sebas@kde.org> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19 ***************************************************************************/
21 #ifndef BATTERY_H
22 #define BATTERY_H
24 #include <QLabel>
25 #include <QGraphicsSceneHoverEvent>
26 #include <QPair>
27 #include <QMap>
29 #include <plasma/applet.h>
30 #include <plasma/phase.h>
31 #include <plasma/dataengine.h>
32 #include "ui_batteryConfig.h"
34 class KDialog;
36 namespace Plasma
38 class Svg;
41 class Battery : public Plasma::Applet
43 Q_OBJECT
44 public:
45 Battery(QObject *parent, const QVariantList &args);
46 ~Battery();
48 void init();
49 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
50 const QRect &contents);
51 void setPath(const QString&);
52 QSizeF contentSizeHint() const;
53 Qt::Orientations expandingDirections() const;
55 void constraintsUpdated(Plasma::Constraints constraints);
57 public slots:
58 void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
59 void showConfigurationInterface();
61 protected Q_SLOTS:
62 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
63 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
65 //protected slots:
66 void configAccepted();
67 void readColors();
69 private slots:
70 void animationUpdate(qreal progress);
71 void acAnimationUpdate(qreal progress);
72 void batteryAnimationUpdate(qreal progress);
74 private:
75 Q_ENUMS( m_batteryStyle )
76 enum ClockStyle {
77 // Keep the order of styles the same order as the items in the configdialog!
78 OxygenBattery, ClassicBattery
80 void connectSources();
81 void disconnectSources();
82 int m_batteryStyle;
83 /* Paint battery with proper charge level */
84 void paintBattery(QPainter *p, const QRect &contentsRect, const int batteryPercent, const bool plugState);
85 /* Paint a label on top of the battery */
86 void paintLabel(QPainter *p, const QRect &contentsRect, const QString& labelText);
87 /* Fade in/out the label above the battery. */
88 void showLabel(bool show);
89 /* Scale in/out Battery. */
90 void showBattery(bool show);
91 /* Scale in/out Ac Adapter. */
92 void showAcAdapter(bool show);
93 /* Scale in a QRectF */
94 QRectF scaleRectF(qreal progress, QRectF rect);
95 /* Show multiple batteries with individual icons and charge info? */
96 bool m_showMultipleBatteries;
97 /* Should the battery charge information be shown on top? */
98 bool m_showBatteryString;
99 QSizeF m_size;
100 int m_pixelSize;
101 int m_smallPixelSize;
102 Plasma::Svg* m_theme;
103 bool m_acadapter_plugged;
105 // Configuration dialog
106 KDialog *m_dialog;
107 Ui::batteryConfig ui;
109 Plasma::Phase::AnimId m_animId;
110 qreal m_alpha;
111 bool m_fadeIn;
113 Plasma::Phase::AnimId m_acAnimId;
114 qreal m_acAlpha;
115 bool m_acFadeIn;
117 Plasma::Phase::AnimId m_batteryAnimId;
118 qreal m_batteryAlpha;
119 bool m_batteryFadeIn;
121 // Internal data
122 QList<QVariant> batterylist, acadapterlist;
123 QHash<QString, QHash<QString, QVariant> > m_batteries_data;
124 QFont m_font;
125 bool m_isHovered;
126 bool m_drawBackground;
127 QColor m_boxColor;
128 QColor m_textColor;
129 int m_boxAlpha;
130 int m_boxHoverAlpha;
131 int m_numOfBattery;
134 K_EXPORT_PLASMA_APPLET(battery, Battery)
136 #endif