author | harlekin <harlekin> | 2003-04-11 08:06:37 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-04-11 08:06:37 (UTC) |
commit | 0cce344730fbdcc131254bf04a2d40f665e1bd86 (patch) (unidiff) | |
tree | 784328c71110744d0e75dd5c67d9240124460421 | |
parent | 59294dc9a8edd412745e406f35d5564a9a3b3ffa (diff) | |
download | opie-0cce344730fbdcc131254bf04a2d40f665e1bd86.zip opie-0cce344730fbdcc131254bf04a2d40f665e1bd86.tar.gz opie-0cce344730fbdcc131254bf04a2d40f665e1bd86.tar.bz2 |
adapt better to variable screen sizes
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 43 | ||||
-rw-r--r-- | core/applets/batteryapplet/batterystatus.h | 2 |
2 files changed, 33 insertions, 12 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index 7d3bdd9..fdd963c 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -1,236 +1,255 @@ | |||
1 | 1 | ||
2 | #include "batterystatus.h" | 2 | #include "batterystatus.h" |
3 | 3 | ||
4 | #include <qpe/power.h> | 4 | #include <qpe/power.h> |
5 | 5 | ||
6 | #include <opie/odevice.h> | 6 | #include <opie/odevice.h> |
7 | 7 | ||
8 | #include <qpainter.h> | 8 | #include <qpainter.h> |
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 <qlayout.h> | ||
12 | #include <qtextstream.h> | 13 | #include <qtextstream.h> |
14 | #include <qapplication.h> | ||
13 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
14 | 16 | ||
15 | using namespace Opie; | 17 | using namespace Opie; |
16 | 18 | ||
17 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | 19 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) |
18 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { | 20 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { |
19 | setCaption( tr("Battery status") ); | 21 | setCaption( tr("Battery status") ); |
20 | QPushButton *pb = new QPushButton( tr("Close"), this ); | 22 | QPushButton *pb = new QPushButton( tr("Close"), this ); |
21 | pb->move( 70, 250 ); | 23 | QVBoxLayout *layout = new QVBoxLayout ( this ); |
22 | pb->setMaximumHeight(20); | 24 | |
25 | jackPercent = 0; | ||
26 | |||
27 | pb->setMaximumHeight(40); | ||
28 | pb->setMaximumWidth( 120 ); | ||
29 | |||
23 | pb->show(); | 30 | pb->show(); |
31 | |||
32 | layout->addStretch( 0 ); | ||
33 | layout->addWidget( pb ); | ||
34 | |||
24 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 35 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
25 | getProcApmStatusIpaq(); | 36 | getProcApmStatusIpaq(); |
26 | } | 37 | } |
27 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); | 38 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); |
28 | percent = ps->batteryPercentRemaining(); | 39 | percent = ps->batteryPercentRemaining(); |
29 | show(); | 40 | show(); |
30 | } | 41 | } |
31 | 42 | ||
32 | BatteryStatus::~BatteryStatus() | 43 | BatteryStatus::~BatteryStatus() |
33 | { | 44 | { |
34 | } | 45 | } |
35 | 46 | ||
36 | /* | 47 | /* |
37 | * Make use of the advanced apm interface of the ipaq | 48 | * Make use of the advanced apm interface of the ipaq |
38 | */ | 49 | */ |
39 | bool BatteryStatus::getProcApmStatusIpaq() { | 50 | bool BatteryStatus::getProcApmStatusIpaq() { |
40 | 51 | ||
41 | bat2 = false; | 52 | bat2 = false; |
42 | 53 | ||
43 | QFile procApmIpaq("/proc/hal/battery"); | 54 | QFile procApmIpaq("/proc/hal/battery"); |
44 | 55 | ||
45 | if (procApmIpaq.open(IO_ReadOnly) ) { | 56 | if (procApmIpaq.open(IO_ReadOnly) ) { |
46 | QStringList list; | 57 | QStringList list; |
47 | // since it is /proc we _must_ use QTextStream | 58 | // since it is /proc we _must_ use QTextStream |
48 | QTextStream stream ( &procApmIpaq); | 59 | QTextStream stream ( &procApmIpaq); |
49 | QString streamIn; | 60 | QString streamIn; |
50 | streamIn = stream.read(); | 61 | streamIn = stream.read(); |
51 | list = QStringList::split("\n", streamIn); | 62 | list = QStringList::split("\n", streamIn); |
52 | 63 | ||
53 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 64 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
54 | // not nice, need a rewrite later | 65 | // not nice, need a rewrite later |
55 | if( (*line).startsWith(" Percentage") ){ | 66 | if( (*line).startsWith(" Percentage") ){ |
56 | if (bat2 == true) { | 67 | if (bat2 == true) { |
57 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 68 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
58 | } else { | 69 | } else { |
59 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 70 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
60 | } | 71 | } |
61 | }else if( (*line).startsWith(" Life") ){ | 72 | }else if( (*line).startsWith(" Life") ){ |
62 | if (bat2 == true) { | 73 | if (bat2 == true) { |
63 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); | 74 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); |
64 | } else { | 75 | } else { |
65 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); | 76 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); |
66 | } | 77 | } |
67 | }else if( (*line).startsWith("Battery #1") ){ | 78 | }else if( (*line).startsWith("Battery #1") ){ |
68 | bat2 = true; | 79 | bat2 = true; |
69 | }else if( (*line).startsWith(" Status") ){ | 80 | }else if( (*line).startsWith(" Status") ){ |
70 | if (bat2 == true) { | 81 | if (bat2 == true) { |
71 | jackStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); | 82 | jackStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); |
72 | } else { | 83 | } else { |
73 | ipaqStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); | 84 | ipaqStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); |
74 | } | 85 | } |
75 | }else if( (*line).startsWith(" Chemistry") ) { | 86 | }else if( (*line).startsWith(" Chemistry") ) { |
76 | if (bat2 == true) { | 87 | if (bat2 == true) { |
77 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 88 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
78 | } else { | 89 | } else { |
79 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 90 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
80 | } | 91 | } |
81 | } | 92 | } |
82 | } | 93 | } |
83 | } else { | 94 | } else { |
84 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); | 95 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); |
85 | } | 96 | } |
86 | 97 | ||
87 | procApmIpaq.close(); | 98 | procApmIpaq.close(); |
88 | 99 | ||
89 | jackPercent = perc2.toInt(); | 100 | jackPercent = perc2.toInt(); |
90 | ipaqPercent = perc1.toInt(); | 101 | ipaqPercent = perc1.toInt(); |
91 | 102 | ||
92 | if (perc2.isEmpty()) { | 103 | if (perc2.isEmpty()) { |
93 | perc2 = "no data"; | 104 | perc2 = "no data"; |
94 | } else { | 105 | } else { |
95 | perc2 += " %"; | 106 | perc2 += " %"; |
96 | } | 107 | } |
97 | 108 | ||
98 | 109 | ||
99 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { | 110 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { |
100 | sec2 = "no data"; | 111 | sec2 = "no data"; |
101 | } else { | 112 | } else { |
102 | sec2 += " min"; | 113 | sec2 += " min"; |
103 | } | 114 | } |
104 | 115 | ||
105 | jackStatus == (" ( " + jackStatus + " )"); | 116 | jackStatus == (" ( " + jackStatus + " )"); |
106 | 117 | ||
107 | return true; | 118 | return true; |
108 | } | 119 | } |
109 | 120 | ||
110 | 121 | ||
111 | void BatteryStatus::updatePercent( int pc ) { | 122 | void BatteryStatus::updatePercent( int pc ) { |
112 | percent = pc; | 123 | percent = pc; |
113 | repaint(FALSE); | 124 | repaint(FALSE); |
114 | } | 125 | } |
115 | 126 | ||
116 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { | 127 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { |
117 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; | 128 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; |
118 | topgrad.hsv( &h1, &s1, &v1 ); | 129 | topgrad.hsv( &h1, &s1, &v1 ); |
119 | botgrad.hsv( &h2, &s2, &v2 ); | 130 | botgrad.hsv( &h2, &s2, &v2 ); |
120 | for ( int j = 0; j < hy-2; j++ ) { | 131 | for ( int j = 0; j < hy-2; j++ ) { |
121 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 132 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
122 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 133 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
123 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); | 134 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); |
124 | } | 135 | } |
125 | for ( int j = 0; j < hh; j++ ) { | 136 | for ( int j = 0; j < hh; j++ ) { |
126 | p->setPen( highlight ); | 137 | p->setPen( highlight ); |
127 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); | 138 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); |
128 | } | 139 | } |
129 | for ( int j = 0; j < ng-hy-hh; j++ ) { | 140 | for ( int j = 0; j < ng-hy-hh; j++ ) { |
130 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 141 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
131 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 142 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
132 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); | 143 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); |
133 | } | 144 | } |
134 | } | 145 | } |
135 | 146 | ||
136 | void BatteryStatus::paintEvent( QPaintEvent * ) { | 147 | void BatteryStatus::paintEvent( QPaintEvent * ) { |
137 | 148 | ||
149 | |||
150 | int screenWidth = qApp->desktop()->width(); | ||
151 | int screenHeight = qApp->desktop()->height(); | ||
152 | |||
138 | QPainter p(this); | 153 | QPainter p(this); |
139 | QString text; | 154 | QString text; |
140 | if ( ps->batteryStatus() == PowerStatus::Charging ) { | 155 | if ( ps->batteryStatus() == PowerStatus::Charging ) { |
141 | if (bat2) { | 156 | if (bat2) { |
142 | text = tr("Charging both devices"); | 157 | text = tr("Charging both devices"); |
143 | } else { | 158 | } else { |
144 | text = tr("Charging"); | 159 | text = tr("Charging"); |
145 | } | 160 | } |
146 | } else if ( ps->batteryPercentAccurate() ) { | 161 | } else if ( ps->batteryPercentAccurate() ) { |
147 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); | 162 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); |
148 | } else { | 163 | } else { |
149 | text = tr("Battery status: "); | 164 | text = tr("Battery status: "); |
150 | switch ( ps->batteryStatus() ) { | 165 | switch ( ps->batteryStatus() ) { |
151 | case PowerStatus::High: | 166 | case PowerStatus::High: |
152 | text += tr("Good"); | 167 | text += tr("Good"); |
153 | break; | 168 | break; |
154 | case PowerStatus::Low: | 169 | case PowerStatus::Low: |
155 | text += tr("Low"); | 170 | text += tr("Low"); |
156 | break; | 171 | break; |
157 | case PowerStatus::VeryLow: | 172 | case PowerStatus::VeryLow: |
158 | text += tr("Very Low"); | 173 | text += tr("Very Low"); |
159 | break; | 174 | break; |
160 | case PowerStatus::Critical: | 175 | case PowerStatus::Critical: |
161 | text += tr("Critical"); | 176 | text += tr("Critical"); |
162 | break; | 177 | break; |
163 | default: // NotPresent, etc. | 178 | default: // NotPresent, etc. |
164 | text += tr("Unknown"); | 179 | text += tr("Unknown"); |
165 | } | 180 | } |
166 | } | 181 | } |
167 | p.drawText( 10, 90, text ); | 182 | p.drawText( 10, 90, text ); |
168 | 183 | ||
169 | if ( ps->acStatus() == PowerStatus::Backup ) | 184 | if ( ps->acStatus() == PowerStatus::Backup ) |
170 | p.drawText( 10, 110, tr("On backup power") ); | 185 | p.drawText( 10, 110, tr("On backup power") ); |
171 | else if ( ps->acStatus() == PowerStatus::Online ) | 186 | else if ( ps->acStatus() == PowerStatus::Online ) |
172 | p.drawText( 10, 110, tr("Power on-line") ); | 187 | p.drawText( 10, 110, tr("Power on-line") ); |
173 | else if ( ps->acStatus() == PowerStatus::Offline ) | 188 | else if ( ps->acStatus() == PowerStatus::Offline ) |
174 | p.drawText( 10, 110, tr("External power disconnected") ); | 189 | p.drawText( 10, 110, tr("External power disconnected") ); |
175 | 190 | ||
176 | if ( ps->batteryTimeRemaining() >= 0 ) { | 191 | if ( ps->batteryTimeRemaining() >= 0 ) { |
177 | text.sprintf( tr("Battery time remaining") + ": %im %02is", | 192 | text.sprintf( tr("Battery time remaining") + ": %im %02is", |
178 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); | 193 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); |
179 | p.drawText( 10, 130, text ); | 194 | p.drawText( 10, 130, text ); |
180 | } | 195 | } |
181 | 196 | ||
182 | QColor c; | 197 | QColor c; |
183 | QColor darkc; | 198 | QColor darkc; |
184 | QColor lightc; | 199 | QColor lightc; |
185 | if ( ps->acStatus() == PowerStatus::Offline ) { | 200 | if ( ps->acStatus() == PowerStatus::Offline ) { |
186 | c = blue.light(120); | 201 | c = blue.light(120); |
187 | darkc = c.dark(280); | 202 | darkc = c.dark(280); |
188 | lightc = c.light(145); | 203 | lightc = c.light(145); |
189 | } else if ( ps->acStatus() == PowerStatus::Online ) { | 204 | } else if ( ps->acStatus() == PowerStatus::Online ) { |
190 | c = green.dark(130); | 205 | c = green.dark(130); |
191 | darkc = c.dark(200); | 206 | darkc = c.dark(200); |
192 | lightc = c.light(220); | 207 | lightc = c.light(220); |
193 | } else { | 208 | } else { |
194 | c = red; | 209 | c = red; |
195 | darkc = c.dark(280); | 210 | darkc = c.dark(280); |
196 | lightc = c.light(140); | 211 | lightc = c.light(140); |
197 | } | 212 | } |
198 | if ( percent < 0 ) | 213 | if ( percent < 0 ) |
199 | return; | 214 | return; |
200 | 215 | ||
201 | int percent2 = percent * 2; | 216 | int rightEnd1 = screenWidth - 47; |
217 | int rightEnd2 = screenWidth - 35; | ||
218 | int percent2 = ( percent / 100 ) * rightEnd1 ; | ||
202 | p.setPen( black ); | 219 | p.setPen( black ); |
203 | qDrawShadePanel( &p, 9, 30, 204, 39, colorGroup(), TRUE, 1, NULL); | 220 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); |
204 | qDrawShadePanel( &p, 212, 37, 12, 24, colorGroup(), TRUE, 1, NULL); | 221 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); |
205 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); | 222 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); |
206 | drawSegment( &p, QRect( 11 + percent2, 30, 200 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); | 223 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); |
207 | drawSegment( &p, QRect( 212, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 224 | drawSegment( &p, QRect( rightEnd2, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
208 | p.setPen( black); | 225 | p.setPen( black); |
209 | 226 | ||
210 | 227 | ||
211 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 228 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
212 | 229 | ||
213 | p.drawText(15, 50, tr ("Ipaq " + ipaqChem)); | 230 | p.drawText(15, 50, tr ("Ipaq " + ipaqChem)); |
214 | 231 | ||
215 | QString jacketMsg; | 232 | QString jacketMsg; |
216 | if (bat2) { | 233 | if (bat2) { |
217 | p.setPen(black); | 234 | p.setPen(black); |
218 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); | 235 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); |
219 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); | 236 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); |
220 | jacketMsg = tr("Jacket " + jackChem); | 237 | jacketMsg = tr("Jacket " + jackChem); |
221 | } else { | 238 | } else { |
222 | jackPercent = 0; | 239 | jackPercent = 0; |
223 | jacketMsg = tr("No jacket with battery inserted"); | 240 | jacketMsg = tr("No jacket with battery inserted"); |
224 | } | 241 | } |
225 | 242 | ||
226 | qDrawShadePanel( &p, 9, 160, 204, 39, colorGroup(), TRUE, 1, NULL); | 243 | int jackPerc = ( jackPercent / 100 ) * screenWidth - 47; |
227 | qDrawShadePanel( &p, 212, 167, 12, 24, colorGroup(), TRUE, 1, NULL); | 244 | |
228 | drawSegment( &p, QRect( 10, 160, jackPercent*2, 40 ), lightc, darkc, lightc.light(115), 6 ); | 245 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); |
229 | drawSegment( &p, QRect( 11 + jackPercent*2, 160, 200 - jackPercent*2, 40 ), white.light(80), black, white.light(90), 6 ); | 246 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); |
230 | drawSegment( &p, QRect( 212, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 247 | drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); |
248 | drawSegment( &p, QRect( 11 + jackPerc, 160, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); | ||
249 | drawSegment( &p, QRect( rightEnd2, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); | ||
231 | p.setPen( black ); | 250 | p.setPen( black ); |
232 | p.drawText(15, 180, jacketMsg); | 251 | p.drawText(15, 180, jacketMsg); |
233 | } | 252 | } |
234 | 253 | ||
235 | } | 254 | } |
236 | 255 | ||
diff --git a/core/applets/batteryapplet/batterystatus.h b/core/applets/batteryapplet/batterystatus.h index 18c2943..a5ab804 100644 --- a/core/applets/batteryapplet/batterystatus.h +++ b/core/applets/batteryapplet/batterystatus.h | |||
@@ -1,58 +1,60 @@ | |||
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 <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | class PowerStatus; | 25 | class PowerStatus; |
26 | 26 | ||
27 | class BatteryStatus : public QWidget | 27 | class BatteryStatus : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | BatteryStatus( const PowerStatus *s, QWidget *parent=0 ); | 31 | BatteryStatus( const PowerStatus *s, QWidget *parent=0 ); |
32 | ~BatteryStatus(); | 32 | ~BatteryStatus(); |
33 | 33 | ||
34 | void updatePercent( int ); | 34 | void updatePercent( int ); |
35 | 35 | ||
36 | protected: | 36 | protected: |
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 | private: | 40 | private: |
41 | const PowerStatus *ps; | 41 | const PowerStatus *ps; |
42 | int percent; | 42 | int percent; |
43 | int ipaqPercent; | 43 | int ipaqPercent; |
44 | int jackPercent; | 44 | int jackPercent; |
45 | int jackMinutes; | 45 | int jackMinutes; |
46 | QString perc1; | 46 | QString perc1; |
47 | QString sec1; | 47 | QString sec1; |
48 | QString perc2; | 48 | QString perc2; |
49 | QString sec2; | 49 | QString sec2; |
50 | QString ipaqStatus; | 50 | QString ipaqStatus; |
51 | QString jackStatus; | 51 | QString jackStatus; |
52 | QString ipaqChem; | 52 | QString ipaqChem; |
53 | QString jackChem; | 53 | QString jackChem; |
54 | bool bat2; | 54 | bool bat2; |
55 | int screenWidth; | ||
56 | int screenHeight; | ||
55 | }; | 57 | }; |
56 | 58 | ||
57 | #endif | 59 | #endif |
58 | 60 | ||