summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp1
-rw-r--r--core/applets/batteryapplet/batterystatus.cpp17
-rw-r--r--core/applets/batteryapplet/batterystatus.h2
3 files changed, 13 insertions, 7 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 0d3d190..e85a9da 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -1,177 +1,178 @@
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 */ 23/* OPIE */
24#include <opie2/otaskbarapplet.h> 24#include <opie2/otaskbarapplet.h>
25 25
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/power.h> 29#include <qpe/power.h>
30 30
31/* QT */ 31/* QT */
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qtimer.h> 33#include <qtimer.h>
34 34
35 35
36using namespace Opie::Ui; 36using namespace Opie::Ui;
37BatteryMeter::BatteryMeter( QWidget *parent ) 37BatteryMeter::BatteryMeter( QWidget *parent )
38: QWidget( parent ), charging(false) { 38: QWidget( parent ), charging(false) {
39 ps = new PowerStatus; 39 ps = new PowerStatus;
40 startTimer( 10000 ); 40 startTimer( 10000 );
41 41
42 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); 42 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) );
43 setFixedHeight( AppLnk::smallIconSize() ); 43 setFixedHeight( AppLnk::smallIconSize() );
44 44
45 chargeTimer = new QTimer( this ); 45 chargeTimer = new QTimer( this );
46 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); 46 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) );
47 timerEvent(0); 47 timerEvent(0);
48 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 48 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
49 Config c( "qpe" ); 49 Config c( "qpe" );
50 c.setGroup( "Battery" ); 50 c.setGroup( "Battery" );
51 style = c.readNumEntry( "Style", 0 ); 51 style = c.readNumEntry( "Style", 0 );
52} 52}
53 53
54BatteryMeter::~BatteryMeter() { 54BatteryMeter::~BatteryMeter() {
55 delete ps; 55 delete ps;
56} 56}
57 57
58QSize BatteryMeter::sizeHint() const { 58QSize BatteryMeter::sizeHint() const {
59 return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); 59 return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() );
60} 60}
61 61
62void BatteryMeter::mousePressEvent( QMouseEvent* e ) { 62void BatteryMeter::mousePressEvent( QMouseEvent* e ) {
63 if ( e->button() == RightButton ) { 63 if ( e->button() == RightButton ) {
64 style = 1-style; 64 style = 1-style;
65 Config c( "qpe" ); 65 Config c( "qpe" );
66 c.setGroup( "Battery" ); 66 c.setGroup( "Battery" );
67 c.writeEntry( "Style", style ); 67 c.writeEntry( "Style", style );
68 repaint( true ); 68 repaint( true );
69 } 69 }
70 QWidget::mousePressEvent( e ); 70 QWidget::mousePressEvent( e );
71} 71}
72 72
73void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) { 73void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) {
74 if ( batteryView && batteryView->isVisible() ) { 74 if ( batteryView && batteryView->isVisible() ) {
75 batteryView->hide(); 75 batteryView->hide();
76 } else { 76 } else {
77 if ( !batteryView ) { 77 if ( !batteryView ) {
78 batteryView = new BatteryStatus( ps, 0, WStyle_StaysOnTop | WType_Popup ); 78 batteryView = new BatteryStatus( ps, 0, WStyle_StaysOnTop | WType_Popup );
79 batteryView->setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 79 batteryView->setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
80 } 80 }
81 81
82 batteryView->UpdateBatteryStatus();
82 QRect r(batteryView->pos(),batteryView->sizeHint()); 83 QRect r(batteryView->pos(),batteryView->sizeHint());
83 QPoint curPos = this->mapToGlobal ( rect().topLeft() ); 84 QPoint curPos = this->mapToGlobal ( rect().topLeft() );
84 85
85 int lp = qApp->desktop()->width() - batteryView->sizeHint().width(); 86 int lp = qApp->desktop()->width() - batteryView->sizeHint().width();
86 r.moveTopLeft( QPoint(lp, curPos.y()-batteryView->sizeHint().height()-1) ); 87 r.moveTopLeft( QPoint(lp, curPos.y()-batteryView->sizeHint().height()-1) );
87 batteryView->setGeometry(r); 88 batteryView->setGeometry(r);
88 89
89 batteryView->raise(); 90 batteryView->raise();
90 batteryView->show(); 91 batteryView->show();
91 } 92 }
92} 93}
93 94
94 95
95void BatteryMeter::timerEvent( QTimerEvent * ) { 96void BatteryMeter::timerEvent( QTimerEvent * ) {
96 PowerStatus prev = *ps; 97 PowerStatus prev = *ps;
97 98
98 *ps = PowerStatusManager::readStatus(); 99 *ps = PowerStatusManager::readStatus();
99 100
100 if ( prev != *ps ) { 101 if ( prev != *ps ) {
101 percent = ps->batteryPercentRemaining(); 102 percent = ps->batteryPercentRemaining();
102 if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { 103 if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) {
103 percent = 0; 104 percent = 0;
104 charging = true; 105 charging = true;
105 chargeTimer->start( 500 ); 106 chargeTimer->start( 500 );
106 } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { 107 } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) {
107 charging = false; 108 charging = false;
108 chargeTimer->stop(); 109 chargeTimer->stop();
109 if ( batteryView ) 110 if ( batteryView )
110 batteryView->updatePercent( percent ); 111 batteryView->updatePercent( percent );
111 } 112 }
112 repaint( style != 0 ); 113 repaint( style != 0 );
113 if ( batteryView ) 114 if ( batteryView )
114 batteryView->repaint(); 115 batteryView->repaint();
115 } 116 }
116} 117}
117 118
118void BatteryMeter::chargeTimeout() { 119void BatteryMeter::chargeTimeout() {
119 percent += 20; 120 percent += 20;
120 if ( percent > 100 ) 121 if ( percent > 100 )
121 percent = 0; 122 percent = 0;
122 123
123 repaint(FALSE); 124 repaint(FALSE);
124 if ( batteryView ) 125 if ( batteryView )
125 batteryView->updatePercent( percent ); 126 batteryView->updatePercent( percent );
126} 127}
127 128
128void BatteryMeter::paintEvent( QPaintEvent* ) { 129void BatteryMeter::paintEvent( QPaintEvent* ) {
129 130
130 if ( style == 1 ) { 131 if ( style == 1 ) {
131 QPainter p(this); 132 QPainter p(this);
132 QFont f( "Fixed", AppLnk::smallIconSize()/2 ); 133 QFont f( "Fixed", AppLnk::smallIconSize()/2 );
133 QFontMetrics fm( f ); 134 QFontMetrics fm( f );
134 p.setFont( f ); 135 p.setFont( f );
135 p.drawText( 0, height()/2, QString::number( percent ) ); 136 p.drawText( 0, height()/2, QString::number( percent ) );
136 p.drawText( width()/4, height(), "%" ); 137 p.drawText( width()/4, height(), "%" );
137 return; 138 return;
138 } 139 }
139 140
140 QPainter p(this); 141 QPainter p(this);
141 QColor color; 142 QColor color;
142 QColor g = gray.light( 160 ); 143 QColor g = gray.light( 160 );
143 switch ( ps->acStatus() ) { 144 switch ( ps->acStatus() ) {
144 case PowerStatus::Offline: 145 case PowerStatus::Offline:
145 color = blue.light( 150 ); 146 color = blue.light( 150 );
146 break; 147 break;
147 case PowerStatus::Online: 148 case PowerStatus::Online:
148 color = green.dark( 130 ).light( 180 ); 149 color = green.dark( 130 ).light( 180 );
149 break; 150 break;
150 default: 151 default:
151 color = red.light( 160 ); 152 color = red.light( 160 );
152 } 153 }
153 154
154 int w = height() / 2; 155 int w = height() / 2;
155 if ( !(w%2) ) 156 if ( !(w%2) )
156 w--; // should have an odd value to get a real middle line 157 w--; // should have an odd value to get a real middle line
157 int h = height() - 4; 158 int h = height() - 4;
158 int pix = (percent * h) / 100; 159 int pix = (percent * h) / 100;
159 int y2 = height() -2; 160 int y2 = height() -2;
160 int y = y2 - pix; 161 int y = y2 - pix;
161 int x1 = (width() - w ) / 2; 162 int x1 = (width() - w ) / 2;
162 163
163 p.setPen(QColor(80,80,80)); 164 p.setPen(QColor(80,80,80));
164 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header 165 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header
165 p.drawRect(x1,1,w,height()-1); // corpus 166 p.drawRect(x1,1,w,height()-1); // corpus
166 p.setBrush(color); 167 p.setBrush(color);
167 168
168 //int extra = ((percent * h) % 100)/(100/4); 169 //int extra = ((percent * h) % 100)/(100/4);
169 170
170 int middle = w/2; 171 int middle = w/2;
171 for ( int i = 0; i < middle; i++ ) { 172 for ( int i = 0; i < middle; i++ ) {
172 p.setPen( gray.dark( 100+i*20 ) ); 173 p.setPen( gray.dark( 100+i*20 ) );
173 p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); 174 p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 );
174 p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); 175 p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 );
175 p.setPen( color.dark( 100+i*20 ) ); 176 p.setPen( color.dark( 100+i*20 ) );
176 p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); 177 p.drawLine( x1+middle-i, y, x1+middle-i, y2 );
177 p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); 178 p.drawLine( x1+middle+i, y, x1+middle+i, y2 );
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp
index 5a24b94..860db64 100644
--- a/core/applets/batteryapplet/batterystatus.cpp
+++ b/core/applets/batteryapplet/batterystatus.cpp
@@ -1,125 +1,130 @@
1 1
2#include "batterystatus.h" 2#include "batterystatus.h"
3 3
4/* OPIE */ 4/* OPIE */
5#include <opie2/odevice.h> 5#include <opie2/odevice.h>
6#include <qpe/power.h> 6#include <qpe/power.h>
7 7
8/* QT */ 8/* QT */
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qdrawutil.h> 10#include <qdrawutil.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qtextstream.h> 12#include <qtextstream.h>
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15using namespace Opie::Core; 15using namespace Opie::Core;
16 16
17BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f ) 17BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f )
18: QFrame( parent, 0, f), ps(p), bat2(false) { 18: QFrame( parent, 0, f), ps(p), bat2(false) {
19 19
20 jackPercent = 0; 20 UpdateBatteryStatus();
21
22 if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
23 getProcApmStatusIpaq();
24 }
25 percent = ps->batteryPercentRemaining();
26} 21}
27 22
28BatteryStatus::~BatteryStatus() {} 23BatteryStatus::~BatteryStatus() {}
29 24
25void BatteryStatus::UpdateBatteryStatus() {
26
27 jackPercent = 0;
28
29 if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
30 getProcApmStatusIpaq();
31 }
32 percent = ps->batteryPercentRemaining();
33}
34
30/* 35/*
31 * Make use of the advanced apm interface of the ipaq 36 * Make use of the advanced apm interface of the ipaq
32 */ 37 */
33bool BatteryStatus::getProcApmStatusIpaq() { 38bool BatteryStatus::getProcApmStatusIpaq() {
34 39
35 bat2 = false; 40 bat2 = false;
36 41
37 QFile procApmIpaq("/proc/hal/battery"); 42 QFile procApmIpaq("/proc/hal/battery");
38 43
39 if (procApmIpaq.open(IO_ReadOnly) ) { 44 if (procApmIpaq.open(IO_ReadOnly) ) {
40 QStringList list; 45 QStringList list;
41 // since it is /proc we _must_ use QTextStream 46 // since it is /proc we _must_ use QTextStream
42 QTextStream stream ( &procApmIpaq); 47 QTextStream stream ( &procApmIpaq);
43 QString streamIn; 48 QString streamIn;
44 streamIn = stream.read(); 49 streamIn = stream.read();
45 list = QStringList::split("\n", streamIn); 50 list = QStringList::split("\n", streamIn);
46 51
47 for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { 52 for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
48 // not nice, need a rewrite later 53 // not nice, need a rewrite later
49 if( (*line).startsWith(" Percentage") ) { 54 if( (*line).startsWith(" Percentage") ) {
50 if (bat2 == true) { 55 if (bat2 == true) {
51 perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2); 56 perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2);
52 } else { 57 } else {
53 perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); 58 perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2);
54 } 59 }
55 } else if( (*line).startsWith(" Life") ) { 60 } else if( (*line).startsWith(" Life") ) {
56 if (bat2 == true) { 61 if (bat2 == true) {
57 sec2 = (*line).mid(((*line).find(':')+2), 5 ); 62 sec2 = (*line).mid(((*line).find(':')+2), 5 );
58 } else { 63 } else {
59 sec1 = (*line).mid(((*line).find(':')+2), 5 ); 64 sec1 = (*line).mid(((*line).find(':')+2), 5 );
60 } 65 }
61 } else if( (*line).startsWith("Battery #1") ) { 66 } else if( (*line).startsWith("Battery #1") ) {
62 bat2 = true; 67 bat2 = true;
63 } else if( (*line).startsWith(" Status") ) { 68 } else if( (*line).startsWith(" Status") ) {
64 if (bat2 == true) { 69 if (bat2 == true) {
65 jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); 70 jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
66 } else { 71 } else {
67 ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); 72 ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
68 } 73 }
69 } else if( (*line).startsWith(" Chemistry") ) { 74 } else if( (*line).startsWith(" Chemistry") ) {
70 if (bat2 == true) { 75 if (bat2 == true) {
71 jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); 76 jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);
72 } else { 77 } else {
73 ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); 78 ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);
74 } 79 }
75 } 80 }
76 } 81 }
77 } else { 82 } else {
78 QMessageBox::warning(this, tr("Failure"),tr("could not open file")); 83 QMessageBox::warning(this, tr("Failure"),tr("could not open file"));
79 } 84 }
80 85
81 procApmIpaq.close(); 86 procApmIpaq.close();
82 jackPercent = perc2.toInt(); 87 jackPercent = perc2.toInt();
83 ipaqPercent = perc1.toInt(); 88 ipaqPercent = perc1.toInt();
84 89
85 if (perc2.isEmpty()) { 90 if (perc2.isEmpty()) {
86 perc2 = tr("no data"); 91 perc2 = tr("no data");
87 } else { 92 } else {
88 perc2 += " %"; 93 perc2 += " %";
89 } 94 }
90 95
91 if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { 96 if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) {
92 sec2 = tr("no data"); 97 sec2 = tr("no data");
93 } else { 98 } else {
94 sec2 += " min"; 99 sec2 += " min";
95 } 100 }
96 101
97 jackStatus == (" ( " + jackStatus + " )"); 102 jackStatus == (" ( " + jackStatus + " )");
98 return true; 103 return true;
99} 104}
100 105
101 106
102void BatteryStatus::updatePercent( int pc ) { 107void BatteryStatus::updatePercent( int pc ) {
103 percent = pc; 108 percent = pc;
104 repaint(FALSE); 109 repaint(FALSE);
105} 110}
106 111
107void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { 112void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) {
108 int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; 113 int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height;
109 topgrad.hsv( &h1, &s1, &v1 ); 114 topgrad.hsv( &h1, &s1, &v1 );
110 botgrad.hsv( &h2, &s2, &v2 ); 115 botgrad.hsv( &h2, &s2, &v2 );
111 for ( int j = 0; j < hy-2; j++ ) { 116 for ( int j = 0; j < hy-2; j++ ) {
112 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), 117 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
113 v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); 118 v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
114 p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); 119 p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j );
115 } 120 }
116 for ( int j = 0; j < hh; j++ ) { 121 for ( int j = 0; j < hh; j++ ) {
117 p->setPen( highlight ); 122 p->setPen( highlight );
118 p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); 123 p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j );
119 } 124 }
120 for ( int j = 0; j < ng-hy-hh; j++ ) { 125 for ( int j = 0; j < ng-hy-hh; j++ ) {
121 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), 126 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
122 v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); 127 v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
123 p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); 128 p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j );
124 } 129 }
125} 130}
diff --git a/core/applets/batteryapplet/batterystatus.h b/core/applets/batteryapplet/batterystatus.h
index bb95ece..4da446d 100644
--- a/core/applets/batteryapplet/batterystatus.h
+++ b/core/applets/batteryapplet/batterystatus.h
@@ -1,64 +1,64 @@
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#ifndef BATTERY_STATUS_H 20#ifndef BATTERY_STATUS_H
21#define BATTERY_STATUS_H 21#define BATTERY_STATUS_H
22 22
23#include <qframe.h> 23#include <qframe.h>
24 24
25class PowerStatus; 25class PowerStatus;
26 26
27class BatteryStatus : public QFrame 27class BatteryStatus : public QFrame
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 BatteryStatus( const PowerStatus *s, QWidget *parent=0, WFlags f = 0 ); 31 BatteryStatus( const PowerStatus *s, QWidget *parent=0, WFlags f = 0 );
32 ~BatteryStatus(); 32 ~BatteryStatus();
33 33 void BatteryStatus::UpdateBatteryStatus();
34 void updatePercent( int ); 34 void updatePercent( int );
35 QSize sizeHint() const; 35 QSize sizeHint() const;
36protected: 36protected:
37 void drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ); 37 void drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height );
38 void paintEvent( QPaintEvent *pe ); 38 void paintEvent( QPaintEvent *pe );
39 bool BatteryStatus::getProcApmStatusIpaq(); 39 bool BatteryStatus::getProcApmStatusIpaq();
40 40
41private: 41private:
42 QString statusText() const; 42 QString statusText() const;
43 QString statusTextIpaq() const; 43 QString statusTextIpaq() const;
44 const PowerStatus *ps; 44 const PowerStatus *ps;
45 int percent; 45 int percent;
46 int ipaqPercent; 46 int ipaqPercent;
47 int jackPercent; 47 int jackPercent;
48 int jackMinutes; 48 int jackMinutes;
49 QString perc1; 49 QString perc1;
50 QString sec1; 50 QString sec1;
51 QString perc2; 51 QString perc2;
52 QString sec2; 52 QString sec2;
53 QString ipaqStatus; 53 QString ipaqStatus;
54 QString jackStatus; 54 QString jackStatus;
55 QString ipaqChem; 55 QString ipaqChem;
56 QString jackChem; 56 QString jackChem;
57 bool bat2; 57 bool bat2;
58 bool bat2inserted; 58 bool bat2inserted;
59 int screenWidth; 59 int screenWidth;
60 int screenHeight; 60 int screenHeight;
61}; 61};
62 62
63#endif 63#endif
64 64