author | drw <drw> | 2004-02-18 16:23:17 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-18 16:23:17 (UTC) |
commit | 7d16774139aa40fb812d636bcf9ad3f45aa2b9e1 (patch) (unidiff) | |
tree | 51dc00c15db884b4f4351ed685e022853446a0d6 /core/applets/batteryapplet/batterystatus.cpp | |
parent | 45179e1807aa5ca024b423112303509f91253a53 (diff) | |
download | opie-7d16774139aa40fb812d636bcf9ad3f45aa2b9e1.zip opie-7d16774139aa40fb812d636bcf9ad3f45aa2b9e1.tar.gz opie-7d16774139aa40fb812d636bcf9ad3f45aa2b9e1.tar.bz2 |
Fix size and drawing of battery status widget and eliminate compiler warnings
Diffstat (limited to 'core/applets/batteryapplet/batterystatus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 75 |
1 files changed, 36 insertions, 39 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 | |||
@@ -21,2 +21,4 @@ BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | |||
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 ); |
@@ -26,4 +28,3 @@ BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | |||
26 | 28 | ||
27 | pb->setMaximumHeight(40); | 29 | pb->setMaximumSize( 120, 40 ); |
28 | pb->setMaximumWidth( 120 ); | ||
29 | 30 | ||
@@ -31,3 +32,3 @@ BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | |||
31 | 32 | ||
32 | layout->addStretch( 0 ); | 33 | layout->addStretch(); |
33 | layout->addWidget( pb ); | 34 | layout->addWidget( pb ); |
@@ -66,27 +67,27 @@ bool BatteryStatus::getProcApmStatusIpaq() { | |||
66 | if( (*line).startsWith(" Percentage") ){ | 67 | if( (*line).startsWith(" Percentage") ){ |
67 | if (bat2 == true) { | 68 | if (bat2 == true) { |
68 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 69 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
69 | } else { | 70 | } else { |
70 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 71 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
71 | } | 72 | } |
72 | }else if( (*line).startsWith(" Life") ){ | 73 | }else if( (*line).startsWith(" Life") ){ |
73 | if (bat2 == true) { | 74 | if (bat2 == true) { |
74 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); | 75 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); |
75 | } else { | 76 | } else { |
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); |
91 | } | 92 | } |
92 | } | 93 | } |
@@ -132,3 +133,3 @@ void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topg | |||
132 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 133 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
133 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 134 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
134 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); | 135 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); |
@@ -141,3 +142,3 @@ void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topg | |||
141 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 142 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
142 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 143 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
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 ); |
@@ -148,6 +149,2 @@ 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); |
@@ -155,7 +152,7 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
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 { |
159 | text = tr("Charging"); | 156 | text = tr("Charging"); |
160 | } | 157 | } |
161 | } else if ( ps->batteryPercentAccurate() ) { | 158 | } else if ( ps->batteryPercentAccurate() ) { |
@@ -192,3 +189,3 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
192 | text.sprintf( tr("Battery time remaining") + ": %im %02is", | 189 | text.sprintf( tr("Battery time remaining") + ": %im %02is", |
193 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); | 190 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); |
194 | p.drawText( 10, 130, text ); | 191 | p.drawText( 10, 130, text ); |
@@ -215,5 +212,5 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
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 ); |
@@ -242,3 +239,3 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
242 | 239 | ||
243 | int jackPerc = ( jackPercent / 100.0 ) * ( screenWidth - 47 ) ; | 240 | int jackPerc = ( jackPercent / 100 ) * ( width() - 47 ) ; |
244 | 241 | ||