Applets
battery.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BATTERY_H
00021 #define BATTERY_H
00022
00023 #include <QLabel>
00024 #include <QGraphicsSceneHoverEvent>
00025 #include <QPair>
00026 #include <QMap>
00027
00028 #include <plasma/applet.h>
00029 #include <plasma/animator.h>
00030 #include <plasma/dataengine.h>
00031 #include "ui_batteryConfig.h"
00032
00033 namespace Plasma
00034 {
00035 class Svg;
00036 }
00037
00038 class Battery : public Plasma::Applet
00039 {
00040 Q_OBJECT
00041 public:
00042 Battery(QObject *parent, const QVariantList &args);
00043 ~Battery();
00044
00045 void init();
00046 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
00047 const QRect &contents);
00048 void setPath(const QString&);
00049 QSizeF contentSizeHint() const;
00050 Qt::Orientations expandingDirections() const;
00051
00052 void constraintsEvent(Plasma::Constraints constraints);
00053
00054 public slots:
00055 void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
00056
00057 protected Q_SLOTS:
00058 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00059 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00060 void configAccepted();
00061 void readColors();
00062
00063 protected:
00064 void createConfigurationInterface(KConfigDialog *parent);
00065
00066 private slots:
00067 void animationUpdate(qreal progress);
00068 void acAnimationUpdate(qreal progress);
00069 void batteryAnimationUpdate(qreal progress);
00070
00071 private:
00072 Q_ENUMS( m_batteryStyle )
00073 enum ClockStyle {
00074
00075 OxygenBattery, ClassicBattery
00076 };
00077 void connectSources();
00078 void disconnectSources();
00079 int m_batteryStyle;
00080
00081 void paintBattery(QPainter *p, const QRect &contentsRect, const int batteryPercent, const bool plugState);
00082
00083 void paintLabel(QPainter *p, const QRect &contentsRect, const QString& labelText);
00084
00085 void showLabel(bool show);
00086
00087 void showBattery(bool show);
00088
00089 void showAcAdapter(bool show);
00090
00091 QRectF scaleRectF(qreal progress, QRectF rect);
00092
00093 bool m_showMultipleBatteries;
00094
00095 bool m_showBatteryString;
00096 QSizeF m_size;
00097 int m_pixelSize;
00098 Plasma::Svg* m_theme;
00099 bool m_acadapter_plugged;
00100
00101
00102 Ui::batteryConfig ui;
00103
00104 int m_animId;
00105 qreal m_alpha;
00106 bool m_fadeIn;
00107
00108 int m_acAnimId;
00109 qreal m_acAlpha;
00110 bool m_acFadeIn;
00111
00112 int m_batteryAnimId;
00113 qreal m_batteryAlpha;
00114 bool m_batteryFadeIn;
00115
00116
00117 QList<QVariant> batterylist, acadapterlist;
00118 QHash<QString, QHash<QString, QVariant> > m_batteries_data;
00119 QFont m_font;
00120 bool m_isHovered;
00121 QColor m_boxColor;
00122 QColor m_textColor;
00123 QRectF m_textRect;
00124 int m_boxAlpha;
00125 int m_boxHoverAlpha;
00126 int m_numOfBattery;
00127 };
00128
00129 K_EXPORT_PLASMA_APPLET(battery, Battery)
00130
00131 #endif