summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog1
-rw-r--r--noncore/applets/memoryapplet/graph.cpp183
-rw-r--r--noncore/applets/memoryapplet/graph.h89
-rw-r--r--noncore/applets/memoryapplet/load.cpp212
-rw-r--r--noncore/applets/memoryapplet/load.h60
-rw-r--r--noncore/applets/memoryapplet/memory.cpp165
-rw-r--r--noncore/applets/memoryapplet/memory.h63
-rw-r--r--noncore/applets/memoryapplet/memoryapplet.pro14
-rw-r--r--noncore/applets/memoryapplet/swapfile.cpp15
9 files changed, 794 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index f2cf5c5..14be30b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,2 +10,3 @@
* #1501 - Fixed bug in todo sql backend (eilers)
+ * #1505 - Added more Swap sizes in memoryapplet (mickeyl)
* #1525 - Hopefully fixed double alarms and not removing alarms set with the Clock application (zecke)
diff --git a/noncore/applets/memoryapplet/graph.cpp b/noncore/applets/memoryapplet/graph.cpp
new file mode 100644
index 0000000..0b02bf7
--- a/dev/null
+++ b/noncore/applets/memoryapplet/graph.cpp
@@ -0,0 +1,183 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qpainter.h>
+#include <qpixmap.h>
+#include "graph.h"
+
+void GraphData::clear()
+{
+ names.clear();
+ values.resize(0);
+}
+
+void GraphData::addItem( const QString &name, int value )
+{
+ names.append( name );
+ values.resize( values.size() + 1 );
+ values[values.size()-1] = value;
+}
+
+Graph::Graph(QWidget *parent, const char *name, WFlags f )
+ : QFrame( parent, name, f )
+{
+}
+
+PieGraph::PieGraph(QWidget *parent, const char *name, WFlags f )
+ : Graph( parent, name, f )
+{
+}
+
+void PieGraph::drawContents( QPainter *p )
+{
+ int size = QMIN( contentsRect().width(), contentsRect().height() ) - 1;
+
+ int total = 0;
+ for ( unsigned i = 0; i < data->count(); i++ )
+ total += data->value(i);
+
+ int angle = 0;
+ for ( unsigned i = 0; i < data->count(); i++ ) {
+ int len;
+ if ( i == data->count() - 1 || !total )
+ len = 5760 - angle;
+ else
+ len = data->value(i) * 5760 / total;
+ QColor col;
+ col.setHsv( i * 360 / data->count(), 255, 255 );
+ p->setBrush( col );
+ p->drawPie ( contentsRect().x(), contentsRect().y(),
+ size, size, angle, len+32 );
+ angle += len;
+ }
+}
+
+BarGraph::BarGraph(QWidget *parent, const char *name, WFlags f )
+ : Graph( parent, name, f )
+{
+ setMinimumHeight( 10 );
+ setMaximumHeight( 45 );
+}
+
+void BarGraph::drawContents( QPainter *p )
+{
+ int h = contentsRect().height();
+ int y = contentsRect().top();
+
+ int total = 0;
+ for ( unsigned i = 0; i < data->count(); i++ )
+ total += data->value(i);
+
+ int pos = 0;
+ for ( unsigned i = 0; i < data->count(); i++ ) {
+ int len;
+ if ( i == data->count() - 1 || !total )
+ len = contentsRect().width() - pos;
+ else
+ len = data->value(i) * contentsRect().width() / total;
+ QColor col;
+ col.setHsv( i * 360 / data->count(), 255, 255 );
+ drawSegment( p, QRect(contentsRect().x() + pos, y, len, h), col );
+ pos += len;
+ }
+}
+
+void BarGraph::drawSegment( QPainter *p, const QRect &r, const QColor &c )
+{
+ if ( QPixmap::defaultDepth() > 8 ) {
+ QColor topgrad = c.light(170);
+ QColor botgrad = c.dark();
+
+ int h1, h2, s1, s2, v1, v2;
+ topgrad.hsv( &h1, &s1, &v1 );
+ botgrad.hsv( &h2, &s2, &v2 );
+ int ng = r.height();
+ for ( int j =0; j < ng; j++ ) {
+ p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1),
+ s1 + ((s2-s1)*j)/(ng-1),
+ v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
+ p->drawLine( r.x(), r.top()+j, r.x()+r.width(), r.top()+j );
+ }
+ } else {
+ p->fillRect( r.x(), r.top(), r.width(), r.height(), c );
+ }
+}
+
+
+GraphLegend::GraphLegend( QWidget *parent, const char *name, WFlags f )
+ : QFrame( parent, name, f )
+{
+ horz = FALSE;
+}
+
+void GraphLegend::setOrientation(Orientation o)
+{
+ horz = o == Horizontal;
+}
+
+void GraphLegend::drawContents( QPainter *p )
+{
+ int total = 0;
+ for ( unsigned i = 0; i < data->count(); i++ )
+ total += data->value(i);
+
+ int tw = width()/data->count()-1;
+ int th = height()/(horz ? 1 : data->count());
+ if ( th > p->fontMetrics().height() )
+ th = p->fontMetrics().height();
+ int x = 0;
+ int y = 0;
+ for ( unsigned i = 0; i < data->count(); i++ ) {
+ QColor col;
+ col.setHsv( i * 360 / data->count(), 255, 255 );
+ p->setBrush( col );
+ p->drawRect( x+1, y+1, th - 2, th - 2 );
+ p->drawText( x+th + 1, y + p->fontMetrics().ascent()+1, data->name(i) );
+ if ( horz ) {
+ x += tw;
+ } else {
+ y += th;
+ }
+ }
+}
+
+QSize GraphLegend::sizeHint() const
+{
+ int th = fontMetrics().height() + 2;
+ int maxw = 0;
+ for ( unsigned i = 0; i < data->count(); i++ ) {
+ int w = fontMetrics().width( data->name(i) );
+ if ( w > maxw )
+ maxw = w;
+ }
+ if ( 0 && horz ) {
+ return QSize( maxw * data->count(), th );
+ } else {
+ return QSize( maxw, th * data->count() );
+ }
+}
+
+void GraphLegend::setData( const GraphData *p )
+{
+ data = p;
+ int th = fontMetrics().height();
+ setMinimumHeight( th * ( horz ? 1 : data->count() ) );
+ updateGeometry();
+}
diff --git a/noncore/applets/memoryapplet/graph.h b/noncore/applets/memoryapplet/graph.h
new file mode 100644
index 0000000..5a65e79
--- a/dev/null
+++ b/noncore/applets/memoryapplet/graph.h
@@ -0,0 +1,89 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qframe.h>
+#include <qarray.h>
+#include <qstringlist.h>
+
+class GraphData
+{
+public:
+ void clear();
+ void addItem( const QString &name, int value );
+
+ const QString &name( int i ) const { return names[i]; }
+ int value( int i ) const { return values[i]; }
+ unsigned count() const { return values.size(); }
+
+private:
+ QStringList names;
+ QArray<int> values;
+};
+
+class Graph : public QFrame
+{
+ Q_OBJECT
+public:
+ Graph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+
+ void setData( const GraphData *p ) { data = p; }
+
+protected:
+ const GraphData *data;
+};
+
+class PieGraph : public Graph
+{
+ Q_OBJECT
+public:
+ PieGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+
+protected:
+ virtual void drawContents( QPainter *p );
+};
+
+class BarGraph : public Graph
+{
+ Q_OBJECT
+public:
+ BarGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+
+protected:
+ virtual void drawContents( QPainter *p );
+ void drawSegment( QPainter *p, const QRect &r, const QColor &c );
+};
+
+class GraphLegend : public QFrame
+{
+ Q_OBJECT
+public:
+ GraphLegend( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+
+ void setData( const GraphData *p );
+ virtual QSize sizeHint() const;
+ void setOrientation(Orientation o);
+
+protected:
+ virtual void drawContents( QPainter *p );
+
+private:
+ const GraphData *data;
+ bool horz;
+};
diff --git a/noncore/applets/memoryapplet/load.cpp b/noncore/applets/memoryapplet/load.cpp
new file mode 100644
index 0000000..d9d7a66
--- a/dev/null
+++ b/noncore/applets/memoryapplet/load.cpp
@@ -0,0 +1,212 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <stdio.h>
+
+#include <qfile.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qtextstream.h>
+#include <qtimer.h>
+#include <qwhatsthis.h>
+
+#include "load.h"
+
+LoadInfo::LoadInfo( QWidget *parent, const char *name, WFlags f )
+ : QWidget( parent, name, f )
+{
+ QVBoxLayout *vb = new QVBoxLayout( this, 6 );
+
+ QString cpuInfo = getCpuInfo();
+ if ( !cpuInfo.isNull() )
+ vb->addWidget( new QLabel( cpuInfo, this ) );
+ vb->addWidget( new Load( this ), 100 );
+ QLabel *l = new QLabel( this );
+ l->setPixmap( makeLabel( red, tr("Application CPU usage (%)") ) );
+ vb->addWidget( l, 1 );
+ l = new QLabel( this );
+ l->setPixmap( makeLabel( green, tr("System CPU usage (%)") ) );
+ vb->addWidget( l, 1 );
+ vb->addStretch(50);
+
+ QWhatsThis::add( this, tr( "This page shows how much this device's processor is being used." ) );
+}
+
+QPixmap LoadInfo::makeLabel( const QColor &col, const QString &text )
+{
+ int h = fontMetrics().height();
+ QPixmap pm( 20 + fontMetrics().width( text ), h );
+ QPainter p( &pm );
+ p.fillRect( pm.rect(), colorGroup().background() );
+ p.fillRect( 0, h/2-4, 18, h/2+3, black );
+ p.setPen( col );
+ p.drawLine( 2, h/2, 15, h/2 );
+ p.setPen( colorGroup().text() );
+ p.drawText( 20, fontMetrics().ascent(), text );
+
+ return pm;
+}
+
+QString LoadInfo::getCpuInfo()
+{
+ bool haveInfo = FALSE;
+ QString info = tr("Type: ");
+ QFile f( "/proc/cpuinfo" );
+ if ( f.open( IO_ReadOnly ) ) {
+ QTextStream ts( &f );
+
+ while ( !ts.atEnd() ) {
+ QString s = ts.readLine();
+ if ( s.find( "model name" ) == 0 ) {
+ info += s.mid( s.find( ':' ) + 2 );
+ haveInfo = TRUE;
+ } else if ( s.find( "cpu MHz" ) == 0 ) {
+ double mhz = s.mid( s.find( ':' ) + 2 ).toDouble();
+ info += " " + QString::number( mhz, 'f', 0 );
+ info += "MHz";
+ break;
+ } else if ( s.find( "Processor" ) == 0 ) {
+ info += s.mid( s.find( ':' ) + 2 );
+ haveInfo = TRUE;
+ break;
+#ifdef __MIPSEL__
+ } else if ( s.find( "cpu model" ) == 0 ) {
+ info += " " + s.mid( s.find( ':' ) + 2 );
+ break;
+ } else if ( s.find( "cpu" ) == 0 ) {
+ info += s.mid( s.find( ':' ) + 2 );
+ haveInfo = TRUE;
+#endif
+ }
+ }
+ }
+
+ if ( !haveInfo )
+ info = QString();
+
+ return info;
+}
+
+Load::Load( QWidget *parent, const char *name, WFlags f )
+ : QWidget( parent, name, f )
+{
+ setMinimumHeight( 30 );
+ setBackgroundColor( black );
+ points = 100;
+ setMinimumWidth( points );
+ userLoad = new double [points];
+ systemLoad = new double [points];
+ for ( int i = 0; i < points; i++ ) {
+ userLoad[i] = 0.0;
+ systemLoad[i] = 0.0;
+ }
+ maxLoad = 1.3;
+ QTimer *timer = new QTimer( this );
+ connect( timer, SIGNAL(timeout()), SLOT(timeout()) );
+ timer->start( 2000 );
+ gettimeofday( &last, 0 );
+ first = TRUE;
+ timeout();
+}
+
+void Load::paintEvent( QPaintEvent * )
+{
+ QPainter p( this );
+
+ int h = height() - 5;
+
+ int mult = (int)(h / maxLoad);
+
+ p.setPen( gray );
+ p.drawLine( 0, h - mult, width(), h - mult );
+ p.drawText( 0, h - mult, "100" );
+ p.drawText( 0, h, "0" );
+
+ p.setPen( green );
+ for ( int i = 1; i < points; i++ ) {
+ int x1 = (i - 1) * width() / points;
+ int x2 = i * width() / points;
+ p.drawLine( x1, h - systemLoad[i-1] * mult,
+ x2, h - systemLoad[i] * mult );
+ }
+
+ p.setPen( red );
+ for ( int i = 1; i < points; i++ ) {
+ int x1 = (i - 1) * width() / points;
+ int x2 = i * width() / points;
+ p.drawLine( x1, h - userLoad[i-1] * mult,
+ x2, h - userLoad[i] * mult );
+ }
+}
+
+void Load::timeout()
+{
+ int user;
+ int usernice;
+ int sys;
+ int idle;
+ FILE *fp;
+ fp = fopen( "/proc/stat", "r" );
+ fscanf( fp, "cpu %d %d %d %d", &user, &usernice, &sys, &idle );
+ fclose( fp );
+ struct timeval now;
+ gettimeofday( &now, 0 );
+ int tdiff = now.tv_usec - last.tv_usec;
+ tdiff += (now.tv_sec - last.tv_sec) * 1000000;
+ tdiff /= 10000;
+
+ int udiff = user - lastUser;
+ int sdiff = sys - lastSys;
+ if ( tdiff > 0 ) {
+ double uload = (double)udiff / (double)tdiff;
+ double sload = (double)sdiff / (double)tdiff;
+ if ( !first ) {
+ for ( int i = 1; i < points; i++ ) {
+ userLoad[i-1] = userLoad[i];
+ systemLoad[i-1] = systemLoad[i];
+ }
+ userLoad[points-1] = uload;
+ systemLoad[points-1] = sload;
+// scroll( -width()/points, 0, QRect( 0, 0, width() - width()/points + 1, height() ) );
+ repaint( TRUE );
+ double ml = 1.3;
+ /*
+ for ( int i = 0; i < points; i++ ) {
+ if ( userLoad[i] > ml )
+ ml = userLoad[i];
+ }
+ */
+ if ( maxLoad != ml ) {
+ maxLoad = ml;
+ update();
+ }
+ }
+
+ last = now;
+ lastUser = user;
+ lastSys = sys;
+ first = FALSE;
+ } else if ( tdiff < 0 ) {
+ last = now;
+ }
+}
+
diff --git a/noncore/applets/memoryapplet/load.h b/noncore/applets/memoryapplet/load.h
new file mode 100644
index 0000000..e7f5388
--- a/dev/null
+++ b/noncore/applets/memoryapplet/load.h
@@ -0,0 +1,60 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <sys/time.h>
+#include <qwidget.h>
+
+/*
+ Little load meter
+*/
+class Load : public QWidget {
+ Q_OBJECT
+public:
+ Load( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+
+protected:
+ void paintEvent( QPaintEvent *ev );
+
+private slots:
+ void timeout();
+
+private:
+ int points;
+ double *userLoad;
+ double *systemLoad;
+ double maxLoad;
+ struct timeval last;
+ int lastUser;
+ int lastUsernice;
+ int lastSys;
+ int lastIdle;
+ bool first;
+};
+
+class LoadInfo : public QWidget
+{
+ Q_OBJECT
+public:
+ LoadInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+
+private:
+ QPixmap makeLabel( const QColor &col, const QString &text );
+ QString getCpuInfo();
+};
diff --git a/noncore/applets/memoryapplet/memory.cpp b/noncore/applets/memoryapplet/memory.cpp
new file mode 100644
index 0000000..05349e4
--- a/dev/null
+++ b/noncore/applets/memoryapplet/memory.cpp
@@ -0,0 +1,165 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qlabel.h>
+#include <qtimer.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+#include "graph.h"
+#include "memory.h"
+
+MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags f )
+ : QWidget( parent, name, f )
+{
+ QVBoxLayout *vb = new QVBoxLayout( this, 5 );
+
+ totalMem = new QLabel( this );
+ vb->addWidget( totalMem );
+
+ data = new GraphData();
+ graph = new BarGraph( this );
+ graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ vb->addWidget( graph, 1 );
+ graph->setData( data );
+
+ legend = new GraphLegend( this );
+ vb->addWidget( legend );
+ legend->setData( data );
+
+ swapMem = new QLabel( this );
+ vb->addWidget( swapMem );
+
+ swapdata = new GraphData();
+ swapgraph = new BarGraph( this );
+ swapgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ vb->addWidget( swapgraph, 1 );
+ swapgraph->setData( swapdata );
+
+ swaplegend = new GraphLegend( this );
+ vb->addWidget( swaplegend );
+ swaplegend->setData( swapdata );
+
+ vb->addStretch( 1 );
+ updateData();
+
+ QTimer *t = new QTimer( this );
+ connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
+ t->start( 5000 );
+
+ QWhatsThis::add( this, tr( "This page shows how memory (i.e. RAM) is being allocated on your device.\nMemory is categorized as follows:\n\n1. Used - memory used to by Opie and any running applications.\n2. Buffers - temporary storage used to improve performance\n3. Cached - information that has recently been used, but has not been freed yet.\n4. Free - memory not currently used by Opie or any running applications." ) );
+
+}
+
+MemoryInfo::~MemoryInfo()
+{
+ delete data;
+}
+
+void MemoryInfo::updateData()
+{
+ QFile file( "/proc/meminfo" );
+
+ if ( file.open( IO_ReadOnly ) )
+ {
+ // local variables
+ QString line;
+ QString identifier;
+ QString value;
+ int position;
+ QTextStream t( &file );
+
+ while ( !t.atEnd() )
+ {
+ // read a line
+ line = t.readLine();
+
+ // extract identifier and value from line
+ position = line.find( ":" );
+ identifier = line.left( position );
+ value = line.mid( position + 1, line.length() - position - 3 );
+ value = value.stripWhiteSpace();
+
+ // copy values in variables
+ if ( identifier == "MemTotal" )
+ {
+ total = value.toULong();
+ } else if ( identifier == "MemFree" )
+ {
+ memfree = value.toULong();
+ } else if ( identifier == "Buffers" )
+ {
+ buffers = value.toULong();
+ } else if ( identifier == "Cached" )
+ {
+ cached = value.toULong();
+ } else if ( identifier == "SwapCached" )
+ {
+ } else if ( identifier == "SwapTotal" )
+ {
+ swaptotal = value.toULong();
+ } else if ( identifier == "SwapFree" )
+ {
+ swapfree = value.toULong();
+ }
+ }
+
+ file.close();
+
+ // calculate values
+ used = total - memfree;
+ swapused = swaptotal - swapfree;
+ realUsed = total - ( buffers + cached + memfree );
+
+ // visualize values
+ totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) );
+ data->clear();
+ data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed );
+ data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers );
+ data->addItem( tr("Cached (%1 kB)").arg(cached), cached );
+ data->addItem( tr("Free (%1 kB)").arg(memfree), memfree );
+
+ graph->hide();
+ graph->show();
+ legend->update();
+
+ if (swaptotal > 0)
+ {
+ swapMem->setText( tr( "Total Swap: %1 kB" ).arg( swaptotal ) );
+ swapdata->clear();
+ swapdata->addItem( tr("Used (%1 kB)").arg(swapused), swapused );
+ swapdata->addItem( tr("Free (%1 kB)").arg(swapfree), swapfree );
+
+ swapMem->show();
+ swapgraph->show();
+ swaplegend->show();
+
+ swapgraph->repaint( FALSE );
+ swaplegend->update();
+ }
+ else
+ {
+ swapMem->hide();
+ swapgraph->hide();
+ swaplegend->hide();
+ }
+ }
+}
diff --git a/noncore/applets/memoryapplet/memory.h b/noncore/applets/memoryapplet/memory.h
new file mode 100644
index 0000000..f655604
--- a/dev/null
+++ b/noncore/applets/memoryapplet/memory.h
@@ -0,0 +1,63 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef MEMORY_H
+#define MEMORY_H
+
+#include <qwidget.h>
+
+class GraphData;
+class Graph;
+class GraphLegend;
+class QLabel;
+
+class MemoryInfo : public QWidget
+{
+ Q_OBJECT
+public:
+ MemoryInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+ ~MemoryInfo();
+
+ unsigned long total;
+ unsigned long used;
+ unsigned long memfree;
+ unsigned long buffers;
+ unsigned long cached;
+ unsigned long realUsed;
+ unsigned long swaptotal;
+ unsigned long swapused;
+ unsigned long swapfree;
+
+private slots:
+ void updateData();
+
+private:
+ QLabel *totalMem;
+ GraphData *data;
+ Graph *graph;
+ GraphLegend *legend;
+
+ QLabel* swapMem;
+ GraphData *swapdata;
+ Graph *swapgraph;
+ GraphLegend *swaplegend;
+};
+
+#endif
diff --git a/noncore/applets/memoryapplet/memoryapplet.pro b/noncore/applets/memoryapplet/memoryapplet.pro
index 57bb1c9..1dfc02f 100644
--- a/noncore/applets/memoryapplet/memoryapplet.pro
+++ b/noncore/applets/memoryapplet/memoryapplet.pro
@@ -2,5 +2,5 @@ TEMPLATE = lib
CONFIG += qt plugin warn_on
-HEADERS = ../../settings/sysinfo/graph.h \
- ../../settings/sysinfo/load.h \
- ../../settings/sysinfo/memory.h \
+HEADERS = graph.h \
+ load.h \
+ memory.h \
memorymeter.h \
@@ -8,5 +8,5 @@ HEADERS = ../../settings/sysinfo/graph.h \
swapfile.h
-SOURCES = ../../settings/sysinfo/graph.cpp \
- ../../settings/sysinfo/load.cpp \
- ../../settings/sysinfo/memory.cpp \
+SOURCES = graph.cpp \
+ load.cpp \
+ memory.cpp \
memorymeter.cpp \
@@ -18,3 +18,3 @@ INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH +=
-VERSION = 1.0.0
+VERSION = 1.0.1
LIBS += -lqpe -lopiecore2 -lopieui2
diff --git a/noncore/applets/memoryapplet/swapfile.cpp b/noncore/applets/memoryapplet/swapfile.cpp
index 96010c8..4609c13 100644
--- a/noncore/applets/memoryapplet/swapfile.cpp
+++ b/noncore/applets/memoryapplet/swapfile.cpp
@@ -92,3 +92,3 @@ Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f )
swapSize = new QComboBox(hb3);
- swapSize->insertStringList(QStringList::split(",", tr("2 Mb,4 Mb,6 Mb,8 Mb")));
+ swapSize->insertStringList(QStringList::split(",", tr("2 Mb,4 Mb,6 Mb,8 Mb,16 Mb,32 Mb,64 Mb")));
@@ -345,2 +345,9 @@ void Swapfile::makeswapfile()
break;
+ case 4: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=16384").arg(swapPath1->text()));
+ break;
+ case 5: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=32768").arg(swapPath1->text()));
+ break;
+ case 6: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=65536").arg(swapPath1->text()));
+ break;
+
}
@@ -433,2 +440,8 @@ void Swapfile::status()
break;
+ case 16: swapSize->setCurrentItem(4);
+ break;
+ case 32: swapSize->setCurrentItem(5);
+ break;
+ case 64: swapSize->setCurrentItem(6);
+ break;
}