summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp8
-rw-r--r--core/applets/batteryapplet/batterystatus.cpp75
2 files changed, 40 insertions, 43 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 3b64fb5..9a9ddf6 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -69,9 +69,9 @@ void BatteryMeter::mousePressEvent( QMouseEvent* e )
69 } 69 }
70 QWidget::mousePressEvent( e ); 70 QWidget::mousePressEvent( e );
71} 71}
72 72
73void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) 73void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ )
74{ 74{
75 if ( batteryView && batteryView->isVisible() ) { 75 if ( batteryView && batteryView->isVisible() ) {
76 delete (QWidget *) batteryView; 76 delete (QWidget *) batteryView;
77 } else { 77 } else {
@@ -109,13 +109,13 @@ void BatteryMeter::timerEvent( QTimerEvent * )
109void BatteryMeter::chargeTimeout() 109void BatteryMeter::chargeTimeout()
110{ 110{
111 percent += 20; 111 percent += 20;
112 if ( percent > 100 ) 112 if ( percent > 100 )
113 percent = 0; 113 percent = 0;
114 114
115 repaint(FALSE); 115 repaint(FALSE);
116 if ( batteryView ) 116 if ( batteryView )
117 batteryView->updatePercent( percent ); 117 batteryView->updatePercent( percent );
118} 118}
119 119
120void BatteryMeter::paintEvent( QPaintEvent* ) 120void BatteryMeter::paintEvent( QPaintEvent* )
121{ 121{
@@ -153,9 +153,9 @@ void BatteryMeter::paintEvent( QPaintEvent* )
153 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header 153 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header
154 p.drawRect(x1,1,w,height()-1); // corpus 154 p.drawRect(x1,1,w,height()-1); // corpus
155 p.setBrush(color); 155 p.setBrush(color);
156 156
157 int extra = ((percent * h) % 100)/(100/4); 157 //int extra = ((percent * h) % 100)/(100/4);
158 158
159 int middle = w/2; 159 int middle = w/2;
160 for ( int i = 0; i < middle; i++ ) 160 for ( int i = 0; i < middle; i++ )
161 { 161 {
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp
index 64e0499..86b20e8 100644
--- a/core/applets/batteryapplet/batterystatus.cpp
+++ b/core/applets/batteryapplet/batterystatus.cpp
@@ -18,19 +18,20 @@ using namespace Opie;
18 18
19BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) 19BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent )
20 : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { 20 : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) {
21 setCaption( tr("Battery status") ); 21 setCaption( tr("Battery status") );
22 setMinimumSize( 150, 200 );
23
22 QPushButton *pb = new QPushButton( tr("Close"), this ); 24 QPushButton *pb = new QPushButton( tr("Close"), this );
23 QVBoxLayout *layout = new QVBoxLayout ( this ); 25 QVBoxLayout *layout = new QVBoxLayout ( this );
24 26
25 jackPercent = 0; 27 jackPercent = 0;
26 28
27 pb->setMaximumHeight(40); 29 pb->setMaximumSize( 120, 40 );
28 pb->setMaximumWidth( 120 );
29 30
30 pb->show(); 31 pb->show();
31 32
32 layout->addStretch( 0 ); 33 layout->addStretch();
33 layout->addWidget( pb ); 34 layout->addWidget( pb );
34 35
35 if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { 36 if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
36 getProcApmStatusIpaq(); 37 getProcApmStatusIpaq();
@@ -63,33 +64,33 @@ bool BatteryStatus::getProcApmStatusIpaq() {
63 64
64 for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { 65 for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
65 // not nice, need a rewrite later 66 // not nice, need a rewrite later
66 if( (*line).startsWith(" Percentage") ){ 67 if( (*line).startsWith(" Percentage") ){
67 if (bat2 == true) { 68 if (bat2 == true) {
68 perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); 69 perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2);
69 } else { 70 } else {
70 perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); 71 perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2);
71 } 72 }
72 }else if( (*line).startsWith(" Life") ){ 73 }else if( (*line).startsWith(" Life") ){
73 if (bat2 == true) { 74 if (bat2 == true) {
74 sec2 = (*line).mid(((*line).find(':')+2), 5 ); 75 sec2 = (*line).mid(((*line).find(':')+2), 5 );
75 } else { 76 } else {
76 sec1 = (*line).mid(((*line).find(':')+2), 5 ); 77 sec1 = (*line).mid(((*line).find(':')+2), 5 );
77 } 78 }
78 }else if( (*line).startsWith("Battery #1") ){ 79 }else if( (*line).startsWith("Battery #1") ){
79 bat2 = true; 80 bat2 = true;
80 }else if( (*line).startsWith(" Status") ){ 81 }else if( (*line).startsWith(" Status") ){
81 if (bat2 == true) { 82 if (bat2 == true) {
82 jackStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); 83 jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
83 } else { 84 } else {
84 ipaqStatus = (*line).mid((*line).find('(')+1., (*line).find(')')-(*line).find('(')-1); 85 ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
85 } 86 }
86 }else if( (*line).startsWith(" Chemistry") ) { 87 }else if( (*line).startsWith(" Chemistry") ) {
87 if (bat2 == true) { 88 if (bat2 == true) {
88 jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); 89 jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);
89 } else { 90 } else {
90 ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); 91 ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);
91 } 92 }
92 } 93 }
93 } 94 }
94 } else { 95 } else {
95 QMessageBox::warning(this, tr("Failure"),tr("could not open file")); 96 QMessageBox::warning(this, tr("Failure"),tr("could not open file"));
@@ -129,36 +130,32 @@ void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topg
129 topgrad.hsv( &h1, &s1, &v1 ); 130 topgrad.hsv( &h1, &s1, &v1 );
130 botgrad.hsv( &h2, &s2, &v2 ); 131 botgrad.hsv( &h2, &s2, &v2 );
131 for ( int j = 0; j < hy-2; j++ ) { 132 for ( int j = 0; j < hy-2; j++ ) {
132 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), 133 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
133 v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); 134 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 ); 135 p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j );
135 } 136 }
136 for ( int j = 0; j < hh; j++ ) { 137 for ( int j = 0; j < hh; j++ ) {
137 p->setPen( highlight ); 138 p->setPen( highlight );
138 p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); 139 p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j );
139 } 140 }
140 for ( int j = 0; j < ng-hy-hh; j++ ) { 141 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 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 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 p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j );
144 } 145 }
145} 146}
146 147
147void BatteryStatus::paintEvent( QPaintEvent * ) { 148void BatteryStatus::paintEvent( QPaintEvent * ) {
148 149
149
150 int screenWidth = qApp->desktop()->width();
151 int screenHeight = qApp->desktop()->height();
152
153 QPainter p(this); 150 QPainter p(this);
154 QString text; 151 QString text;
155 if ( ps->batteryStatus() == PowerStatus::Charging ) { 152 if ( ps->batteryStatus() == PowerStatus::Charging ) {
156 if (bat2) { 153 if (bat2) {
157 text = tr("Charging both devices"); 154 text = tr("Charging both devices");
158 } else { 155 } else {
159 text = tr("Charging"); 156 text = tr("Charging");
160 } 157 }
161 } else if ( ps->batteryPercentAccurate() ) { 158 } else if ( ps->batteryPercentAccurate() ) {
162 text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); 159 text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent );
163 } else { 160 } else {
164 text = tr("Battery status: "); 161 text = tr("Battery status: ");
@@ -189,9 +186,9 @@ void BatteryStatus::paintEvent( QPaintEvent * ) {
189 p.drawText( 10, 110, tr("External power disconnected") ); 186 p.drawText( 10, 110, tr("External power disconnected") );
190 187
191 if ( ps->batteryTimeRemaining() >= 0 ) { 188 if ( ps->batteryTimeRemaining() >= 0 ) {
192 text.sprintf( tr("Battery time remaining") + ": %im %02is", 189 text.sprintf( tr("Battery time remaining") + ": %im %02is",
193 ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); 190 ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 );
194 p.drawText( 10, 130, text ); 191 p.drawText( 10, 130, text );
195 } 192 }
196 193
197 QColor c; 194 QColor c;
@@ -212,11 +209,11 @@ void BatteryStatus::paintEvent( QPaintEvent * ) {
212 } 209 }
213 if ( percent < 0 ) 210 if ( percent < 0 )
214 return; 211 return;
215 212
216 int rightEnd1 = screenWidth - 47; 213 int rightEnd1 = width() - 47;
217 int rightEnd2 = screenWidth - 35; 214 int rightEnd2 = width() - 35;
218 int percent2 = ( percent / 100.0 ) * rightEnd1 ; 215 int percent2 = ( percent / 100 ) * rightEnd1 ;
219 p.setPen( black ); 216 p.setPen( black );
220 qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); 217 qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL);
221 qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); 218 qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL);
222 drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); 219 drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 );
@@ -239,9 +236,9 @@ void BatteryStatus::paintEvent( QPaintEvent * ) {
239 jackPercent = 0; 236 jackPercent = 0;
240 jacketMsg = tr("No jacket with battery inserted"); 237 jacketMsg = tr("No jacket with battery inserted");
241 } 238 }
242 239
243 int jackPerc = ( jackPercent / 100.0 ) * ( screenWidth - 47 ) ; 240 int jackPerc = ( jackPercent / 100 ) * ( width() - 47 ) ;
244 241
245 qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); 242 qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL);
246 qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); 243 qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL);
247 drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); 244 drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 );