• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Applets

battery.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007-2008 by Sebastian Kuegler <sebas@kde.org>          *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program; if not, write to the                         *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
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             // Keep the order of styles the same order as the items in the configdialog!
00075             OxygenBattery, ClassicBattery
00076         };
00077         void connectSources();
00078         void disconnectSources();
00079         int m_batteryStyle;
00080         /* Paint battery with proper charge level */
00081         void paintBattery(QPainter *p, const QRect &contentsRect, const int batteryPercent, const bool plugState);
00082         /* Paint a label on top of the battery */
00083         void paintLabel(QPainter *p, const QRect &contentsRect, const QString& labelText);
00084         /* Fade in/out the label above the battery. */
00085         void showLabel(bool show);
00086         /* Scale in/out Battery. */
00087         void showBattery(bool show);
00088         /* Scale in/out Ac Adapter. */
00089         void showAcAdapter(bool show);
00090         /* Scale in a QRectF */
00091         QRectF scaleRectF(qreal progress, QRectF rect);
00092         /* Show multiple batteries with individual icons and charge info? */
00093         bool m_showMultipleBatteries;
00094         /* Should the battery charge information be shown on top? */
00095         bool m_showBatteryString;
00096         QSizeF m_size;
00097         int m_pixelSize;
00098         Plasma::Svg* m_theme;
00099         bool m_acadapter_plugged;
00100 
00101         // Configuration dialog
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         // Internal data
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

Applets

Skip menu "Applets"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal