-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 34043f4..08ddc85 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -1,283 +1,284 @@ | |||
1 | 1 | ||
2 | #include "batterystatus.h" | 2 | #include "batterystatus.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <opie2/odevice.h> | 5 | #include <opie2/odevice.h> |
6 | #include <qpe/power.h> | 6 | #include <qpe/power.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qdrawutil.h> | 10 | #include <qdrawutil.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | ||
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | ||
17 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f ) | 17 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f ) |
18 | : QFrame( parent, 0, f), ps(p), bat2(false) { | 18 | : QFrame( parent, 0, f), ps(p), bat2(false) { |
19 | 19 | ||
20 | UpdateBatteryStatus(); | 20 | UpdateBatteryStatus(); |
21 | } | 21 | } |
22 | 22 | ||
23 | BatteryStatus::~BatteryStatus() {} | 23 | BatteryStatus::~BatteryStatus() {} |
24 | 24 | ||
25 | void BatteryStatus::UpdateBatteryStatus() { | 25 | void BatteryStatus::UpdateBatteryStatus() { |
26 | 26 | ||
27 | jackPercent = 0; | 27 | jackPercent = 0; |
28 | 28 | ||
29 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 29 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
30 | getProcApmStatusIpaq(); | 30 | if ( ODevice::inst ( ) -> model() != Model_iPAQ_H191x ) |
31 | getProcApmStatusIpaq(); | ||
31 | } | 32 | } |
32 | percent = ps->batteryPercentRemaining(); | 33 | percent = ps->batteryPercentRemaining(); |
33 | } | 34 | } |
34 | 35 | ||
35 | /* | 36 | /* |
36 | * Make use of the advanced apm interface of the ipaq | 37 | * Make use of the advanced apm interface of the ipaq |
37 | */ | 38 | */ |
38 | bool BatteryStatus::getProcApmStatusIpaq() { | 39 | bool BatteryStatus::getProcApmStatusIpaq() { |
39 | 40 | ||
40 | bat2 = false; | 41 | bat2 = false; |
41 | 42 | ||
42 | QFile procApmIpaq("/proc/hal/battery"); | 43 | QFile procApmIpaq("/proc/hal/battery"); |
43 | 44 | ||
44 | if (procApmIpaq.open(IO_ReadOnly) ) { | 45 | if (procApmIpaq.open(IO_ReadOnly) ) { |
45 | QStringList list; | 46 | QStringList list; |
46 | // since it is /proc we _must_ use QTextStream | 47 | // since it is /proc we _must_ use QTextStream |
47 | QTextStream stream ( &procApmIpaq); | 48 | QTextStream stream ( &procApmIpaq); |
48 | QString streamIn; | 49 | QString streamIn; |
49 | streamIn = stream.read(); | 50 | streamIn = stream.read(); |
50 | list = QStringList::split("\n", streamIn); | 51 | list = QStringList::split("\n", streamIn); |
51 | 52 | ||
52 | sec2 = sec1 = ""; | 53 | sec2 = sec1 = ""; |
53 | 54 | ||
54 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 55 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
55 | // not nice, need a rewrite later | 56 | // not nice, need a rewrite later |
56 | if( (*line).startsWith(" Percentage") ) { | 57 | if( (*line).startsWith(" Percentage") ) { |
57 | if (bat2 == true) { | 58 | if (bat2 == true) { |
58 | perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2); | 59 | perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2); |
59 | } else { | 60 | } else { |
60 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 61 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
61 | } | 62 | } |
62 | } else if( (*line).startsWith(" Life") ) { | 63 | } else if( (*line).startsWith(" Life") ) { |
63 | if (bat2 == true) { | 64 | if (bat2 == true) { |
64 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); | 65 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); |
65 | } else { | 66 | } else { |
66 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); | 67 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); |
67 | } | 68 | } |
68 | } else if( (*line).startsWith("Battery #1") ) { | 69 | } else if( (*line).startsWith("Battery #1") ) { |
69 | bat2 = true; | 70 | bat2 = true; |
70 | } else if( (*line).startsWith(" Status") ) { | 71 | } else if( (*line).startsWith(" Status") ) { |
71 | if (bat2 == true) { | 72 | if (bat2 == true) { |
72 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | 73 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); |
73 | } else { | 74 | } else { |
74 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | 75 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); |
75 | } | 76 | } |
76 | } else if( (*line).startsWith(" Chemistry") ) { | 77 | } else if( (*line).startsWith(" Chemistry") ) { |
77 | if (bat2 == true) { | 78 | if (bat2 == true) { |
78 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 79 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
79 | } else { | 80 | } else { |
80 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 81 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
81 | } | 82 | } |
82 | } | 83 | } |
83 | } | 84 | } |
84 | } else { | 85 | } else { |
85 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); | 86 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); |
86 | } | 87 | } |
87 | 88 | ||
88 | procApmIpaq.close(); | 89 | procApmIpaq.close(); |
89 | jackPercent = perc2.toInt(); | 90 | jackPercent = perc2.toInt(); |
90 | ipaqPercent = perc1.toInt(); | 91 | ipaqPercent = perc1.toInt(); |
91 | 92 | ||
92 | if (perc2.isEmpty() || perc2 == "unknow" ) { | 93 | if (perc2.isEmpty() || perc2 == "unknow" ) { |
93 | perc2 = tr("no data"); | 94 | perc2 = tr("no data"); |
94 | } else { | 95 | } else { |
95 | perc2 += " %"; | 96 | perc2 += " %"; |
96 | } | 97 | } |
97 | 98 | ||
98 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { | 99 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { |
99 | sec2 = tr("no data"); | 100 | sec2 = tr("no data"); |
100 | } else { | 101 | } else { |
101 | sec2 += " min"; | 102 | sec2 += " min"; |
102 | } | 103 | } |
103 | 104 | ||
104 | jackStatus.prepend( " ( " ); | 105 | jackStatus.prepend( " ( " ); |
105 | jackStatus.append( " )" ); | 106 | jackStatus.append( " )" ); |
106 | return true; | 107 | return true; |
107 | } | 108 | } |
108 | 109 | ||
109 | 110 | ||
110 | void BatteryStatus::updatePercent( int pc ) { | 111 | void BatteryStatus::updatePercent( int pc ) { |
111 | percent = pc; | 112 | percent = pc; |
112 | repaint(FALSE); | 113 | repaint(FALSE); |
113 | } | 114 | } |
114 | 115 | ||
115 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { | 116 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { |
116 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; | 117 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; |
117 | topgrad.hsv( &h1, &s1, &v1 ); | 118 | topgrad.hsv( &h1, &s1, &v1 ); |
118 | botgrad.hsv( &h2, &s2, &v2 ); | 119 | botgrad.hsv( &h2, &s2, &v2 ); |
119 | for ( int j = 0; j < hy-2; j++ ) { | 120 | for ( int j = 0; j < hy-2; j++ ) { |
120 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 121 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
121 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 122 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
122 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); | 123 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); |
123 | } | 124 | } |
124 | for ( int j = 0; j < hh; j++ ) { | 125 | for ( int j = 0; j < hh; j++ ) { |
125 | p->setPen( highlight ); | 126 | p->setPen( highlight ); |
126 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); | 127 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); |
127 | } | 128 | } |
128 | for ( int j = 0; j < ng-hy-hh; j++ ) { | 129 | for ( int j = 0; j < ng-hy-hh; j++ ) { |
129 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 130 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
130 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 131 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
131 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); | 132 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | 135 | ||
135 | QString BatteryStatus::statusText() const { | 136 | QString BatteryStatus::statusText() const { |
136 | QString text; | 137 | QString text; |
137 | 138 | ||
138 | if ( ps->batteryStatus() == PowerStatus::Charging ) { | 139 | if ( ps->batteryStatus() == PowerStatus::Charging ) { |
139 | if (bat2) { | 140 | if (bat2) { |
140 | text = tr("Charging both devices"); | 141 | text = tr("Charging both devices"); |
141 | } else { | 142 | } else { |
142 | text = tr("Charging"); | 143 | text = tr("Charging"); |
143 | } | 144 | } |
144 | } else if ( ps->batteryPercentAccurate() ) { | 145 | } else if ( ps->batteryPercentAccurate() ) { |
145 | text = tr( "Remaining Power: %1%" ).arg( percent ); | 146 | text = tr( "Remaining Power: %1%" ).arg( percent ); |
146 | //text.sprintf( tr("Remaining Power") + ": %i%%", percent ); | 147 | //text.sprintf( tr("Remaining Power") + ": %i%%", percent ); |
147 | } else { | 148 | } else { |
148 | text = tr( "Battery status: " ); | 149 | text = tr( "Battery status: " ); |
149 | switch ( ps->batteryStatus() ) { | 150 | switch ( ps->batteryStatus() ) { |
150 | case PowerStatus::High: | 151 | case PowerStatus::High: |
151 | text.append( tr( "Good" ) ); | 152 | text.append( tr( "Good" ) ); |
152 | break; | 153 | break; |
153 | case PowerStatus::Low: | 154 | case PowerStatus::Low: |
154 | text.append( tr( "Low" ) ); | 155 | text.append( tr( "Low" ) ); |
155 | break; | 156 | break; |
156 | case PowerStatus::VeryLow: | 157 | case PowerStatus::VeryLow: |
157 | text.append( tr( "Very Low" ) ); | 158 | text.append( tr( "Very Low" ) ); |
158 | break; | 159 | break; |
159 | case PowerStatus::Critical: | 160 | case PowerStatus::Critical: |
160 | text.append( tr( "Critical" ) ); | 161 | text.append( tr( "Critical" ) ); |
161 | break; | 162 | break; |
162 | default: // NotPresent, etc. | 163 | default: // NotPresent, etc. |
163 | text.append( tr( "Unknown" ) ); | 164 | text.append( tr( "Unknown" ) ); |
164 | } | 165 | } |
165 | } | 166 | } |
166 | 167 | ||
167 | if ( ps->acStatus() == PowerStatus::Backup ) | 168 | if ( ps->acStatus() == PowerStatus::Backup ) |
168 | { | 169 | { |
169 | text.append( '\n' ); | 170 | text.append( '\n' ); |
170 | text.append( tr( "On backup power" ) ); | 171 | text.append( tr( "On backup power" ) ); |
171 | } | 172 | } |
172 | else if ( ps->acStatus() == PowerStatus::Online ) | 173 | else if ( ps->acStatus() == PowerStatus::Online ) |
173 | { | 174 | { |
174 | text.append( '\n' ); | 175 | text.append( '\n' ); |
175 | text.append( tr( "Power on-line" ) ); | 176 | text.append( tr( "Power on-line" ) ); |
176 | } | 177 | } |
177 | else if ( ps->acStatus() == PowerStatus::Offline ) | 178 | else if ( ps->acStatus() == PowerStatus::Offline ) |
178 | { | 179 | { |
179 | text.append( '\n' ); | 180 | text.append( '\n' ); |
180 | text.append( tr( "External power disconnected" ) ); | 181 | text.append( tr( "External power disconnected" ) ); |
181 | } | 182 | } |
182 | 183 | ||
183 | if ( ps->batteryTimeRemaining() >= 0 ) | 184 | if ( ps->batteryTimeRemaining() >= 0 ) |
184 | { | 185 | { |
185 | text.append( '\n' ); | 186 | text.append( '\n' ); |
186 | text.append( tr("Remaining Time: %1m %2s" ).arg( ps->batteryTimeRemaining() / 60 ) | 187 | text.append( tr("Remaining Time: %1m %2s" ).arg( ps->batteryTimeRemaining() / 60 ) |
187 | .arg( ps->batteryTimeRemaining() % 60, 2 ) ); | 188 | .arg( ps->batteryTimeRemaining() % 60, 2 ) ); |
188 | /* text += "\n" + QString().sprintf( tr("Remaining Time") + ": %im %02is", | 189 | /* text += "\n" + QString().sprintf( tr("Remaining Time") + ": %im %02is", |
189 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 );*/ | 190 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 );*/ |
190 | } | 191 | } |
191 | return text; | 192 | return text; |
192 | } | 193 | } |
193 | 194 | ||
194 | QString BatteryStatus::statusTextIpaq() const { | 195 | QString BatteryStatus::statusTextIpaq() const { |
195 | QString text = tr( "Remaining Power: %1 \n%2\nRemaining Time: %3" ).arg( perc2 ) | 196 | QString text = tr( "Remaining Power: %1 \n%2\nRemaining Time: %3" ).arg( perc2 ) |
196 | .arg( jackStatus ) | 197 | .arg( jackStatus ) |
197 | .arg( sec2 ); | 198 | .arg( sec2 ); |
198 | /* QString text = tr("Remaining Power: ") + perc2 + " " + jackStatus; | 199 | /* QString text = tr("Remaining Power: ") + perc2 + " " + jackStatus; |
199 | text += "\n" + tr("Remaining Time: ") + sec2;*/ | 200 | text += "\n" + tr("Remaining Time: ") + sec2;*/ |
200 | return text; | 201 | return text; |
201 | } | 202 | } |
202 | 203 | ||
203 | void BatteryStatus::paintEvent( QPaintEvent * ev ) { | 204 | void BatteryStatus::paintEvent( QPaintEvent * ev ) { |
204 | 205 | ||
205 | QPainter p( this ); | 206 | QPainter p( this ); |
206 | 207 | ||
207 | QString text = statusText(); | 208 | QString text = statusText(); |
208 | p.eraseRect( p.boundingRect( 10, 50, width() - 20, 40 , AlignVCenter, text ) ); | 209 | p.eraseRect( p.boundingRect( 10, 50, width() - 20, 40 , AlignVCenter, text ) ); |
209 | p.drawText( 10, 50, width() - 20, 40 , AlignVCenter, text ); | 210 | p.drawText( 10, 50, width() - 20, 40 , AlignVCenter, text ); |
210 | 211 | ||
211 | QColor c; | 212 | QColor c; |
212 | QColor darkc; | 213 | QColor darkc; |
213 | QColor lightc; | 214 | QColor lightc; |
214 | if ( ps->acStatus() == PowerStatus::Offline ) { | 215 | if ( ps->acStatus() == PowerStatus::Offline ) { |
215 | c = blue.light(120); | 216 | c = blue.light(120); |
216 | darkc = c.dark(280); | 217 | darkc = c.dark(280); |
217 | lightc = c.light(145); | 218 | lightc = c.light(145); |
218 | } else if ( ps->acStatus() == PowerStatus::Online ) { | 219 | } else if ( ps->acStatus() == PowerStatus::Online ) { |
219 | c = green.dark(130); | 220 | c = green.dark(130); |
220 | darkc = c.dark(200); | 221 | darkc = c.dark(200); |
221 | lightc = c.light(220); | 222 | lightc = c.light(220); |
222 | } else { | 223 | } else { |
223 | c = red; | 224 | c = red; |
224 | darkc = c.dark(280); | 225 | darkc = c.dark(280); |
225 | lightc = c.light(140); | 226 | lightc = c.light(140); |
226 | } | 227 | } |
227 | if ( percent < 0 ) | 228 | if ( percent < 0 ) |
228 | return; | 229 | return; |
229 | 230 | ||
230 | int rightEnd1 = width() - 47; | 231 | int rightEnd1 = width() - 47; |
231 | int rightEnd2 = width() - 35; | 232 | int rightEnd2 = width() - 35; |
232 | int percent2 = (percent * rightEnd1) / 100; | 233 | int percent2 = (percent * rightEnd1) / 100; |
233 | p.setPen( black ); | 234 | p.setPen( black ); |
234 | qDrawShadePanel( &p, 9, 10, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); | 235 | qDrawShadePanel( &p, 9, 10, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); |
235 | qDrawShadePanel( &p, rightEnd2, 17, 12, 24, colorGroup(), TRUE, 1, NULL); | 236 | qDrawShadePanel( &p, rightEnd2, 17, 12, 24, colorGroup(), TRUE, 1, NULL); |
236 | drawSegment( &p, QRect( 10, 10, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); | 237 | drawSegment( &p, QRect( 10, 10, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); |
237 | drawSegment( &p, QRect( 11 + percent2, 10, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); | 238 | drawSegment( &p, QRect( 11 + percent2, 10, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); |
238 | drawSegment( &p, QRect( rightEnd2, 17, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 239 | drawSegment( &p, QRect( rightEnd2, 17, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
239 | p.setPen( black); | 240 | p.setPen( black); |
240 | 241 | ||
241 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ && bat2 ) { | 242 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ && bat2 ) { |
242 | 243 | ||
243 | p.drawText( 15, 30, tr("Ipaq %1").arg( ipaqChem ) ); | 244 | p.drawText( 15, 30, tr("Ipaq %1").arg( ipaqChem ) ); |
244 | 245 | ||
245 | QString jacketMsg; | 246 | QString jacketMsg; |
246 | if (bat2) { | 247 | if (bat2) { |
247 | p.setPen(black); | 248 | p.setPen(black); |
248 | QString text = statusTextIpaq(); | 249 | QString text = statusTextIpaq(); |
249 | p.eraseRect( p.boundingRect( 10, 130, width() - 20, 40 , AlignVCenter, text ) ); | 250 | p.eraseRect( p.boundingRect( 10, 130, width() - 20, 40 , AlignVCenter, text ) ); |
250 | p.drawText( 10, 130, width() - 20, 40 , AlignVCenter, text ); | 251 | p.drawText( 10, 130, width() - 20, 40 , AlignVCenter, text ); |
251 | jacketMsg = tr("Jacket ").arg( jackChem ); | 252 | jacketMsg = tr("Jacket ").arg( jackChem ); |
252 | } else { | 253 | } else { |
253 | jackPercent = 0; | 254 | jackPercent = 0; |
254 | jacketMsg = tr("No jacket with battery inserted"); | 255 | jacketMsg = tr("No jacket with battery inserted"); |
255 | } | 256 | } |
256 | 257 | ||
257 | int jackPerc = ( jackPercent * ( width() - 47 ) ) / 100; | 258 | int jackPerc = ( jackPercent * ( width() - 47 ) ) / 100; |
258 | 259 | ||
259 | qDrawShadePanel( &p, 9, 90, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); | 260 | qDrawShadePanel( &p, 9, 90, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); |
260 | qDrawShadePanel( &p, rightEnd2, 97, 12, 24, colorGroup(), TRUE, 1, NULL); | 261 | qDrawShadePanel( &p, rightEnd2, 97, 12, 24, colorGroup(), TRUE, 1, NULL); |
261 | drawSegment( &p, QRect( 10, 90, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); | 262 | drawSegment( &p, QRect( 10, 90, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); |
262 | drawSegment( &p, QRect( 11 + jackPerc, 90, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); | 263 | drawSegment( &p, QRect( 11 + jackPerc, 90, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); |
263 | drawSegment( &p, QRect( rightEnd2, 97, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 264 | drawSegment( &p, QRect( rightEnd2, 97, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
264 | p.setPen( black ); | 265 | p.setPen( black ); |
265 | p.drawText(15, 100, width() - 20, 20 , AlignVCenter, jacketMsg); | 266 | p.drawText(15, 100, width() - 20, 20 , AlignVCenter, jacketMsg); |
266 | } | 267 | } |
267 | QFrame::paintEvent(ev); | 268 | QFrame::paintEvent(ev); |
268 | } | 269 | } |
269 | 270 | ||
270 | QSize BatteryStatus::sizeHint() const { | 271 | QSize BatteryStatus::sizeHint() const { |
271 | QString text = statusText(); | 272 | QString text = statusText(); |
272 | QString text2 = statusTextIpaq(); | 273 | QString text2 = statusTextIpaq(); |
273 | QFontMetrics fm = fontMetrics(); | 274 | QFontMetrics fm = fontMetrics(); |
274 | QRect r=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text ); | 275 | QRect r=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text ); |
275 | QRect r2=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text2 ); | 276 | QRect r2=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text2 ); |
276 | 277 | ||
277 | if ( bat2 ) { | 278 | if ( bat2 ) { |
278 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), | 279 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), |
279 | r.width()+2*10 ), 2 * 10 + 100 + r.height() + r2.height() ); | 280 | r.width()+2*10 ), 2 * 10 + 100 + r.height() + r2.height() ); |
280 | } | 281 | } |
281 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), | 282 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), |
282 | r.width()+2*10 ), 2 * 10 + 40 + r.height() ); | 283 | r.width()+2*10 ), 2 * 10 + 40 + r.height() ); |
283 | } | 284 | } |