summaryrefslogtreecommitdiff
path: root/noncore/applets/memoryapplet
Unidiff
Diffstat (limited to 'noncore/applets/memoryapplet') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/memoryapplet/memorymeter.cpp26
-rw-r--r--noncore/applets/memoryapplet/memorystatus.cpp1
-rw-r--r--noncore/applets/memoryapplet/memorystatus.h4
3 files changed, 15 insertions, 16 deletions
diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp
index 9299f49..9cdeaf4 100644
--- a/noncore/applets/memoryapplet/memorymeter.cpp
+++ b/noncore/applets/memoryapplet/memorymeter.cpp
@@ -28,22 +28,23 @@
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qtimer.h> 29#include <qtimer.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <qtopia/applnk.h> 32#include <qtopia/applnk.h>
33 33
34using namespace Opie::Ui;
34MemoryMeter::MemoryMeter( QWidget *parent ) 35MemoryMeter::MemoryMeter( QWidget *parent )
35 : QWidget( parent ), memoryView(0) 36 : QWidget( parent ), memoryView(0)
36{ 37{
37 bvsz = QSize(); 38 bvsz = QSize();
38 if ( qApp->desktop()->height() >= 300 ) 39 if ( qApp->desktop()->height() >= 300 )
39 { 40 {
40 memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup ); 41 memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup );
41 memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised ); 42 memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised );
42 } 43 }
43 else 44 else
44 { 45 {
45 memoryView = new MemoryStatus( 0 ); 46 memoryView = new MemoryStatus( 0 );
46 memoryView->showMaximized(); 47 memoryView->showMaximized();
47 } 48 }
48 49
49 Config config("MemoryPlugin"); 50 Config config("MemoryPlugin");
@@ -76,17 +77,17 @@ QSize MemoryMeter::sizeHint() const
76 77
77bool MemoryMeter::updateMemoryViewGeometry() 78bool MemoryMeter::updateMemoryViewGeometry()
78{ 79{
79 if (memoryView != 0) 80 if (memoryView != 0)
80 { 81 {
81 QSize sz = memoryView->sizeHint(); 82 QSize sz = memoryView->sizeHint();
82 if ( sz != bvsz ) 83 if ( sz != bvsz )
83 { 84 {
84 bvsz = sz; 85 bvsz = sz;
85 QRect r(memoryView->pos(), memoryView->sizeHint()); 86 QRect r(memoryView->pos(), memoryView->sizeHint());
86 if ( qApp->desktop()->height() >= 300 ) 87 if ( qApp->desktop()->height() >= 300 )
87 { 88 {
88 QPoint curPos = mapToGlobal( rect().topLeft() ); 89 QPoint curPos = mapToGlobal( rect().topLeft() );
89 int lp = qApp->desktop()->width() - memoryView->sizeHint().width(); 90 int lp = qApp->desktop()->width() - memoryView->sizeHint().width();
90 r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) ); 91 r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) );
91 } 92 }
92 memoryView->setGeometry(r); 93 memoryView->setGeometry(r);
@@ -97,17 +98,17 @@ bool MemoryMeter::updateMemoryViewGeometry()
97 98
98 return FALSE; 99 return FALSE;
99} 100}
100 101
101void MemoryMeter::mousePressEvent( QMouseEvent *) 102void MemoryMeter::mousePressEvent( QMouseEvent *)
102{ 103{
103 if ( memoryView->isVisible() ) 104 if ( memoryView->isVisible() )
104 { 105 {
105 memoryView->hide(); 106 memoryView->hide();
106 } 107 }
107 else 108 else
108 { 109 {
109 bvsz = QSize(); 110 bvsz = QSize();
110 updateMemoryViewGeometry(); 111 updateMemoryViewGeometry();
111 memoryView->raise(); 112 memoryView->raise();
112 memoryView->show(); 113 memoryView->show();
113 } 114 }
@@ -203,13 +204,13 @@ void MemoryMeter::paintEvent( QPaintEvent* )
203 if (used_height < 0) 204 if (used_height < 0)
204 used_height = 0; 205 used_height = 0;
205 206
206 // 207 //
207 // Drained section. 208 // Drained section.
208 // 209 //
209 if (used_height != 0) 210 if (used_height != 0)
210 { 211 {
211 p.setPen(NoPen); 212 p.setPen(NoPen);
212 p.setBrush(gray); 213 p.setBrush(gray);
213 p.drawRect(batt_xoffset, batt_yoffset, band_width, used_height); 214 p.drawRect(batt_xoffset, batt_yoffset, band_width, used_height);
214 p.drawRect(batt_xoffset + 2 * band_width, batt_yoffset, band_width, used_height); 215 p.drawRect(batt_xoffset + 2 * band_width, batt_yoffset, band_width, used_height);
215 216
@@ -220,13 +221,13 @@ void MemoryMeter::paintEvent( QPaintEvent* )
220 p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height); 221 p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height);
221 } 222 }
222 223
223 // 224 //
224 // Unused section. 225 // Unused section.
225 // 226 //
226 if ( batt_height - used_height > 0 ) 227 if ( batt_height - used_height > 0 )
227 { 228 {
228 int unused_offset = used_height + batt_yoffset; 229 int unused_offset = used_height + batt_yoffset;
229 int unused_height = batt_height - used_height; 230 int unused_height = batt_height - used_height;
230 p.setPen(NoPen); 231 p.setPen(NoPen);
231 p.setBrush(c); 232 p.setBrush(c);
232 p.drawRect(batt_xoffset, unused_offset, band_width, unused_height); 233 p.drawRect(batt_xoffset, unused_offset, band_width, unused_height);
@@ -237,11 +238,8 @@ void MemoryMeter::paintEvent( QPaintEvent* )
237 238
238 p.setBrush(darkc); 239 p.setBrush(darkc);
239 p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height); 240 p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height);
240 } 241 }
241} 242}
242 243
243Q_EXPORT_INTERFACE() 244EXPORT_OPIE_APPLET_v1( MemoryMeter )
244{
245 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> );
246}
247 245
diff --git a/noncore/applets/memoryapplet/memorystatus.cpp b/noncore/applets/memoryapplet/memorystatus.cpp
index c01ba28..95ae06b 100644
--- a/noncore/applets/memoryapplet/memorystatus.cpp
+++ b/noncore/applets/memoryapplet/memorystatus.cpp
@@ -25,12 +25,13 @@
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qdrawutil.h> 26#include <qdrawutil.h>
27#include <qlabel.h> 27#include <qlabel.h>
28 28
29#include <qlayout.h> 29#include <qlayout.h>
30 30
31using namespace Opie::Ui;
31MemoryStatus::MemoryStatus(QWidget *parent, WFlags f ) 32MemoryStatus::MemoryStatus(QWidget *parent, WFlags f )
32 : QFrame(parent, 0, f), mi(0), sf(0) 33 : QFrame(parent, 0, f), mi(0), sf(0)
33{ 34{
34 setCaption( tr("Memory Status") ); 35 setCaption( tr("Memory Status") );
35 //resize( 220, 180 ); 36 //resize( 220, 180 );
36 37
diff --git a/noncore/applets/memoryapplet/memorystatus.h b/noncore/applets/memoryapplet/memorystatus.h
index c3926db..d16787b 100644
--- a/noncore/applets/memoryapplet/memorystatus.h
+++ b/noncore/applets/memoryapplet/memorystatus.h
@@ -23,13 +23,13 @@
23#include <qframe.h> 23#include <qframe.h>
24 24
25#include <opie2/otabwidget.h> 25#include <opie2/otabwidget.h>
26 26
27class MemoryInfo; 27class MemoryInfo;
28class Swapfile; 28class Swapfile;
29using Opie::OTabWidget; 29
30 30
31class MemoryStatus : public QFrame 31class MemoryStatus : public QFrame
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34public: 34public:
35 MemoryStatus(QWidget *parent = 0, WFlags f = 0); 35 MemoryStatus(QWidget *parent = 0, WFlags f = 0);
@@ -39,11 +39,11 @@ public:
39 MemoryInfo* mi; 39 MemoryInfo* mi;
40 Swapfile* sf; 40 Swapfile* sf;
41 41
42 int percent(); 42 int percent();
43 43
44private: 44private:
45 OTabWidget *tab; 45 Opie::Ui::OTabWidget *tab;
46}; 46};
47 47
48#endif 48#endif
49 49