summaryrefslogtreecommitdiff
path: root/core
authormickeyl <mickeyl>2006-06-01 11:26:26 (UTC)
committer mickeyl <mickeyl>2006-06-01 11:26:26 (UTC)
commitdd618abb56ba6dec2f4c76548d264d2a68660e0d (patch) (side-by-side diff)
tree528babbeff43924711d266c5cab078cfc88d3b37 /core
parent4ec617a0fa1c44f5527ae7eff176cf8451d9973c (diff)
downloadopie-dd618abb56ba6dec2f4c76548d264d2a68660e0d.zip
opie-dd618abb56ba6dec2f4c76548d264d2a68660e0d.tar.gz
opie-dd618abb56ba6dec2f4c76548d264d2a68660e0d.tar.bz2
improve support for ipaqs
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/batterystatus.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp
index 08ddc85..9622726 100644
--- a/core/applets/batteryapplet/batterystatus.cpp
+++ b/core/applets/batteryapplet/batterystatus.cpp
@@ -37,101 +37,99 @@ void BatteryStatus::UpdateBatteryStatus() {
* Make use of the advanced apm interface of the ipaq
*/
bool BatteryStatus::getProcApmStatusIpaq() {
bat2 = false;
QFile procApmIpaq("/proc/hal/battery");
if (procApmIpaq.open(IO_ReadOnly) ) {
QStringList list;
// since it is /proc we _must_ use QTextStream
QTextStream stream ( &procApmIpaq);
QString streamIn;
streamIn = stream.read();
list = QStringList::split("\n", streamIn);
sec2 = sec1 = "";
for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
// not nice, need a rewrite later
if( (*line).startsWith(" Percentage") ) {
if (bat2 == true) {
perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2);
} else {
perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2);
}
} else if( (*line).startsWith(" Life") ) {
if (bat2 == true) {
sec2 = (*line).mid(((*line).find(':')+2), 5 );
} else {
sec1 = (*line).mid(((*line).find(':')+2), 5 );
}
} else if( (*line).startsWith("Battery #1") ) {
bat2 = true;
} else if( (*line).startsWith(" Status") ) {
if (bat2 == true) {
jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
} else {
ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
}
} else if( (*line).startsWith(" Chemistry") ) {
if (bat2 == true) {
jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);
} else {
ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);
}
}
}
- } else {
- QMessageBox::warning(this, tr("Failure"),tr("could not open file"));
+ procApmIpaq.close();
}
- procApmIpaq.close();
jackPercent = perc2.toInt();
ipaqPercent = perc1.toInt();
if (perc2.isEmpty() || perc2 == "unknow" ) {
perc2 = tr("no data");
} else {
perc2 += " %";
}
if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) {
sec2 = tr("no data");
} else {
sec2 += " min";
}
jackStatus.prepend( " ( " );
jackStatus.append( " )" );
return true;
}
void BatteryStatus::updatePercent( int pc ) {
percent = pc;
repaint(FALSE);
}
void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) {
int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height;
topgrad.hsv( &h1, &s1, &v1 );
botgrad.hsv( &h2, &s2, &v2 );
for ( int j = 0; j < hy-2; j++ ) {
p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j );
}
for ( int j = 0; j < hh; j++ ) {
p->setPen( highlight );
p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j );
}
for ( int j = 0; j < ng-hy-hh; j++ ) {
p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j );
}
}
QString BatteryStatus::statusText() const {
QString text;