-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 | |||
@@ -155,49 +155,49 @@ QString BatteryStatus::statusText() const { | |||
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; |
@@ -217,40 +217,41 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
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 | } |