Diffstat (limited to 'core/applets/batteryapplet/batterystatus.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index 64e0499..86b20e8 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -16,23 +16,24 @@ | |||
16 | 16 | ||
17 | using namespace Opie; | 17 | using namespace Opie; |
18 | 18 | ||
19 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | 19 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) |
20 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { | 20 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { |
21 | setCaption( tr("Battery status") ); | 21 | setCaption( tr("Battery status") ); |
22 | setMinimumSize( 150, 200 ); | ||
23 | |||
22 | QPushButton *pb = new QPushButton( tr("Close"), this ); | 24 | QPushButton *pb = new QPushButton( tr("Close"), this ); |
23 | QVBoxLayout *layout = new QVBoxLayout ( this ); | 25 | QVBoxLayout *layout = new QVBoxLayout ( this ); |
24 | 26 | ||
25 | jackPercent = 0; | 27 | jackPercent = 0; |
26 | 28 | ||
27 | pb->setMaximumHeight(40); | 29 | pb->setMaximumSize( 120, 40 ); |
28 | pb->setMaximumWidth( 120 ); | ||
29 | 30 | ||
30 | pb->show(); | 31 | pb->show(); |
31 | 32 | ||
32 | layout->addStretch( 0 ); | 33 | layout->addStretch(); |
33 | layout->addWidget( pb ); | 34 | layout->addWidget( pb ); |
34 | 35 | ||
35 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 36 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
36 | getProcApmStatusIpaq(); | 37 | getProcApmStatusIpaq(); |
37 | } | 38 | } |
38 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); | 39 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); |
@@ -76,15 +77,15 @@ bool BatteryStatus::getProcApmStatusIpaq() { | |||
76 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); | 77 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); |
77 | } | 78 | } |
78 | }else if( (*line).startsWith("Battery #1") ){ | 79 | }else if( (*line).startsWith("Battery #1") ){ |
79 | bat2 = true; | 80 | bat2 = true; |
80 | }else if( (*line).startsWith(" Status") ){ | 81 | }else if( (*line).startsWith(" Status") ){ |
81 | if (bat2 == true) { | 82 | if (bat2 == true) { |
82 | jackStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); | 83 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); |
83 | } else { | 84 | } else { |
84 | ipaqStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); | 85 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); |
85 | } | 86 | } |
86 | }else if( (*line).startsWith(" Chemistry") ) { | 87 | }else if( (*line).startsWith(" Chemistry") ) { |
87 | if (bat2 == true) { | 88 | if (bat2 == true) { |
88 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 89 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
89 | } else { | 90 | } else { |
90 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 91 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
@@ -143,16 +144,12 @@ void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topg | |||
143 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); | 144 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); |
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
147 | void BatteryStatus::paintEvent( QPaintEvent * ) { | 148 | void BatteryStatus::paintEvent( QPaintEvent * ) { |
148 | 149 | ||
149 | |||
150 | int screenWidth = qApp->desktop()->width(); | ||
151 | int screenHeight = qApp->desktop()->height(); | ||
152 | |||
153 | QPainter p(this); | 150 | QPainter p(this); |
154 | QString text; | 151 | QString text; |
155 | if ( ps->batteryStatus() == PowerStatus::Charging ) { | 152 | if ( ps->batteryStatus() == PowerStatus::Charging ) { |
156 | if (bat2) { | 153 | if (bat2) { |
157 | text = tr("Charging both devices"); | 154 | text = tr("Charging both devices"); |
158 | } else { | 155 | } else { |
@@ -210,15 +207,15 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
210 | darkc = c.dark(280); | 207 | darkc = c.dark(280); |
211 | lightc = c.light(140); | 208 | lightc = c.light(140); |
212 | } | 209 | } |
213 | if ( percent < 0 ) | 210 | if ( percent < 0 ) |
214 | return; | 211 | return; |
215 | 212 | ||
216 | int rightEnd1 = screenWidth - 47; | 213 | int rightEnd1 = width() - 47; |
217 | int rightEnd2 = screenWidth - 35; | 214 | int rightEnd2 = width() - 35; |
218 | int percent2 = ( percent / 100.0 ) * rightEnd1 ; | 215 | int percent2 = ( percent / 100 ) * rightEnd1 ; |
219 | p.setPen( black ); | 216 | p.setPen( black ); |
220 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); | 217 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); |
221 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); | 218 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); |
222 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); | 219 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); |
223 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); | 220 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); |
224 | drawSegment( &p, QRect( rightEnd2, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 221 | drawSegment( &p, QRect( rightEnd2, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
@@ -237,13 +234,13 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
237 | jacketMsg = tr("Jacket ") + jackChem; | 234 | jacketMsg = tr("Jacket ") + jackChem; |
238 | } else { | 235 | } else { |
239 | jackPercent = 0; | 236 | jackPercent = 0; |
240 | jacketMsg = tr("No jacket with battery inserted"); | 237 | jacketMsg = tr("No jacket with battery inserted"); |
241 | } | 238 | } |
242 | 239 | ||
243 | int jackPerc = ( jackPercent / 100.0 ) * ( screenWidth - 47 ) ; | 240 | int jackPerc = ( jackPercent / 100 ) * ( width() - 47 ) ; |
244 | 241 | ||
245 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); | 242 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); |
246 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); | 243 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); |
247 | drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); | 244 | 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 ); | 245 | 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 ); | 246 | drawSegment( &p, QRect( rightEnd2, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); |