author | mickeyl <mickeyl> | 2003-05-10 17:20:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-10 17:20:32 (UTC) |
commit | d563040b1ccf4678f056626525d605e8bcba07ef (patch) (unidiff) | |
tree | c36b8e48c5fe2df876769315843d9e60f0931c79 | |
parent | e858fffe853c2893775c202c52ba1d4898e723bc (diff) | |
download | opie-d563040b1ccf4678f056626525d605e8bcba07ef.zip opie-d563040b1ccf4678f056626525d605e8bcba07ef.tar.gz opie-d563040b1ccf4678f056626525d605e8bcba07ef.tar.bz2 |
do a full repaint if style != 0
-rw-r--r-- | core/applets/batteryapplet/battery.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index eee3ed3..078ce8d 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp | |||
@@ -33,100 +33,100 @@ BatteryMeter::BatteryMeter( QWidget *parent ) | |||
33 | : QWidget( parent ), charging(false) | 33 | : QWidget( parent ), charging(false) |
34 | { | 34 | { |
35 | ps = new PowerStatus; | 35 | ps = new PowerStatus; |
36 | startTimer( 10000 ); | 36 | startTimer( 10000 ); |
37 | setFixedHeight( AppLnk::smallIconSize() ); | 37 | setFixedHeight( AppLnk::smallIconSize() ); |
38 | chargeTimer = new QTimer( this ); | 38 | chargeTimer = new QTimer( this ); |
39 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); | 39 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); |
40 | timerEvent(0); | 40 | timerEvent(0); |
41 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 41 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
42 | Config c( "qpe" ); | 42 | Config c( "qpe" ); |
43 | c.setGroup( "Battery" ); | 43 | c.setGroup( "Battery" ); |
44 | style = c.readNumEntry( "Style", 0 ); | 44 | style = c.readNumEntry( "Style", 0 ); |
45 | } | 45 | } |
46 | 46 | ||
47 | BatteryMeter::~BatteryMeter() | 47 | BatteryMeter::~BatteryMeter() |
48 | { | 48 | { |
49 | delete ps; | 49 | delete ps; |
50 | } | 50 | } |
51 | 51 | ||
52 | QSize BatteryMeter::sizeHint() const | 52 | QSize BatteryMeter::sizeHint() const |
53 | { | 53 | { |
54 | return QSize(10, height() ); | 54 | return QSize(10, height() ); |
55 | } | 55 | } |
56 | 56 | ||
57 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) | 57 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) |
58 | { | 58 | { |
59 | if ( e->button() == RightButton ) | 59 | if ( e->button() == RightButton ) |
60 | { | 60 | { |
61 | style = 1-style; | 61 | style = 1-style; |
62 | Config c( "qpe" ); | 62 | Config c( "qpe" ); |
63 | c.setGroup( "Battery" ); | 63 | c.setGroup( "Battery" ); |
64 | c.writeEntry( "Style", style ); | 64 | c.writeEntry( "Style", style ); |
65 | repaint(); | 65 | repaint( true ); |
66 | } | 66 | } |
67 | QWidget::mousePressEvent( e ); | 67 | QWidget::mousePressEvent( e ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) | 70 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) |
71 | { | 71 | { |
72 | if ( batteryView && batteryView->isVisible() ) { | 72 | if ( batteryView && batteryView->isVisible() ) { |
73 | delete (QWidget *) batteryView; | 73 | delete (QWidget *) batteryView; |
74 | } else { | 74 | } else { |
75 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); | 75 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); |
76 | batteryView->showMaximized(); | 76 | batteryView->showMaximized(); |
77 | batteryView->raise(); | 77 | batteryView->raise(); |
78 | batteryView->show(); | 78 | batteryView->show(); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | void BatteryMeter::timerEvent( QTimerEvent * ) | 82 | void BatteryMeter::timerEvent( QTimerEvent * ) |
83 | { | 83 | { |
84 | PowerStatus prev = *ps; | 84 | PowerStatus prev = *ps; |
85 | 85 | ||
86 | *ps = PowerStatusManager::readStatus(); | 86 | *ps = PowerStatusManager::readStatus(); |
87 | 87 | ||
88 | if ( prev != *ps ) { | 88 | if ( prev != *ps ) { |
89 | percent = ps->batteryPercentRemaining(); | 89 | percent = ps->batteryPercentRemaining(); |
90 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { | 90 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { |
91 | percent = 0; | 91 | percent = 0; |
92 | charging = true; | 92 | charging = true; |
93 | chargeTimer->start( 500 ); | 93 | chargeTimer->start( 500 ); |
94 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { | 94 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { |
95 | charging = false; | 95 | charging = false; |
96 | chargeTimer->stop(); | 96 | chargeTimer->stop(); |
97 | if ( batteryView ) | 97 | if ( batteryView ) |
98 | batteryView->updatePercent( percent ); | 98 | batteryView->updatePercent( percent ); |
99 | } | 99 | } |
100 | repaint(FALSE); | 100 | repaint( style != 0 ); |
101 | if ( batteryView ) | 101 | if ( batteryView ) |
102 | batteryView->repaint(); | 102 | batteryView->repaint(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void BatteryMeter::chargeTimeout() | 106 | void 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 | ||
117 | void BatteryMeter::paintEvent( QPaintEvent* ) | 117 | void 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 | p.drawText( 0, AppLnk::smallIconSize()/2, QString::number( percent ) ); |
126 | p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" ); | 126 | p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" ); |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | 129 | ||
130 | QPainter p(this); | 130 | QPainter p(this); |
131 | QColor color; | 131 | QColor color; |
132 | QColor g = gray.light( 160 ); | 132 | QColor g = gray.light( 160 ); |