summaryrefslogtreecommitdiff
path: root/core/applets/batteryapplet/battery.cpp
Unidiff
Diffstat (limited to 'core/applets/batteryapplet/battery.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 3b329c6..f3a95ed 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -12,48 +12,49 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "battery.h" 20#include "battery.h"
21#include "batterystatus.h" 21#include "batterystatus.h"
22 22
23#include <qpe/power.h> 23#include <qpe/power.h>
24#include <qpe/applnk.h>
24 25
25#include <qpainter.h> 26#include <qpainter.h>
26#include <qtimer.h> 27#include <qtimer.h>
27 28
28 29
29BatteryMeter::BatteryMeter( QWidget *parent ) 30BatteryMeter::BatteryMeter( QWidget *parent )
30 : QWidget( parent ), charging(false) 31 : QWidget( parent ), charging(false)
31{ 32{
32 ps = new PowerStatus; 33 ps = new PowerStatus;
33 startTimer( 10000 ); 34 startTimer( 10000 );
34 setFixedHeight(12); 35 setFixedHeight( AppLnk::smallIconSize() );
35 chargeTimer = new QTimer( this ); 36 chargeTimer = new QTimer( this );
36 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); 37 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) );
37 timerEvent(0); 38 timerEvent(0);
38} 39}
39 40
40BatteryMeter::~BatteryMeter() 41BatteryMeter::~BatteryMeter()
41{ 42{
42 delete ps; 43 delete ps;
43} 44}
44 45
45QSize BatteryMeter::sizeHint() const 46QSize BatteryMeter::sizeHint() const
46{ 47{
47 return QSize(10,12); 48 return QSize(10, height() );
48} 49}
49 50
50void BatteryMeter::mouseReleaseEvent( QMouseEvent *) 51void BatteryMeter::mouseReleaseEvent( QMouseEvent *)
51{ 52{
52 if ( batteryView && batteryView->isVisible() ) { 53 if ( batteryView && batteryView->isVisible() ) {
53 delete (QWidget *) batteryView; 54 delete (QWidget *) batteryView;
54 } else { 55 } else {
55 if ( !batteryView ) 56 if ( !batteryView )
56 batteryView = new BatteryStatus( ps ); 57 batteryView = new BatteryStatus( ps );
57 batteryView->showMaximized(); 58 batteryView->showMaximized();
58 batteryView->raise(); 59 batteryView->raise();
59 batteryView->show(); 60 batteryView->show();
@@ -107,26 +108,26 @@ void BatteryMeter::paintEvent( QPaintEvent* )
107 darkc = c.dark(120); 108 darkc = c.dark(120);
108 lightc = c.light(140); 109 lightc = c.light(140);
109 } else if ( ps->acStatus() == PowerStatus::Online ) { 110 } else if ( ps->acStatus() == PowerStatus::Online ) {
110 c = green.dark(130); 111 c = green.dark(130);
111 darkc = c.dark(120); 112 darkc = c.dark(120);
112 lightc = c.light(180); 113 lightc = c.light(180);
113 } else { 114 } else {
114 c = red; 115 c = red;
115 darkc = c.dark(120); 116 darkc = c.dark(120);
116 lightc = c.light(160); 117 lightc = c.light(160);
117 } 118 }
118 119
119 int w = 6; 120 int w = height() / 2 ;
120 int h = height()-3; 121 int h = height() - 4;
121 int pix = (percent * h) / 100; 122 int pix = (percent * h) / 100;
122 int y2 = height() - 2; 123 int y2 = height() - 2;
123 int y = y2 - pix; 124 int y = y2 - pix;
124 int x1 = (width() - w) / 2; 125 int x1 = (width() - w) / 2;
125 126
126 p.setPen(QColor(80,80,80)); 127 p.setPen(QColor(80,80,80));
127 p.drawLine(x1+w/4,0,x1+w/4+w/2,0); 128 p.drawLine(x1+w/4,0,x1+w/4+w/2,0);
128 p.drawRect(x1,1,w,height()-1); 129 p.drawRect(x1,1,w,height()-1);
129 p.setBrush(c); 130 p.setBrush(c);
130 131
131 int extra = ((percent * h) % 100)/(100/4); 132 int extra = ((percent * h) % 100)/(100/4);
132 133