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 <QGraphicsGridLayout>
00026 #include <QPair>
00027 #include <QMap>
00028
00029 #include <Plasma/Applet>
00030 #include <Plasma/Animator>
00031 #include <Plasma/DataEngine>
00032 #include <Plasma/PopupApplet>
00033 #include "ui_batteryConfig.h"
00034
00035 namespace Plasma
00036 {
00037 class Svg;
00038 class Label;
00039 class ExtenderItem;
00040 class ComboBox;
00041 class Slider;
00042 }
00043
00044 class Battery : public Plasma::PopupApplet
00045 {
00046 Q_OBJECT
00047 public:
00048 Battery(QObject *parent, const QVariantList &args);
00049 ~Battery();
00050
00051 void init();
00052 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
00053 const QRect &contents);
00054 void setPath(const QString&);
00055 Qt::Orientations expandingDirections() const;
00056 void constraintsEvent(Plasma::Constraints constraints);
00057 void popupEvent(bool show);
00058 void showBatteryLabel(bool show);
00059
00060 public slots:
00061 void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
00062
00063 protected Q_SLOTS:
00064 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00065 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00066 void configAccepted();
00067 void readColors();
00068
00069 protected:
00070 void createConfigurationInterface(KConfigDialog *parent);
00071 void setEmbedded(const bool embedded);
00072
00073 private slots:
00074 void animationUpdate(qreal progress);
00075 void acAnimationUpdate(qreal progress);
00076 void batteryAnimationUpdate(qreal progress);
00077 void sourceAdded(const QString &source);
00078 void sourceRemoved(const QString &source);
00079 void brightnessChanged(const int brightness);
00080 void updateSlider(const float brightness);
00081 void setFullBrightness();
00082 void openConfig();
00083 void setProfile(const QString &profile);
00084 void suspend();
00085 void hibernate();
00086
00087 private:
00088 void connectSources();
00089 void disconnectSources();
00090 void initBatteryExtender(Plasma::ExtenderItem *item);
00091 void updateStatus();
00092
00093
00094 bool m_isEmbedded;
00095 Battery *m_extenderApplet;
00096 bool m_extenderVisible;
00097
00098 QGraphicsGridLayout *m_controlsLayout;
00099 QGraphicsGridLayout *m_batteryLayout;
00100 Plasma::Label *m_statusLabel;
00101 Plasma::Label *m_batteryLabel;
00102 Plasma::Label *m_profileLabel;
00103 Plasma::ComboBox *m_profileCombo;
00104 Plasma::Slider *m_brightnessSlider;
00105 int m_inhibitCookie;
00106
00107
00108 void paintBattery(QPainter *p, const QRect &contentsRect, const int batteryPercent, const bool plugState);
00109
00110 void paintLabel(QPainter *p, const QRect &contentsRect, const QString& labelText);
00111
00112 void showBattery(bool show);
00113
00114 void showAcAdapter(bool show);
00115
00116 void showLabel(bool show);
00117
00118 QRectF scaleRectF(qreal progress, QRectF rect);
00119
00120 bool m_showMultipleBatteries;
00121
00122 bool m_showBatteryString;
00123 QSizeF m_size;
00124 int m_pixelSize;
00125 Plasma::Svg* m_theme;
00126
00127 QStringList m_availableProfiles;
00128 QString m_currentProfile;
00129 QStringList m_suspendMethods;
00130
00131
00132 Ui::batteryConfig ui;
00133
00134 int m_animId;
00135 qreal m_alpha;
00136 bool m_fadeIn;
00137
00138 int m_acAnimId;
00139 qreal m_acAlpha;
00140 bool m_acFadeIn;
00141
00142 int m_batteryAnimId;
00143 qreal m_batteryAlpha;
00144 bool m_batteryFadeIn;
00145
00146
00147 QList<QVariant> batterylist, acadapterlist;
00148 QHash<QString, QHash<QString, QVariant> > m_batteries_data;
00149 QFont m_font;
00150 bool m_isHovered;
00151 bool m_firstRun;
00152 QColor m_boxColor;
00153 QColor m_textColor;
00154 QRectF m_textRect;
00155 int m_boxAlpha;
00156 int m_boxHoverAlpha;
00157 int m_numOfBattery;
00158 bool m_acadapter_plugged;
00159 int m_remainingMSecs;
00160 };
00161
00162 K_EXPORT_PLASMA_APPLET(battery, Battery)
00163
00164 #endif