summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 078ce8d..480d261 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -101,50 +101,60 @@ void BatteryMeter::timerEvent( QTimerEvent * )
101 if ( batteryView ) 101 if ( batteryView )
102 batteryView->repaint(); 102 batteryView->repaint();
103 } 103 }
104} 104}
105 105
106void BatteryMeter::chargeTimeout() 106void BatteryMeter::chargeTimeout()
107{ 107{
108 percent += 20; 108 percent += 20;
109 if ( percent > 100 ) 109 if ( percent > 100 )
110 percent = 0; 110 percent = 0;
111 111
112 repaint(FALSE); 112 repaint(FALSE);
113 if ( batteryView ) 113 if ( batteryView )
114 batteryView->updatePercent( percent ); 114 batteryView->updatePercent( percent );
115} 115}
116 116
117void BatteryMeter::paintEvent( QPaintEvent* ) 117void BatteryMeter::paintEvent( QPaintEvent* )
118{ 118{
119 if ( style == 1 ) 119 if ( style == 1 )
120 { 120 {
121 QPainter p(this); 121 QPainter p(this);
122 QFont f( "Fixed", AppLnk::smallIconSize()/2 ); 122 QFont f( "Fixed", AppLnk::smallIconSize()/2 );
123 QFontMetrics fm( f ); 123 QFontMetrics fm( f );
124 p.setFont( f ); 124 p.setFont( f );
125 p.drawText( 0, AppLnk::smallIconSize()/2, QString::number( percent ) ); 125 if ( percent > 98 ) {
126 p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" ); 126 p.drawText( 0, 0, width(), height(), Qt::AlignCenter, tr( "F" ) );
127 }
128 else if ( percent < 5 )
129 {
130 p.drawText( 0, 0, width(), height(), Qt::AlignCenter, tr( "E" ) );
131 }
132 else
133 {
134 p.drawText( 0, AppLnk::smallIconSize()/2, QString::number( percent ) );
135 p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" );
136 }
127 return; 137 return;
128 } 138 }
129 139
130 QPainter p(this); 140 QPainter p(this);
131 QColor color; 141 QColor color;
132 QColor g = gray.light( 160 ); 142 QColor g = gray.light( 160 );
133 switch ( ps->acStatus() ) 143 switch ( ps->acStatus() )
134 { 144 {
135 case PowerStatus::Offline: color = blue.light( 150 ); break; 145 case PowerStatus::Offline: color = blue.light( 150 ); break;
136 case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; 146 case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break;
137 default: color = red.light( 160 ); 147 default: color = red.light( 160 );
138 } 148 }
139 149
140 int w = height() / 2; 150 int w = height() / 2;
141 if ( !(w%2) ) w--; // should have an odd value to get a real middle line 151 if ( !(w%2) ) w--; // should have an odd value to get a real middle line
142 int h = height() - 4; 152 int h = height() - 4;
143 int pix = (percent * h) / 100; 153 int pix = (percent * h) / 100;
144 int y2 = height() -2; 154 int y2 = height() -2;
145 int y = y2 - pix; 155 int y = y2 - pix;
146 int x1 = (width() - w ) / 2; 156 int x1 = (width() - w ) / 2;
147 157
148 p.setPen(QColor(80,80,80)); 158 p.setPen(QColor(80,80,80));
149 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header 159 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header
150 p.drawRect(x1,1,w,height()-1); // corpus 160 p.drawRect(x1,1,w,height()-1); // corpus