summaryrefslogtreecommitdiff
path: root/core/applets/batteryapplet/battery.cpp
Unidiff
Diffstat (limited to 'core/applets/batteryapplet/battery.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 9a9ddf6..fed9b34 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -1,51 +1,54 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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/* OPIE */
24#include <opie2/otaskbarapplet.h>
23#include <qpe/applnk.h> 25#include <qpe/applnk.h>
24#include <qpe/config.h> 26#include <qpe/config.h>
25#include <qpe/power.h> 27#include <qpe/power.h>
26#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
27 29
30/* QT */
28#include <qpainter.h> 31#include <qpainter.h>
29#include <qtimer.h> 32#include <qtimer.h>
30 33
31 34
32BatteryMeter::BatteryMeter( QWidget *parent ) 35BatteryMeter::BatteryMeter( QWidget *parent )
33 : QWidget( parent ), charging(false) 36 : QWidget( parent ), charging(false)
34{ 37{
35 ps = new PowerStatus; 38 ps = new PowerStatus;
36 startTimer( 10000 ); 39 startTimer( 10000 );
37 40
38 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); 41 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) );
39 setFixedHeight( AppLnk::smallIconSize() ); 42 setFixedHeight( AppLnk::smallIconSize() );
40 43
41 chargeTimer = new QTimer( this ); 44 chargeTimer = new QTimer( this );
42 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); 45 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) );
43 timerEvent(0); 46 timerEvent(0);
44 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 47 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
45 Config c( "qpe" ); 48 Config c( "qpe" );
46 c.setGroup( "Battery" ); 49 c.setGroup( "Battery" );
47 style = c.readNumEntry( "Style", 0 ); 50 style = c.readNumEntry( "Style", 0 );
48} 51}
49 52
50BatteryMeter::~BatteryMeter() 53BatteryMeter::~BatteryMeter()
51{ 54{
@@ -147,24 +150,34 @@ void BatteryMeter::paintEvent( QPaintEvent* )
147 int pix = (percent * h) / 100; 150 int pix = (percent * h) / 100;
148 int y2 = height() -2; 151 int y2 = height() -2;
149 int y = y2 - pix; 152 int y = y2 - pix;
150 int x1 = (width() - w ) / 2; 153 int x1 = (width() - w ) / 2;
151 154
152 p.setPen(QColor(80,80,80)); 155 p.setPen(QColor(80,80,80));
153 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header 156 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header
154 p.drawRect(x1,1,w,height()-1); // corpus 157 p.drawRect(x1,1,w,height()-1); // corpus
155 p.setBrush(color); 158 p.setBrush(color);
156 159
157 //int extra = ((percent * h) % 100)/(100/4); 160 //int extra = ((percent * h) % 100)/(100/4);
158 161
159 int middle = w/2; 162 int middle = w/2;
160 for ( int i = 0; i < middle; i++ ) 163 for ( int i = 0; i < middle; i++ )
161 { 164 {
162 p.setPen( gray.dark( 100+i*20 ) ); 165 p.setPen( gray.dark( 100+i*20 ) );
163 p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); 166 p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 );
164 p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); 167 p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 );
165 p.setPen( color.dark( 100+i*20 ) ); 168 p.setPen( color.dark( 100+i*20 ) );
166 p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); 169 p.drawLine( x1+middle-i, y, x1+middle-i, y2 );
167 p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); 170 p.drawLine( x1+middle+i, y, x1+middle+i, y2 );
168 } 171 }
169} 172}
170 173
174int BatteryMeter::position()
175{
176 return 8;
177}
178
179Q_EXPORT_INTERFACE()
180{
181 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<BatteryMeter> );
182}
183