1 //===========================================
2 //  Lumina-DE source code
3 //  Copyright (c) 2014, Susanne Jaeckel
4 //  Available under the 3-clause BSD license
5 //  See the LICENSE file for full details
6 //===========================================
7 #ifndef _LUMINA_DESKTOP_BATTERY_H
8 #define _LUMINA_DESKTOP_BATTERY_H
9 
10 #include <QTimer>
11 #include <QWidget>
12 #include <QString>
13 #include <QLabel>
14 
15 #include <LUtils.h>
16 #include <LuminaXDG.h>
17 #include <LuminaOS.h>
18 
19 #include "../../Globals.h"
20 //#include "../LTBWidget.h"
21 #include "../LPPlugin.h"
22 
23 class LBattery : public LPPlugin{
24 	Q_OBJECT
25 public:
26 	LBattery(QWidget *parent = 0, QString id = "battery", bool horizontal=true);
27 	~LBattery();
28 
29 private:
30 	QTimer *timer;
31 	QLabel *label;
32 	QString iconOld;
33 	QSettings *sessionsettings;
34 
35 private slots:
36 	void updateBattery(bool force = false);
37 	QString getRemainingTime();
38 
39 public slots:
LocaleChange()40 	void LocaleChange(){
41 	  updateBattery(true);
42 	}
43 
OrientationChange()44 	void OrientationChange(){
45 	  if(this->layout()->direction()==QBoxLayout::LeftToRight){
46 	    label->setFixedSize( QSize(this->height(), this->height()) );
47 	  }else{
48 	    label->setFixedSize( QSize(this->width(), this->width()) );
49 	  }
50 	  updateBattery(true); //force icon refresh
51 	}
52 protected:
changeEvent(QEvent * ev)53 	void changeEvent(QEvent *ev){
54 	  LPPlugin::changeEvent(ev);
55 	  QEvent::Type tmp = ev->type();
56 	  if(tmp==QEvent::ThemeChange || tmp==QEvent::LanguageChange || tmp==QEvent::LocaleChange){
57 	    updateBattery(true);
58 	  }
59 	}
60 
61 };
62 
63 #endif
64