author | drw <drw> | 2004-02-18 16:23:17 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-18 16:23:17 (UTC) |
commit | 7d16774139aa40fb812d636bcf9ad3f45aa2b9e1 (patch) (unidiff) | |
tree | 51dc00c15db884b4f4351ed685e022853446a0d6 | |
parent | 45179e1807aa5ca024b423112303509f91253a53 (diff) | |
download | opie-7d16774139aa40fb812d636bcf9ad3f45aa2b9e1.zip opie-7d16774139aa40fb812d636bcf9ad3f45aa2b9e1.tar.gz opie-7d16774139aa40fb812d636bcf9ad3f45aa2b9e1.tar.bz2 |
Fix size and drawing of battery status widget and eliminate compiler warnings
-rw-r--r-- | core/applets/batteryapplet/battery.cpp | 4 | ||||
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 23 |
2 files changed, 12 insertions, 15 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 | |||
@@ -70,7 +70,7 @@ void BatteryMeter::mousePressEvent( QMouseEvent* e ) | |||
70 | QWidget::mousePressEvent( e ); | 70 | QWidget::mousePressEvent( e ); |
71 | } | 71 | } |
72 | 72 | ||
73 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) | 73 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) |
74 | { | 74 | { |
75 | if ( batteryView && batteryView->isVisible() ) { | 75 | if ( batteryView && batteryView->isVisible() ) { |
76 | delete (QWidget *) batteryView; | 76 | delete (QWidget *) batteryView; |
@@ -154,7 +154,7 @@ void BatteryMeter::paintEvent( QPaintEvent* ) | |||
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++ ) |
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 | |||
@@ -19,17 +19,18 @@ using namespace Opie; | |||
19 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | 19 | BatteryStatus::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 ) { |
@@ -79,9 +80,9 @@ bool BatteryStatus::getProcApmStatusIpaq() { | |||
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) { |
@@ -146,10 +147,6 @@ void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topg | |||
146 | 147 | ||
147 | void BatteryStatus::paintEvent( QPaintEvent * ) { | 148 | void 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 ) { |
@@ -213,9 +210,9 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
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); |
@@ -240,7 +237,7 @@ void BatteryStatus::paintEvent( QPaintEvent * ) { | |||
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); |