author | harlekin <harlekin> | 2004-05-11 22:41:22 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-05-11 22:41:22 (UTC) |
commit | 7a9cabb330284777113bb544139843dcf0593628 (patch) (unidiff) | |
tree | ec706423d2abc2b7d2dcbbab8f3d846bcff45ee0 /core/applets/batteryapplet/batterystatus.cpp | |
parent | 81104f00cb87962333a024d3fa5ff6cf3d8d7d83 (diff) | |
download | opie-7a9cabb330284777113bb544139843dcf0593628.zip opie-7a9cabb330284777113bb544139843dcf0593628.tar.gz opie-7a9cabb330284777113bb544139843dcf0593628.tar.bz2 |
the "bett ery" commit, batteryapplet is now a popup, only shows second battery on ipaq if a second battery is present
Diffstat (limited to 'core/applets/batteryapplet/batterystatus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 407 |
1 files changed, 206 insertions, 201 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index ab8f36d..655fdc4 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -11,3 +11,2 @@ | |||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qlayout.h> | ||
13 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
@@ -17,30 +16,14 @@ using namespace Opie::Core; | |||
17 | 16 | ||
18 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | 17 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f ) |
19 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { | 18 | : QFrame( parent, 0, f), ps(p), bat2(false) { |
20 | setCaption( tr("Battery status") ); | ||
21 | setMinimumSize( 150, 200 ); | ||
22 | 19 | ||
23 | QPushButton *pb = new QPushButton( tr("Close"), this ); | 20 | jackPercent = 0; |
24 | QVBoxLayout *layout = new QVBoxLayout ( this ); | ||
25 | 21 | ||
26 | jackPercent = 0; | 22 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
27 | 23 | getProcApmStatusIpaq(); | |
28 | pb->setMaximumSize( 120, 40 ); | 24 | } |
29 | 25 | percent = ps->batteryPercentRemaining(); | |
30 | pb->show(); | ||
31 | |||
32 | layout->addStretch(); | ||
33 | layout->addWidget( pb ); | ||
34 | |||
35 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | ||
36 | getProcApmStatusIpaq(); | ||
37 | } | ||
38 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); | ||
39 | percent = ps->batteryPercentRemaining(); | ||
40 | show(); | ||
41 | } | 26 | } |
42 | 27 | ||
43 | BatteryStatus::~BatteryStatus() | 28 | BatteryStatus::~BatteryStatus() {} |
44 | { | ||
45 | } | ||
46 | 29 | ||
@@ -51,69 +34,66 @@ bool BatteryStatus::getProcApmStatusIpaq() { | |||
51 | 34 | ||
52 | bat2 = false; | 35 | bat2 = false; |
53 | 36 | ||
54 | QFile procApmIpaq("/proc/hal/battery"); | 37 | QFile procApmIpaq("/proc/hal/battery"); |
55 | 38 | ||
56 | if (procApmIpaq.open(IO_ReadOnly) ) { | 39 | if (procApmIpaq.open(IO_ReadOnly) ) { |
57 | QStringList list; | 40 | QStringList list; |
58 | // since it is /proc we _must_ use QTextStream | 41 | // since it is /proc we _must_ use QTextStream |
59 | QTextStream stream ( &procApmIpaq); | 42 | QTextStream stream ( &procApmIpaq); |
60 | QString streamIn; | 43 | QString streamIn; |
61 | streamIn = stream.read(); | 44 | streamIn = stream.read(); |
62 | list = QStringList::split("\n", streamIn); | 45 | list = QStringList::split("\n", streamIn); |
63 | 46 | ||
64 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 47 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
65 | // not nice, need a rewrite later | 48 | // not nice, need a rewrite later |
66 | if( (*line).startsWith(" Percentage") ){ | 49 | if( (*line).startsWith(" Percentage") ) { |
67 | if (bat2 == true) { | 50 | if (bat2 == true) { |
68 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 51 | perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2); |
52 | } else { | ||
53 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | ||
54 | } | ||
55 | } else if( (*line).startsWith(" Life") ) { | ||
56 | if (bat2 == true) { | ||
57 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); | ||
58 | } else { | ||
59 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); | ||
60 | } | ||
61 | } else if( (*line).startsWith("Battery #1") ) { | ||
62 | bat2 = true; | ||
63 | } else if( (*line).startsWith(" Status") ) { | ||
64 | if (bat2 == true) { | ||
65 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | ||
66 | } else { | ||
67 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | ||
68 | } | ||
69 | } else if( (*line).startsWith(" Chemistry") ) { | ||
70 | if (bat2 == true) { | ||
71 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | ||
72 | } else { | ||
73 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | ||
74 | } | ||
75 | } | ||
76 | } | ||
69 | } else { | 77 | } else { |
70 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 78 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); |
71 | } | 79 | } |
72 | }else if( (*line).startsWith(" Life") ){ | 80 | |
73 | if (bat2 == true) { | 81 | procApmIpaq.close(); |
74 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); | 82 | jackPercent = perc2.toInt(); |
83 | ipaqPercent = perc1.toInt(); | ||
84 | |||
85 | if (perc2.isEmpty()) { | ||
86 | perc2 = tr("no data"); | ||
75 | } else { | 87 | } else { |
76 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); | 88 | perc2 += " %"; |
77 | } | 89 | } |
78 | }else if( (*line).startsWith("Battery #1") ){ | 90 | |
79 | bat2 = true; | 91 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { |
80 | }else if( (*line).startsWith(" Status") ){ | 92 | sec2 = tr("no data"); |
81 | if (bat2 == true) { | ||
82 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | ||
83 | } else { | ||
84 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | ||
85 | } | ||
86 | }else if( (*line).startsWith(" Chemistry") ) { | ||
87 | if (bat2 == true) { | ||
88 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | ||
89 | } else { | 93 | } else { |
90 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 94 | sec2 += " min"; |
91 | } | 95 | } |
92 | } | ||
93 | } | ||
94 | } else { | ||
95 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); | ||
96 | } | ||
97 | |||
98 | procApmIpaq.close(); | ||
99 | |||
100 | jackPercent = perc2.toInt(); | ||
101 | ipaqPercent = perc1.toInt(); | ||
102 | |||
103 | if (perc2.isEmpty()) { | ||
104 | perc2 = tr("no data"); | ||
105 | } else { | ||
106 | perc2 += " %"; | ||
107 | } | ||
108 | |||
109 | |||
110 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { | ||
111 | sec2 = tr("no data"); | ||
112 | } else { | ||
113 | sec2 += " min"; | ||
114 | } | ||
115 | |||
116 | jackStatus == (" ( " + jackStatus + " )"); | ||
117 | 96 | ||
118 | return true; | 97 | jackStatus == (" ( " + jackStatus + " )"); |
98 | return true; | ||
119 | } | 99 | } |
@@ -122,4 +102,4 @@ bool BatteryStatus::getProcApmStatusIpaq() { | |||
122 | void BatteryStatus::updatePercent( int pc ) { | 102 | void BatteryStatus::updatePercent( int pc ) { |
123 | percent = pc; | 103 | percent = pc; |
124 | repaint(FALSE); | 104 | repaint(FALSE); |
125 | } | 105 | } |
@@ -127,125 +107,150 @@ void BatteryStatus::updatePercent( int pc ) { | |||
127 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { | 107 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { |
128 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; | 108 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; |
129 | topgrad.hsv( &h1, &s1, &v1 ); | 109 | topgrad.hsv( &h1, &s1, &v1 ); |
130 | botgrad.hsv( &h2, &s2, &v2 ); | 110 | botgrad.hsv( &h2, &s2, &v2 ); |
131 | for ( int j = 0; j < hy-2; j++ ) { | 111 | for ( int j = 0; j < hy-2; j++ ) { |
132 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 112 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
133 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 113 | 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 ); | 114 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); |
135 | } | 115 | } |
136 | for ( int j = 0; j < hh; j++ ) { | 116 | for ( int j = 0; j < hh; j++ ) { |
137 | p->setPen( highlight ); | 117 | p->setPen( highlight ); |
138 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); | 118 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); |
119 | } | ||
120 | for ( int j = 0; j < ng-hy-hh; j++ ) { | ||
121 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | ||
122 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | ||
123 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); | ||
139 | } | 124 | } |
140 | for ( int j = 0; j < ng-hy-hh; j++ ) { | ||
141 | 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 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); | ||
144 | } | ||
145 | } | 125 | } |
146 | 126 | ||
147 | void BatteryStatus::paintEvent( QPaintEvent * ) { | 127 | QString BatteryStatus::statusText() const { |
128 | QString text; | ||
148 | 129 | ||
149 | QPainter p(this); | 130 | if ( ps->batteryStatus() == PowerStatus::Charging ) { |
150 | QString text; | ||
151 | if ( ps->batteryStatus() == PowerStatus::Charging ) { | ||
152 | if (bat2) { | 131 | if (bat2) { |
153 | text = tr("Charging both devices"); | 132 | text = tr("Charging both devices"); |
154 | } else { | 133 | } else { |
155 | text = tr("Charging"); | 134 | text = tr("Charging"); |
156 | } | 135 | } |
157 | } else if ( ps->batteryPercentAccurate() ) { | 136 | } else if ( ps->batteryPercentAccurate() ) { |
158 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); | 137 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); |
159 | } else { | 138 | } else { |
160 | text = tr("Battery status: "); | 139 | text = tr("Battery status: "); |
161 | switch ( ps->batteryStatus() ) { | 140 | switch ( ps->batteryStatus() ) { |
162 | case PowerStatus::High: | 141 | case PowerStatus::High: |
163 | text += tr("Good"); | 142 | text += tr("Good"); |
164 | break; | 143 | break; |
165 | case PowerStatus::Low: | 144 | case PowerStatus::Low: |
166 | text += tr("Low"); | 145 | text += tr("Low"); |
167 | break; | 146 | break; |
168 | case PowerStatus::VeryLow: | 147 | case PowerStatus::VeryLow: |
169 | text += tr("Very Low"); | 148 | text += tr("Very Low"); |
170 | break; | 149 | break; |
171 | case PowerStatus::Critical: | 150 | case PowerStatus::Critical: |
172 | text += tr("Critical"); | 151 | text += tr("Critical"); |
173 | break; | 152 | break; |
174 | default: // NotPresent, etc. | 153 | default: // NotPresent, etc. |
175 | text += tr("Unknown"); | 154 | text += tr("Unknown"); |
155 | } | ||
176 | } | 156 | } |
177 | } | ||
178 | p.drawText( 10, 90, text ); | ||
179 | |||
180 | if ( ps->acStatus() == PowerStatus::Backup ) | ||
181 | p.drawText( 10, 110, tr("On backup power") ); | ||
182 | else if ( ps->acStatus() == PowerStatus::Online ) | ||
183 | p.drawText( 10, 110, tr("Power on-line") ); | ||
184 | else if ( ps->acStatus() == PowerStatus::Offline ) | ||
185 | p.drawText( 10, 110, tr("External power disconnected") ); | ||
186 | |||
187 | if ( ps->batteryTimeRemaining() >= 0 ) { | ||
188 | text.sprintf( tr("Battery time remaining") + ": %im %02is", | ||
189 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); | ||
190 | p.drawText( 10, 130, text ); | ||
191 | } | ||
192 | |||
193 | QColor c; | ||
194 | QColor darkc; | ||
195 | QColor lightc; | ||
196 | if ( ps->acStatus() == PowerStatus::Offline ) { | ||
197 | c = blue.light(120); | ||
198 | darkc = c.dark(280); | ||
199 | lightc = c.light(145); | ||
200 | } else if ( ps->acStatus() == PowerStatus::Online ) { | ||
201 | c = green.dark(130); | ||
202 | darkc = c.dark(200); | ||
203 | lightc = c.light(220); | ||
204 | } else { | ||
205 | c = red; | ||
206 | darkc = c.dark(280); | ||
207 | lightc = c.light(140); | ||
208 | } | ||
209 | if ( percent < 0 ) | ||
210 | return; | ||
211 | |||
212 | int rightEnd1 = width() - 47; | ||
213 | int rightEnd2 = width() - 35; | ||
214 | int percent2 = (percent * rightEnd1) / 100; | ||
215 | p.setPen( black ); | ||
216 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); | ||
217 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); | ||
218 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); | ||
219 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); | ||
220 | drawSegment( &p, QRect( rightEnd2, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); | ||
221 | p.setPen( black); | ||
222 | |||
223 | |||
224 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | ||
225 | |||
226 | p.drawText(15, 50, tr ("Ipaq ") + ipaqChem); | ||
227 | |||
228 | QString jacketMsg; | ||
229 | if (bat2) { | ||
230 | p.setPen(black); | ||
231 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); | ||
232 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); | ||
233 | jacketMsg = tr("Jacket ") + jackChem; | ||
234 | } else { | ||
235 | jackPercent = 0; | ||
236 | jacketMsg = tr("No jacket with battery inserted"); | ||
237 | } | ||
238 | |||
239 | int jackPerc = ( jackPercent * ( width() - 47 ) ) / 100; | ||
240 | |||
241 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); | ||
242 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); | ||
243 | drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); | ||
244 | drawSegment( &p, QRect( 11 + jackPerc, 160, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); | ||
245 | drawSegment( &p, QRect( rightEnd2, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); | ||
246 | p.setPen( black ); | ||
247 | p.drawText(15, 180, jacketMsg); | ||
248 | } | ||
249 | 157 | ||
158 | if ( ps->acStatus() == PowerStatus::Backup ) | ||
159 | text += "\n" + tr("On backup power"); | ||
160 | else if ( ps->acStatus() == PowerStatus::Online ) | ||
161 | text += "\n" + tr("Power on-line"); | ||
162 | else if ( ps->acStatus() == PowerStatus::Offline ) | ||
163 | text += "\n" + tr("External power disconnected"); | ||
164 | |||
165 | if ( ps->batteryTimeRemaining() >= 0 ) { | ||
166 | text += "\n" + QString().sprintf( tr("Battery time remaining") + ": %im %02is", | ||
167 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); | ||
168 | } | ||
169 | return text; | ||
170 | } | ||
171 | |||
172 | QString BatteryStatus::statusTextIpaq() const { | ||
173 | QString text; | ||
174 | text += tr("Percentage battery remaining: ") + perc2 + " " + jackStatus; | ||
175 | text += "\n" + tr("Battery time remaining: ") + sec2; | ||
176 | return text; | ||
177 | } | ||
178 | |||
179 | void BatteryStatus::paintEvent( QPaintEvent * ) { | ||
180 | |||
181 | QPainter p( this ); | ||
182 | |||
183 | QString text = statusText(); | ||
184 | p.drawText( 10, 50, width() - 20, 40 , AlignVCenter, text ); | ||
185 | |||
186 | QColor c; | ||
187 | QColor darkc; | ||
188 | QColor lightc; | ||
189 | if ( ps->acStatus() == PowerStatus::Offline ) { | ||
190 | c = blue.light(120); | ||
191 | darkc = c.dark(280); | ||
192 | lightc = c.light(145); | ||
193 | } else if ( ps->acStatus() == PowerStatus::Online ) { | ||
194 | c = green.dark(130); | ||
195 | darkc = c.dark(200); | ||
196 | lightc = c.light(220); | ||
197 | } else { | ||
198 | c = red; | ||
199 | darkc = c.dark(280); | ||
200 | lightc = c.light(140); | ||
201 | } | ||
202 | if ( percent < 0 ) | ||
203 | return; | ||
204 | |||
205 | int rightEnd1 = width() - 47; | ||
206 | int rightEnd2 = width() - 35; | ||
207 | int percent2 = (percent * rightEnd1) / 100; | ||
208 | p.setPen( black ); | ||
209 | qDrawShadePanel( &p, 9, 10, rightEnd1 , 39, 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 ); | ||
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 ); | ||
214 | p.setPen( black); | ||
215 | |||
216 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ && bat2 ) { | ||
217 | |||
218 | p.drawText( 15, 30, tr ("Ipaq ") + ipaqChem ); | ||
219 | |||
220 | QString jacketMsg; | ||
221 | if (bat2) { | ||
222 | p.setPen(black); | ||
223 | QString text = statusTextIpaq(); | ||
224 | p.drawText( 10, 150, text ); | ||
225 | jacketMsg = tr("Jacket ") + jackChem; | ||
226 | } else { | ||
227 | jackPercent = 0; | ||
228 | jacketMsg = tr("No jacket with battery inserted"); | ||
229 | } | ||
230 | |||
231 | int jackPerc = ( jackPercent * ( width() - 47 ) ) / 100; | ||
232 | |||
233 | qDrawShadePanel( &p, 9, 90, rightEnd1, 39, 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 ); | ||
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 ); | ||
238 | p.setPen( black ); | ||
239 | p.drawText(15, 100, width() - 20, 20 , AlignVCenter, jacketMsg); | ||
240 | } | ||
250 | } | 241 | } |
251 | 242 | ||
243 | QSize BatteryStatus::sizeHint() const { | ||
244 | QString text = statusText(); | ||
245 | QString text2 = statusTextIpaq(); | ||
246 | QFontMetrics fm = fontMetrics(); | ||
247 | QRect r=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text ); | ||
248 | QRect r2=fm.boundingRect( 10, 0, width(), height(), AlignVCenter, text2 ); | ||
249 | |||
250 | if ( bat2 ) { | ||
251 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), | ||
252 | r.width() ), 2 * 10 + 80 + r.height() + r2.height() ); | ||
253 | } | ||
254 | return QSize( QMAX( QMIN( 200, qApp->desktop()->width() ), | ||
255 | r.width() ), 2 * 10 + 40 + r.height() ); | ||
256 | } | ||