author | mickeyl <mickeyl> | 2004-03-01 14:31:39 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-01 14:31:39 (UTC) |
commit | 2fbfc7e166235805294b932949f9a24b063d2199 (patch) (unidiff) | |
tree | 353ef0424c54f6443852863c87cdcbfeee696d1c | |
parent | 3cdec2fe5b3201a121cfbb2352162fe0cbae0a1d (diff) | |
download | opie-2fbfc7e166235805294b932949f9a24b063d2199.zip opie-2fbfc7e166235805294b932949f9a24b063d2199.tar.gz opie-2fbfc7e166235805294b932949f9a24b063d2199.tar.bz2 |
libopie1-->libopie2
-rw-r--r-- | core/applets/batteryapplet/battery.cpp | 13 | ||||
-rw-r--r-- | core/applets/batteryapplet/battery.h | 1 | ||||
-rw-r--r-- | core/applets/batteryapplet/batteryapplet.pro | 6 | ||||
-rw-r--r-- | core/applets/batteryapplet/batteryappletimpl.cpp | 65 | ||||
-rw-r--r-- | core/applets/batteryapplet/batteryappletimpl.h | 43 | ||||
-rw-r--r-- | core/applets/batteryapplet/batterystatus.cpp | 5 |
6 files changed, 20 insertions, 113 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index 9a9ddf6..fed9b34 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp | |||
@@ -1,91 +1,94 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "battery.h" | 20 | #include "battery.h" |
21 | #include "batterystatus.h" | 21 | #include "batterystatus.h" |
22 | 22 | ||
23 | /* OPIE */ | ||
24 | #include <opie2/otaskbarapplet.h> | ||
23 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
24 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
25 | #include <qpe/power.h> | 27 | #include <qpe/power.h> |
26 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
27 | 29 | ||
30 | /* QT */ | ||
28 | #include <qpainter.h> | 31 | #include <qpainter.h> |
29 | #include <qtimer.h> | 32 | #include <qtimer.h> |
30 | 33 | ||
31 | 34 | ||
32 | BatteryMeter::BatteryMeter( QWidget *parent ) | 35 | BatteryMeter::BatteryMeter( QWidget *parent ) |
33 | : QWidget( parent ), charging(false) | 36 | : QWidget( parent ), charging(false) |
34 | { | 37 | { |
35 | ps = new PowerStatus; | 38 | ps = new PowerStatus; |
36 | startTimer( 10000 ); | 39 | startTimer( 10000 ); |
37 | 40 | ||
38 | setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); | 41 | setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); |
39 | setFixedHeight( AppLnk::smallIconSize() ); | 42 | setFixedHeight( AppLnk::smallIconSize() ); |
40 | 43 | ||
41 | chargeTimer = new QTimer( this ); | 44 | chargeTimer = new QTimer( this ); |
42 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); | 45 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); |
43 | timerEvent(0); | 46 | timerEvent(0); |
44 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 47 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
45 | Config c( "qpe" ); | 48 | Config c( "qpe" ); |
46 | c.setGroup( "Battery" ); | 49 | c.setGroup( "Battery" ); |
47 | style = c.readNumEntry( "Style", 0 ); | 50 | style = c.readNumEntry( "Style", 0 ); |
48 | } | 51 | } |
49 | 52 | ||
50 | BatteryMeter::~BatteryMeter() | 53 | BatteryMeter::~BatteryMeter() |
51 | { | 54 | { |
52 | delete ps; | 55 | delete ps; |
53 | } | 56 | } |
54 | 57 | ||
55 | QSize BatteryMeter::sizeHint() const | 58 | QSize BatteryMeter::sizeHint() const |
56 | { | 59 | { |
57 | return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); | 60 | return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); |
58 | } | 61 | } |
59 | 62 | ||
60 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) | 63 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) |
61 | { | 64 | { |
62 | if ( e->button() == RightButton ) | 65 | if ( e->button() == RightButton ) |
63 | { | 66 | { |
64 | style = 1-style; | 67 | style = 1-style; |
65 | Config c( "qpe" ); | 68 | Config c( "qpe" ); |
66 | c.setGroup( "Battery" ); | 69 | c.setGroup( "Battery" ); |
67 | c.writeEntry( "Style", style ); | 70 | c.writeEntry( "Style", style ); |
68 | repaint( true ); | 71 | repaint( true ); |
69 | } | 72 | } |
70 | QWidget::mousePressEvent( e ); | 73 | QWidget::mousePressEvent( e ); |
71 | } | 74 | } |
72 | 75 | ||
73 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) | 76 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) |
74 | { | 77 | { |
75 | if ( batteryView && batteryView->isVisible() ) { | 78 | if ( batteryView && batteryView->isVisible() ) { |
76 | delete (QWidget *) batteryView; | 79 | delete (QWidget *) batteryView; |
77 | } else { | 80 | } else { |
78 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); | 81 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); |
79 | QPEApplication::showWidget( batteryView ); | 82 | QPEApplication::showWidget( batteryView ); |
80 | batteryView->raise(); | 83 | batteryView->raise(); |
81 | batteryView->show(); | 84 | batteryView->show(); |
82 | } | 85 | } |
83 | } | 86 | } |
84 | 87 | ||
85 | void BatteryMeter::timerEvent( QTimerEvent * ) | 88 | void BatteryMeter::timerEvent( QTimerEvent * ) |
86 | { | 89 | { |
87 | PowerStatus prev = *ps; | 90 | PowerStatus prev = *ps; |
88 | 91 | ||
89 | *ps = PowerStatusManager::readStatus(); | 92 | *ps = PowerStatusManager::readStatus(); |
90 | 93 | ||
91 | if ( prev != *ps ) { | 94 | if ( prev != *ps ) { |
@@ -107,64 +110,74 @@ void BatteryMeter::timerEvent( QTimerEvent * ) | |||
107 | } | 110 | } |
108 | 111 | ||
109 | void BatteryMeter::chargeTimeout() | 112 | void BatteryMeter::chargeTimeout() |
110 | { | 113 | { |
111 | percent += 20; | 114 | percent += 20; |
112 | if ( percent > 100 ) | 115 | if ( percent > 100 ) |
113 | percent = 0; | 116 | percent = 0; |
114 | 117 | ||
115 | repaint(FALSE); | 118 | repaint(FALSE); |
116 | if ( batteryView ) | 119 | if ( batteryView ) |
117 | batteryView->updatePercent( percent ); | 120 | batteryView->updatePercent( percent ); |
118 | } | 121 | } |
119 | 122 | ||
120 | void BatteryMeter::paintEvent( QPaintEvent* ) | 123 | void BatteryMeter::paintEvent( QPaintEvent* ) |
121 | { | 124 | { |
122 | 125 | ||
123 | if ( style == 1 ) | 126 | if ( style == 1 ) |
124 | { | 127 | { |
125 | QPainter p(this); | 128 | QPainter p(this); |
126 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); | 129 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); |
127 | QFontMetrics fm( f ); | 130 | QFontMetrics fm( f ); |
128 | p.setFont( f ); | 131 | p.setFont( f ); |
129 | p.drawText( 0, height()/2, QString::number( percent ) ); | 132 | p.drawText( 0, height()/2, QString::number( percent ) ); |
130 | p.drawText( width()/4, height(), "%" ); | 133 | p.drawText( width()/4, height(), "%" ); |
131 | return; | 134 | return; |
132 | } | 135 | } |
133 | 136 | ||
134 | QPainter p(this); | 137 | QPainter p(this); |
135 | QColor color; | 138 | QColor color; |
136 | QColor g = gray.light( 160 ); | 139 | QColor g = gray.light( 160 ); |
137 | switch ( ps->acStatus() ) | 140 | switch ( ps->acStatus() ) |
138 | { | 141 | { |
139 | case PowerStatus::Offline: color = blue.light( 150 ); break; | 142 | case PowerStatus::Offline: color = blue.light( 150 ); break; |
140 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; | 143 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; |
141 | default: color = red.light( 160 ); | 144 | default: color = red.light( 160 ); |
142 | } | 145 | } |
143 | 146 | ||
144 | int w = height() / 2; | 147 | int w = height() / 2; |
145 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line | 148 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line |
146 | int h = height() - 4; | 149 | int h = height() - 4; |
147 | int pix = (percent * h) / 100; | 150 | int pix = (percent * h) / 100; |
148 | int y2 = height() -2; | 151 | int y2 = height() -2; |
149 | int y = y2 - pix; | 152 | int y = y2 - pix; |
150 | int x1 = (width() - w ) / 2; | 153 | int x1 = (width() - w ) / 2; |
151 | 154 | ||
152 | p.setPen(QColor(80,80,80)); | 155 | p.setPen(QColor(80,80,80)); |
153 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header | 156 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header |
154 | p.drawRect(x1,1,w,height()-1); // corpus | 157 | p.drawRect(x1,1,w,height()-1); // corpus |
155 | p.setBrush(color); | 158 | p.setBrush(color); |
156 | 159 | ||
157 | //int extra = ((percent * h) % 100)/(100/4); | 160 | //int extra = ((percent * h) % 100)/(100/4); |
158 | 161 | ||
159 | int middle = w/2; | 162 | int middle = w/2; |
160 | for ( int i = 0; i < middle; i++ ) | 163 | for ( int i = 0; i < middle; i++ ) |
161 | { | 164 | { |
162 | p.setPen( gray.dark( 100+i*20 ) ); | 165 | p.setPen( gray.dark( 100+i*20 ) ); |
163 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); | 166 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); |
164 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); | 167 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); |
165 | p.setPen( color.dark( 100+i*20 ) ); | 168 | p.setPen( color.dark( 100+i*20 ) ); |
166 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); | 169 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); |
167 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); | 170 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); |
168 | } | 171 | } |
169 | } | 172 | } |
170 | 173 | ||
174 | int BatteryMeter::position() | ||
175 | { | ||
176 | return 8; | ||
177 | } | ||
178 | |||
179 | Q_EXPORT_INTERFACE() | ||
180 | { | ||
181 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<BatteryMeter> ); | ||
182 | } | ||
183 | |||
diff --git a/core/applets/batteryapplet/battery.h b/core/applets/batteryapplet/battery.h index c2d1216..622c083 100644 --- a/core/applets/batteryapplet/battery.h +++ b/core/applets/batteryapplet/battery.h | |||
@@ -1,57 +1,58 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef BATTERY_H | 20 | #ifndef BATTERY_H |
21 | #define BATTERY_H | 21 | #define BATTERY_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qguardedptr.h> | 24 | #include <qguardedptr.h> |
25 | 25 | ||
26 | class PowerStatus; | 26 | class PowerStatus; |
27 | class BatteryStatus; | 27 | class BatteryStatus; |
28 | class QTimer; | 28 | class QTimer; |
29 | 29 | ||
30 | class BatteryMeter : public QWidget | 30 | class BatteryMeter : public QWidget |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | BatteryMeter( QWidget *parent = 0 ); | 34 | BatteryMeter( QWidget *parent = 0 ); |
35 | ~BatteryMeter(); | 35 | ~BatteryMeter(); |
36 | 36 | ||
37 | QSize sizeHint() const; | 37 | QSize sizeHint() const; |
38 | static int position(); | ||
38 | 39 | ||
39 | protected: | 40 | protected: |
40 | void timerEvent( QTimerEvent* ); | 41 | void timerEvent( QTimerEvent* ); |
41 | void paintEvent( QPaintEvent* ); | 42 | void paintEvent( QPaintEvent* ); |
42 | void mousePressEvent( QMouseEvent* ); | 43 | void mousePressEvent( QMouseEvent* ); |
43 | void mouseReleaseEvent( QMouseEvent* ); | 44 | void mouseReleaseEvent( QMouseEvent* ); |
44 | 45 | ||
45 | protected slots: | 46 | protected slots: |
46 | void chargeTimeout(); | 47 | void chargeTimeout(); |
47 | 48 | ||
48 | protected: | 49 | protected: |
49 | QGuardedPtr<BatteryStatus> batteryView; | 50 | QGuardedPtr<BatteryStatus> batteryView; |
50 | PowerStatus *ps; | 51 | PowerStatus *ps; |
51 | QTimer *chargeTimer; | 52 | QTimer *chargeTimer; |
52 | int percent; | 53 | int percent; |
53 | bool charging; | 54 | bool charging; |
54 | int style; | 55 | int style; |
55 | }; | 56 | }; |
56 | 57 | ||
57 | #endif | 58 | #endif |
diff --git a/core/applets/batteryapplet/batteryapplet.pro b/core/applets/batteryapplet/batteryapplet.pro index 2076987..d956aa0 100644 --- a/core/applets/batteryapplet/batteryapplet.pro +++ b/core/applets/batteryapplet/batteryapplet.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS= battery.h batterystatus.h batteryappletimpl.h | 3 | HEADERS= battery.h batterystatus.h |
4 | SOURCES= battery.cpp batterystatus.cpp batteryappletimpl.cpp | 4 | SOURCES= battery.cpp batterystatus.cpp |
5 | TARGET = batteryapplet | 5 | TARGET = batteryapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include .. | 8 | DEPENDPATH += ../$(OPIEDIR)/include .. |
9 | LIBS += -lqpe -lopie | 9 | LIBS += -lqpe -lopiecore2 |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
13 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/core/applets/batteryapplet/batteryappletimpl.cpp b/core/applets/batteryapplet/batteryappletimpl.cpp deleted file mode 100644 index 7cc5f50..0000000 --- a/core/applets/batteryapplet/batteryappletimpl.cpp +++ b/dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "battery.h" | ||
21 | #include "batteryappletimpl.h" | ||
22 | |||
23 | |||
24 | BatteryAppletImpl::BatteryAppletImpl() | ||
25 | : battery(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | BatteryAppletImpl::~BatteryAppletImpl() | ||
30 | { | ||
31 | delete battery; | ||
32 | } | ||
33 | |||
34 | QWidget *BatteryAppletImpl::applet( QWidget *parent ) | ||
35 | { | ||
36 | if ( !battery ) | ||
37 | battery = new BatteryMeter( parent ); | ||
38 | return battery; | ||
39 | } | ||
40 | |||
41 | int BatteryAppletImpl::position() const | ||
42 | { | ||
43 | return 8; | ||
44 | } | ||
45 | |||
46 | QRESULT BatteryAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
47 | { | ||
48 | *iface = 0; | ||
49 | if ( uuid == IID_QUnknown ) | ||
50 | *iface = this; | ||
51 | else if ( uuid == IID_TaskbarApplet ) | ||
52 | *iface = this; | ||
53 | else | ||
54 | return QS_FALSE; | ||
55 | |||
56 | if ( *iface ) | ||
57 | (*iface)->addRef(); | ||
58 | return QS_OK; | ||
59 | } | ||
60 | |||
61 | Q_EXPORT_INTERFACE() | ||
62 | { | ||
63 | Q_CREATE_INSTANCE( BatteryAppletImpl ) | ||
64 | } | ||
65 | |||
diff --git a/core/applets/batteryapplet/batteryappletimpl.h b/core/applets/batteryapplet/batteryappletimpl.h deleted file mode 100644 index 99654e3..0000000 --- a/core/applets/batteryapplet/batteryappletimpl.h +++ b/dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef BATTERYAPPLETIMPL_H | ||
21 | #define BATTERYAPPLETIMPL_H | ||
22 | |||
23 | #include <qpe/taskbarappletinterface.h> | ||
24 | |||
25 | class BatteryMeter; | ||
26 | |||
27 | class BatteryAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | BatteryAppletImpl(); | ||
31 | virtual ~BatteryAppletImpl(); | ||
32 | |||
33 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
34 | Q_REFCOUNT | ||
35 | |||
36 | virtual QWidget *applet( QWidget *parent ); | ||
37 | virtual int position() const; | ||
38 | |||
39 | private: | ||
40 | BatteryMeter *battery; | ||
41 | }; | ||
42 | |||
43 | #endif | ||
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index 86b20e8..b9ca7b5 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -1,71 +1,72 @@ | |||
1 | 1 | ||
2 | #include "batterystatus.h" | 2 | #include "batterystatus.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odevice.h> | ||
4 | #include <qpe/power.h> | 6 | #include <qpe/power.h> |
5 | 7 | ||
6 | #include <opie/odevice.h> | 8 | /* QT */ |
7 | |||
8 | #include <qpainter.h> | 9 | #include <qpainter.h> |
9 | #include <qpushbutton.h> | 10 | #include <qpushbutton.h> |
10 | #include <qdrawutil.h> | 11 | #include <qdrawutil.h> |
11 | #include <qfile.h> | 12 | #include <qfile.h> |
12 | #include <qlayout.h> | 13 | #include <qlayout.h> |
13 | #include <qtextstream.h> | 14 | #include <qtextstream.h> |
14 | #include <qapplication.h> | 15 | #include <qapplication.h> |
15 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
16 | 17 | ||
17 | using namespace Opie; | 18 | using namespace Opie; |
18 | 19 | ||
19 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | 20 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) |
20 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { | 21 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { |
21 | setCaption( tr("Battery status") ); | 22 | setCaption( tr("Battery status") ); |
22 | setMinimumSize( 150, 200 ); | 23 | setMinimumSize( 150, 200 ); |
23 | 24 | ||
24 | QPushButton *pb = new QPushButton( tr("Close"), this ); | 25 | QPushButton *pb = new QPushButton( tr("Close"), this ); |
25 | QVBoxLayout *layout = new QVBoxLayout ( this ); | 26 | QVBoxLayout *layout = new QVBoxLayout ( this ); |
26 | 27 | ||
27 | jackPercent = 0; | 28 | jackPercent = 0; |
28 | 29 | ||
29 | pb->setMaximumSize( 120, 40 ); | 30 | pb->setMaximumSize( 120, 40 ); |
30 | 31 | ||
31 | pb->show(); | 32 | pb->show(); |
32 | 33 | ||
33 | layout->addStretch(); | 34 | layout->addStretch(); |
34 | layout->addWidget( pb ); | 35 | layout->addWidget( pb ); |
35 | 36 | ||
36 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 37 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
37 | getProcApmStatusIpaq(); | 38 | getProcApmStatusIpaq(); |
38 | } | 39 | } |
39 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); | 40 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); |
40 | percent = ps->batteryPercentRemaining(); | 41 | percent = ps->batteryPercentRemaining(); |
41 | show(); | 42 | show(); |
42 | } | 43 | } |
43 | 44 | ||
44 | BatteryStatus::~BatteryStatus() | 45 | BatteryStatus::~BatteryStatus() |
45 | { | 46 | { |
46 | } | 47 | } |
47 | 48 | ||
48 | /* | 49 | /* |
49 | * Make use of the advanced apm interface of the ipaq | 50 | * Make use of the advanced apm interface of the ipaq |
50 | */ | 51 | */ |
51 | bool BatteryStatus::getProcApmStatusIpaq() { | 52 | bool BatteryStatus::getProcApmStatusIpaq() { |
52 | 53 | ||
53 | bat2 = false; | 54 | bat2 = false; |
54 | 55 | ||
55 | QFile procApmIpaq("/proc/hal/battery"); | 56 | QFile procApmIpaq("/proc/hal/battery"); |
56 | 57 | ||
57 | if (procApmIpaq.open(IO_ReadOnly) ) { | 58 | if (procApmIpaq.open(IO_ReadOnly) ) { |
58 | QStringList list; | 59 | QStringList list; |
59 | // since it is /proc we _must_ use QTextStream | 60 | // since it is /proc we _must_ use QTextStream |
60 | QTextStream stream ( &procApmIpaq); | 61 | QTextStream stream ( &procApmIpaq); |
61 | QString streamIn; | 62 | QString streamIn; |
62 | streamIn = stream.read(); | 63 | streamIn = stream.read(); |
63 | list = QStringList::split("\n", streamIn); | 64 | list = QStringList::split("\n", streamIn); |
64 | 65 | ||
65 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 66 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
66 | // not nice, need a rewrite later | 67 | // not nice, need a rewrite later |
67 | if( (*line).startsWith(" Percentage") ){ | 68 | if( (*line).startsWith(" Percentage") ){ |
68 | if (bat2 == true) { | 69 | if (bat2 == true) { |
69 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 70 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
70 | } else { | 71 | } else { |
71 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 72 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |