-rw-r--r-- | core/applets/batteryapplet/battery.cpp | 14 | ||||
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 2 |
2 files changed, 3 insertions, 13 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index 480d261..078ce8d 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp | |||
@@ -77,100 +77,90 @@ void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) | |||
77 | batteryView->raise(); | 77 | batteryView->raise(); |
78 | batteryView->show(); | 78 | batteryView->show(); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | void BatteryMeter::timerEvent( QTimerEvent * ) | 82 | void BatteryMeter::timerEvent( QTimerEvent * ) |
83 | { | 83 | { |
84 | PowerStatus prev = *ps; | 84 | PowerStatus prev = *ps; |
85 | 85 | ||
86 | *ps = PowerStatusManager::readStatus(); | 86 | *ps = PowerStatusManager::readStatus(); |
87 | 87 | ||
88 | if ( prev != *ps ) { | 88 | if ( prev != *ps ) { |
89 | percent = ps->batteryPercentRemaining(); | 89 | percent = ps->batteryPercentRemaining(); |
90 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { | 90 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { |
91 | percent = 0; | 91 | percent = 0; |
92 | charging = true; | 92 | charging = true; |
93 | chargeTimer->start( 500 ); | 93 | chargeTimer->start( 500 ); |
94 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { | 94 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { |
95 | charging = false; | 95 | charging = false; |
96 | chargeTimer->stop(); | 96 | chargeTimer->stop(); |
97 | if ( batteryView ) | 97 | if ( batteryView ) |
98 | batteryView->updatePercent( percent ); | 98 | batteryView->updatePercent( percent ); |
99 | } | 99 | } |
100 | repaint( style != 0 ); | 100 | repaint( style != 0 ); |
101 | if ( batteryView ) | 101 | if ( batteryView ) |
102 | batteryView->repaint(); | 102 | batteryView->repaint(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void BatteryMeter::chargeTimeout() | 106 | void BatteryMeter::chargeTimeout() |
107 | { | 107 | { |
108 | percent += 20; | 108 | percent += 20; |
109 | if ( percent > 100 ) | 109 | if ( percent > 100 ) |
110 | percent = 0; | 110 | percent = 0; |
111 | 111 | ||
112 | repaint(FALSE); | 112 | repaint(FALSE); |
113 | if ( batteryView ) | 113 | if ( batteryView ) |
114 | batteryView->updatePercent( percent ); | 114 | batteryView->updatePercent( percent ); |
115 | } | 115 | } |
116 | 116 | ||
117 | void BatteryMeter::paintEvent( QPaintEvent* ) | 117 | void BatteryMeter::paintEvent( QPaintEvent* ) |
118 | { | 118 | { |
119 | if ( style == 1 ) | 119 | if ( style == 1 ) |
120 | { | 120 | { |
121 | QPainter p(this); | 121 | QPainter p(this); |
122 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); | 122 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); |
123 | QFontMetrics fm( f ); | 123 | QFontMetrics fm( f ); |
124 | p.setFont( f ); | 124 | p.setFont( f ); |
125 | if ( percent > 98 ) { | 125 | p.drawText( 0, AppLnk::smallIconSize()/2, QString::number( percent ) ); |
126 | p.drawText( 0, 0, width(), height(), Qt::AlignCenter, tr( "F" ) ); | 126 | p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" ); |
127 | } | ||
128 | else if ( percent < 5 ) | ||
129 | { | ||
130 | p.drawText( 0, 0, width(), height(), Qt::AlignCenter, tr( "E" ) ); | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | p.drawText( 0, AppLnk::smallIconSize()/2, QString::number( percent ) ); | ||
135 | p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" ); | ||
136 | } | ||
137 | return; | 127 | return; |
138 | } | 128 | } |
139 | 129 | ||
140 | QPainter p(this); | 130 | QPainter p(this); |
141 | QColor color; | 131 | QColor color; |
142 | QColor g = gray.light( 160 ); | 132 | QColor g = gray.light( 160 ); |
143 | switch ( ps->acStatus() ) | 133 | switch ( ps->acStatus() ) |
144 | { | 134 | { |
145 | case PowerStatus::Offline: color = blue.light( 150 ); break; | 135 | case PowerStatus::Offline: color = blue.light( 150 ); break; |
146 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; | 136 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; |
147 | default: color = red.light( 160 ); | 137 | default: color = red.light( 160 ); |
148 | } | 138 | } |
149 | 139 | ||
150 | int w = height() / 2; | 140 | int w = height() / 2; |
151 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line | 141 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line |
152 | int h = height() - 4; | 142 | int h = height() - 4; |
153 | int pix = (percent * h) / 100; | 143 | int pix = (percent * h) / 100; |
154 | int y2 = height() -2; | 144 | int y2 = height() -2; |
155 | int y = y2 - pix; | 145 | int y = y2 - pix; |
156 | int x1 = (width() - w ) / 2; | 146 | int x1 = (width() - w ) / 2; |
157 | 147 | ||
158 | p.setPen(QColor(80,80,80)); | 148 | p.setPen(QColor(80,80,80)); |
159 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header | 149 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header |
160 | p.drawRect(x1,1,w,height()-1); // corpus | 150 | p.drawRect(x1,1,w,height()-1); // corpus |
161 | p.setBrush(color); | 151 | p.setBrush(color); |
162 | 152 | ||
163 | int extra = ((percent * h) % 100)/(100/4); | 153 | int extra = ((percent * h) % 100)/(100/4); |
164 | 154 | ||
165 | int middle = w/2; | 155 | int middle = w/2; |
166 | for ( int i = 0; i < middle; i++ ) | 156 | for ( int i = 0; i < middle; i++ ) |
167 | { | 157 | { |
168 | p.setPen( gray.dark( 100+i*20 ) ); | 158 | p.setPen( gray.dark( 100+i*20 ) ); |
169 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); | 159 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); |
170 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); | 160 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); |
171 | p.setPen( color.dark( 100+i*20 ) ); | 161 | p.setPen( color.dark( 100+i*20 ) ); |
172 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); | 162 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); |
173 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); | 163 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); |
174 | } | 164 | } |
175 | } | 165 | } |
176 | 166 | ||
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index 092a48d..5936b5d 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -195,61 +195,61 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
195 | } | 195 | } |
196 | 196 | ||
197 | QColor c; | 197 | QColor c; |
198 | QColor darkc; | 198 | QColor darkc; |
199 | QColor lightc; | 199 | QColor lightc; |
200 | if ( ps->acStatus() == PowerStatus::Offline ) { | 200 | if ( ps->acStatus() == PowerStatus::Offline ) { |
201 | c = blue.light(120); | 201 | c = blue.light(120); |
202 | darkc = c.dark(280); | 202 | darkc = c.dark(280); |
203 | lightc = c.light(145); | 203 | lightc = c.light(145); |
204 | } else if ( ps->acStatus() == PowerStatus::Online ) { | 204 | } else if ( ps->acStatus() == PowerStatus::Online ) { |
205 | c = green.dark(130); | 205 | c = green.dark(130); |
206 | darkc = c.dark(200); | 206 | darkc = c.dark(200); |
207 | lightc = c.light(220); | 207 | lightc = c.light(220); |
208 | } else { | 208 | } else { |
209 | c = red; | 209 | c = red; |
210 | darkc = c.dark(280); | 210 | darkc = c.dark(280); |
211 | lightc = c.light(140); | 211 | lightc = c.light(140); |
212 | } | 212 | } |
213 | if ( percent < 0 ) | 213 | if ( percent < 0 ) |
214 | return; | 214 | return; |
215 | 215 | ||
216 | int rightEnd1 = screenWidth - 47; | 216 | int rightEnd1 = screenWidth - 47; |
217 | int rightEnd2 = screenWidth - 35; | 217 | int rightEnd2 = screenWidth - 35; |
218 | int percent2 = ( percent / 100.0 ) * rightEnd1 ; | 218 | int percent2 = ( percent / 100.0 ) * rightEnd1 ; |
219 | p.setPen( black ); | 219 | p.setPen( black ); |
220 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); | 220 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); |
221 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); | 221 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); |
222 | 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 ); |
223 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - 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 ); |
224 | drawSegment( &p, QRect( rightEnd2, 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 ); |
225 | p.setPen( black); | 225 | p.setPen( black); |
226 | 226 | ||
227 | 227 | ||
228 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 228 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
229 | 229 | ||
230 | p.drawText(15, 50, tr ("Ipaq " + ipaqChem)); | 230 | p.drawText(15, 50, tr ("Ipaq " + ipaqChem)); |
231 | 231 | ||
232 | QString jacketMsg; | 232 | QString jacketMsg; |
233 | if (bat2) { | 233 | if (bat2) { |
234 | p.setPen(black); | 234 | p.setPen(black); |
235 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); | 235 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); |
236 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); | 236 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); |
237 | jacketMsg = tr("Jacket " + jackChem); | 237 | jacketMsg = tr("Jacket " + jackChem); |
238 | } else { | 238 | } else { |
239 | jackPercent = 0; | 239 | jackPercent = 0; |
240 | jacketMsg = tr("No jacket with battery inserted"); | 240 | jacketMsg = tr("No jacket with battery inserted"); |
241 | } | 241 | } |
242 | 242 | ||
243 | int jackPerc = ( jackPercent / 100.0 ) * screenWidth - 47; | 243 | int jackPerc = ( jackPercent / 100.0 ) * ( screenWidth - 47 ) ; |
244 | 244 | ||
245 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); | 245 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); |
246 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); | 246 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); |
247 | drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); | 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 ); | 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 ); | 249 | drawSegment( &p, QRect( rightEnd2, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
250 | p.setPen( black ); | 250 | p.setPen( black ); |
251 | p.drawText(15, 180, jacketMsg); | 251 | p.drawText(15, 180, jacketMsg); |
252 | } | 252 | } |
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||