summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-03-23 23:00:35 (UTC)
committer kergoth <kergoth>2003-03-23 23:00:35 (UTC)
commit7849f269eb4bbabe807608cec26d1a0ee9d05868 (patch) (side-by-side diff)
tree887e4dd018e2fa92e03016d7d73c023f0371a7d9
parentaff270316219558bd00cbcc3ffc275213080fcd3 (diff)
downloadopie-7849f269eb4bbabe807608cec26d1a0ee9d05868.zip
opie-7849f269eb4bbabe807608cec26d1a0ee9d05868.tar.gz
opie-7849f269eb4bbabe807608cec26d1a0ee9d05868.tar.bz2
Use of bat2 bool uninitialized (when on zaurus) resulted
in display of "Charging both devices" which confused users. @@ -15,7 +15,7 @@ using namespace Opie; BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) - : QWidget( parent, 0, WDestructiveClose), ps(p) { + : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { setCaption( tr("Battery status") ); QPushButton *pb = new QPushButton( tr("Close"), this ); pb->move( 70, 250 );
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/batterystatus.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp
index 28d6275..7d3bdd9 100644
--- a/core/applets/batteryapplet/batterystatus.cpp
+++ b/core/applets/batteryapplet/batterystatus.cpp
@@ -1,114 +1,114 @@
#include "batterystatus.h"
#include <qpe/power.h>
#include <opie/odevice.h>
#include <qpainter.h>
#include <qpushbutton.h>
#include <qdrawutil.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qmessagebox.h>
using namespace Opie;
BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent )
- : QWidget( parent, 0, WDestructiveClose), ps(p) {
+ : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) {
setCaption( tr("Battery status") );
QPushButton *pb = new QPushButton( tr("Close"), this );
pb->move( 70, 250 );
pb->setMaximumHeight(20);
pb->show();
if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
getProcApmStatusIpaq();
}
connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) );
percent = ps->batteryPercentRemaining();
show();
}
BatteryStatus::~BatteryStatus()
{
}
/*
* 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);
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();
jackPercent = perc2.toInt();
ipaqPercent = perc1.toInt();
if (perc2.isEmpty()) {
perc2 = "no data";
} else {
perc2 += " %";
}
if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) {
sec2 = "no data";
} else {
sec2 += " min";
}
jackStatus == (" ( " + jackStatus + " )");
return true;
}
void BatteryStatus::updatePercent( int pc ) {
percent = pc;
repaint(FALSE);
}