author | harlekin <harlekin> | 2004-06-20 12:32:59 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-06-20 12:32:59 (UTC) |
commit | 3d49080501c6619f9bb323be9935d28f4458530f (patch) (unidiff) | |
tree | 277baf812e3377554ea1369f54b6b5ac7814d118 | |
parent | 63dd6d0c5919bd905f9c39eb1641d18c5372cdda (diff) | |
download | opie-3d49080501c6619f9bb323be9935d28f4458530f.zip opie-3d49080501c6619f9bb323be9935d28f4458530f.tar.gz opie-3d49080501c6619f9bb323be9935d28f4458530f.tar.bz2 |
BUGFIX: 0001321 - The batteryapplet shows a real popup frame now
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index 655fdc4..5a24b94 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -131,126 +131,127 @@ QString BatteryStatus::statusText() const { | |||
131 | if (bat2) { | 131 | if (bat2) { |
132 | text = tr("Charging both devices"); | 132 | text = tr("Charging both devices"); |
133 | } else { | 133 | } else { |
134 | text = tr("Charging"); | 134 | text = tr("Charging"); |
135 | } | 135 | } |
136 | } else if ( ps->batteryPercentAccurate() ) { | 136 | } else if ( ps->batteryPercentAccurate() ) { |
137 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); | 137 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); |
138 | } else { | 138 | } else { |
139 | text = tr("Battery status: "); | 139 | text = tr("Battery status: "); |
140 | switch ( ps->batteryStatus() ) { | 140 | switch ( ps->batteryStatus() ) { |
141 | case PowerStatus::High: | 141 | case PowerStatus::High: |
142 | text += tr("Good"); | 142 | text += tr("Good"); |
143 | break; | 143 | break; |
144 | case PowerStatus::Low: | 144 | case PowerStatus::Low: |
145 | text += tr("Low"); | 145 | text += tr("Low"); |
146 | break; | 146 | break; |
147 | case PowerStatus::VeryLow: | 147 | case PowerStatus::VeryLow: |
148 | text += tr("Very Low"); | 148 | text += tr("Very Low"); |
149 | break; | 149 | break; |
150 | case PowerStatus::Critical: | 150 | case PowerStatus::Critical: |
151 | text += tr("Critical"); | 151 | text += tr("Critical"); |
152 | break; | 152 | break; |
153 | default: // NotPresent, etc. | 153 | default: // NotPresent, etc. |
154 | text += tr("Unknown"); | 154 | text += tr("Unknown"); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | if ( ps->acStatus() == PowerStatus::Backup ) | 158 | if ( ps->acStatus() == PowerStatus::Backup ) |
159 | text += "\n" + tr("On backup power"); | 159 | text += "\n" + tr("On backup power"); |
160 | else if ( ps->acStatus() == PowerStatus::Online ) | 160 | else if ( ps->acStatus() == PowerStatus::Online ) |
161 | text += "\n" + tr("Power on-line"); | 161 | text += "\n" + tr("Power on-line"); |
162 | else if ( ps->acStatus() == PowerStatus::Offline ) | 162 | else if ( ps->acStatus() == PowerStatus::Offline ) |
163 | text += "\n" + tr("External power disconnected"); | 163 | text += "\n" + tr("External power disconnected"); |
164 | 164 | ||
165 | if ( ps->batteryTimeRemaining() >= 0 ) { | 165 | if ( ps->batteryTimeRemaining() >= 0 ) { |
166 | text += "\n" + QString().sprintf( tr("Battery time remaining") + ": %im %02is", | 166 | text += "\n" + QString().sprintf( tr("Battery time remaining") + ": %im %02is", |
167 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); | 167 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); |
168 | } | 168 | } |
169 | return text; | 169 | return text; |
170 | } | 170 | } |
171 | 171 | ||
172 | QString BatteryStatus::statusTextIpaq() const { | 172 | QString BatteryStatus::statusTextIpaq() const { |
173 | QString text; | 173 | QString text; |
174 | text += tr("Percentage battery remaining: ") + perc2 + " " + jackStatus; | 174 | text += tr("Percentage battery remaining: ") + perc2 + " " + jackStatus; |
175 | text += "\n" + tr("Battery time remaining: ") + sec2; | 175 | text += "\n" + tr("Battery time remaining: ") + sec2; |
176 | return text; | 176 | return text; |
177 | } | 177 | } |
178 | 178 | ||
179 | void BatteryStatus::paintEvent( QPaintEvent * ) { | 179 | void BatteryStatus::paintEvent( QPaintEvent * ev ) { |
180 | 180 | ||
181 | QPainter p( this ); | 181 | QPainter p( this ); |
182 | 182 | ||
183 | QString text = statusText(); | 183 | QString text = statusText(); |
184 | p.drawText( 10, 50, width() - 20, 40 , AlignVCenter, text ); | 184 | p.drawText( 10, 50, width() - 20, 40 , AlignVCenter, text ); |
185 | 185 | ||
186 | QColor c; | 186 | QColor c; |
187 | QColor darkc; | 187 | QColor darkc; |
188 | QColor lightc; | 188 | QColor lightc; |
189 | if ( ps->acStatus() == PowerStatus::Offline ) { | 189 | if ( ps->acStatus() == PowerStatus::Offline ) { |
190 | c = blue.light(120); | 190 | c = blue.light(120); |
191 | darkc = c.dark(280); | 191 | darkc = c.dark(280); |
192 | lightc = c.light(145); | 192 | lightc = c.light(145); |
193 | } else if ( ps->acStatus() == PowerStatus::Online ) { | 193 | } else if ( ps->acStatus() == PowerStatus::Online ) { |
194 | c = green.dark(130); | 194 | c = green.dark(130); |
195 | darkc = c.dark(200); | 195 | darkc = c.dark(200); |
196 | lightc = c.light(220); | 196 | lightc = c.light(220); |
197 | } else { | 197 | } else { |
198 | c = red; | 198 | c = red; |
199 | darkc = c.dark(280); | 199 | darkc = c.dark(280); |
200 | lightc = c.light(140); | 200 | lightc = c.light(140); |
201 | } | 201 | } |
202 | if ( percent < 0 ) | 202 | if ( percent < 0 ) |
203 | return; | 203 | return; |
204 | 204 | ||
205 | int rightEnd1 = width() - 47; | 205 | int rightEnd1 = width() - 47; |
206 | int rightEnd2 = width() - 35; | 206 | int rightEnd2 = width() - 35; |
207 | int percent2 = (percent * rightEnd1) / 100; | 207 | int percent2 = (percent * rightEnd1) / 100; |
208 | p.setPen( black ); | 208 | p.setPen( black ); |
209 | qDrawShadePanel( &p, 9, 10, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); | 209 | qDrawShadePanel( &p, 9, 10, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); |
210 | qDrawShadePanel( &p, rightEnd2, 17, 12, 24, colorGroup(), TRUE, 1, NULL); | 210 | qDrawShadePanel( &p, rightEnd2, 17, 12, 24, colorGroup(), TRUE, 1, NULL); |
211 | drawSegment( &p, QRect( 10, 10, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); | 211 | drawSegment( &p, QRect( 10, 10, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); |
212 | drawSegment( &p, QRect( 11 + percent2, 10, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); | 212 | drawSegment( &p, QRect( 11 + percent2, 10, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); |
213 | drawSegment( &p, QRect( rightEnd2, 17, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 213 | drawSegment( &p, QRect( rightEnd2, 17, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
214 | p.setPen( black); | 214 | p.setPen( black); |
215 | 215 | ||
216 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ && bat2 ) { | 216 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ && bat2 ) { |
217 | 217 | ||
218 | p.drawText( 15, 30, tr ("Ipaq ") + ipaqChem ); | 218 | p.drawText( 15, 30, tr ("Ipaq ") + ipaqChem ); |
219 | 219 | ||
220 | QString jacketMsg; | 220 | QString jacketMsg; |
221 | if (bat2) { | 221 | if (bat2) { |
222 | p.setPen(black); | 222 | p.setPen(black); |
223 | QString text = statusTextIpaq(); | 223 | QString text = statusTextIpaq(); |
224 | p.drawText( 10, 150, text ); | 224 | p.drawText( 10, 150, text ); |
225 | jacketMsg = tr("Jacket ") + jackChem; | 225 | jacketMsg = tr("Jacket ") + jackChem; |
226 | } else { | 226 | } else { |
227 | jackPercent = 0; | 227 | jackPercent = 0; |
228 | jacketMsg = tr("No jacket with battery inserted"); | 228 | jacketMsg = tr("No jacket with battery inserted"); |
229 | } | 229 | } |
230 | 230 | ||
231 | int jackPerc = ( jackPercent * ( width() - 47 ) ) / 100; | 231 | int jackPerc = ( jackPercent * ( width() - 47 ) ) / 100; |
232 | 232 | ||
233 | qDrawShadePanel( &p, 9, 90, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); | 233 | qDrawShadePanel( &p, 9, 90, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); |
234 | qDrawShadePanel( &p, rightEnd2, 97, 12, 24, colorGroup(), TRUE, 1, NULL); | 234 | qDrawShadePanel( &p, rightEnd2, 97, 12, 24, colorGroup(), TRUE, 1, NULL); |
235 | drawSegment( &p, QRect( 10, 90, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); | 235 | drawSegment( &p, QRect( 10, 90, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); |
236 | drawSegment( &p, QRect( 11 + jackPerc, 90, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); | 236 | drawSegment( &p, QRect( 11 + jackPerc, 90, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); |
237 | drawSegment( &p, QRect( rightEnd2, 97, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 237 | drawSegment( &p, QRect( rightEnd2, 97, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
238 | p.setPen( black ); | 238 | p.setPen( black ); |
239 | p.drawText(15, 100, width() - 20, 20 , AlignVCenter, jacketMsg); | 239 | p.drawText(15, 100, width() - 20, 20 , AlignVCenter, jacketMsg); |
240 | } | 240 | } |
241 | QFrame::paintEvent(ev); | ||
241 | } | 242 | } |
242 | 243 | ||
243 | QSize BatteryStatus::sizeHint() const { | 244 | QSize BatteryStatus::sizeHint() const { |
244 | QString text = statusText(); | 245 | QString text = statusText(); |
245 | QString text2 = statusTextIpaq(); | 246 | QString text2 = statusTextIpaq(); |
246 | QFontMetrics fm = fontMetrics(); | 247 | QFontMetrics fm = fontMetrics(); |
247 | QRect r=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text ); | 248 | QRect r=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text ); |
248 | QRect r2=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text2 ); | 249 | QRect r2=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text2 ); |
249 | 250 | ||
250 | if ( bat2 ) { | 251 | if ( bat2 ) { |
251 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), | 252 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), |
252 | r.width() ), 2 * 10 + 80 + r.height() + r2.height() ); | 253 | r.width() ), 2 * 10 + 80 + r.height() + r2.height() ); |
253 | } | 254 | } |
254 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), | 255 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), |
255 | r.width() ), 2 * 10 + 40 + r.height() ); | 256 | r.width() ), 2 * 10 + 40 + r.height() ); |
256 | } | 257 | } |