-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/graph.cpp | 183 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/graph.h | 89 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/load.cpp | 212 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/load.h | 60 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memory.cpp | 165 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memory.h | 63 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memoryapplet.pro | 14 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/swapfile.cpp | 15 |
9 files changed, 794 insertions, 8 deletions
@@ -1,193 +1,194 @@ 2005-??-?? Opie 1.1.9 New Features ------------ * Number of icon columns in Launcher is customizable through Launcher.conf (hrw,zecke,mickeyl) * Number of icon columns in Launcher is customizable through LauncherSettings (mickeyl) Fixed Bugs ---------- * #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) * #1533 - Security Owner Dialog (shown in case of unsuccessfull authentiacation) wasn't able to display information in non latin1 encoding (zecke) * n.a. - Removed hard coded font sizes in a couple of inputmethods (mickeyl) * n.a. - Removed MediumDlg appearing prior to FirstUsage wizard (i.e. calibration) (mickeyl) Internal -------- * Added the Qtopia 1.7 SDK macros for quick-apps to easa compilation of 3rd party apps against our headers (mickeyl) * You can now use the Opie build system in combination with a OpenEmbedded staging area which makes a nice cross development environment (mickeyl) * Made Opie compilable with Qt/Embedded 2.3.10 (ar) * Changed Launcher to get default orientation from ODevice w/ QWS_DISPLAY overriding (mickeyl) 2004-11-26 Opie 1.1.8 New Features ------------ * PackageManager supports installation of local ipkg files (drw) * PackageManager supports linking of applications to root (drw) * PackageManager supports src/gz feeds (drw,wimpie) * Added a syslog information tab to sysinfo (mickeyl) * Added new, more consistent, PIM icons + a GIMP teplate (ar) Fixed Bugs ---------- * #1017 - Tetrix doesn't display correctly for high resolution screens (drw) * #1269 - VCards were imported into personal area if it was activated (eilers) * #1464 - Packagemanager dont set active filter after install a package (drw) * #1479 - Improved VCard-Parser to import VCards created by Evolution 2 and Apple Addressbook (eilers) * #1493 - Fixed one column layout bug of the launcher (hrw) * n.a. - PackageManager - (Minor UI tweak) in filter dialog, when option is enabled, set focus to widget that corresponds to that option (drw) * n.a. - PackageManager - (Minor UI tweak) fix double entry in source feed configuration when adding a new feed (drw) * n.a. - Battery Applet - fix sizing of battery info popup (drw,mickeyl) Internal -------- * Moved libopie1 to unsupported (mickeyl) * Implemented generic queryByExample() with incremental searching. A lot of internal changes of the Pim2-library (eilers) * Added fast and full featured and incremental sorted() for SQL addressbook backend (eilers) 2004-11-14 Opie 1.1.7 New Features ------------ * libOpieDB now uses SQLite V3 instead V2. Remember to upgrade your database files! (eilers) * Backup now uses the busy indicator when backing up and restore (ar) * OpiePlayer2 gained adding of Directories to the playlist (zecke) * OpiePlayer2 better error handling (zecke) * OpiePlayer2 progress indication while streaming (zecke) * OpiePlayer2 ported to use libxine 1.0.0-rc6a (brad,zecke) * Ported brightnessapplet from Qtopia 1.7 (mickeyl) * Opie-Eye got a Digital Camera File Backend (alwin,zecke) * Support for Tuxpad1 of Tradesquare.NL (mickeyl,zecke) * Opie-Console use Custom Font and Size in a Profile (harlekin) * Opie-Console transparently log the Output and Input to a file (harlekin) * Added new O-menu icon to lock the PDA immediately: opie-lockapplet (clem) * Opie-Security now hides the plugin-based authentication tabs if no auth. plugin package is installed (clem) * Opie-Security gained a 'test authentication' button (clem) * Opie-Eye got a more unique layout (menubar), a slideshow, user can setup some defaults * Opie-Mail improve the handling of POP mail boxes (alwin) * Both Opie-Eye and Opie-Mail were greatly improved due the hard work of Rajko Albrecht(alwin) * Opie IRC - backports of the 'NeIRC fork' (zecke) Fixed Bugs ---------- * #501 - Pickboard is able to show 'Umlaute' (TT,zecke) * #608 - Make Opie usable for left handed users (zecke) * #957 - Import of VCards/VTodos/VEvents with BASE64 encoding (ljp,zecke) * #1245 - Opie-Go 'paused' (zecke) * #1358 - DocTab didn't show any MimeTypes (was fixed earlier) (zecke) * #1380 - QDateBookAccess::remove() doesn't remove entries (eilers, zecke) * #1395 - Build VNC Backend with gcc3.4 * #1440 - The icon of opie-mobilemsg is missing (CoreDump) * #1426 - Add missing opie-bartender Icon (CoreDump) * #1445 - Opie-Sheet Has No Icon (CoreDump) * #1448 - Brightness Applet added (mickeyl) * #1450 - ZSame didn't clear the bonus item after winning a game (zecke) * #1482 - Fix OFileSelector to be able to sort by size (zecke) * n.a. - Opie-mail: fixed some crasher, some layout-problems * n.a. - Converted applications to not hardcode /opt/QtPalmtop but to use QPEApplication::qpeDir (zecke) * n.a. - Converted usage of qpeDir() not to include a '/' as first charachter of the string (zecke) * n.a. - Build system: Enable distcc and ccache when crosscompiling too, and use them everywhere we can (clem) * n.a. - Build system: Fix deps in several config.in (and fix scripts/deps.pl too) to stop breaking builds, especially with make -j highNumber (clem) * n.a. - Removed hardcoded icon size in a couple of applets (mickeyl) Internal -------- * Opie-Qashmoney has been moved to unsupported (mickeyl) * Opie-Ubrowser has been moved to unsupported (mickeyl) 2004-09-17 Opie 1.1.6 New Features ------------ * Fifteen gained configurable number of items (zecke) * Fifteen can have custom background images (zecke) * Added daemonizing capabilities to QWS Server [via Qt/Embedded] (mickeyl) * Integrated the new security framework into libopie2 (zecke,clem) * Converted the launcher to use the new security framework (zecke) * Backup can now handle custom locations for backup and restore (ar) * Implemented right-on-hold feedback (wimpie,zecke) * Lots of new features in opie-reader (tim,pohly) * Build system cleanups (schurig) Fixed Bugs -------- * #1005 - Fixed backup to CompactFlash (ar) * #1167 - Fixed Opie write crashing on more text than one page (ar) * #1225 - Fixed repeated light flashing on Zaurus with keyz (mickeyl) * #1359 - Fixed bookmarks in Gutenbrowser (ljp) * #1361 - Fixed auto upercase in Opie-Addressbook (eilers) * #1370 - Pimconverter now reacts on cancel key (eilers) * #1376 - Bring back the capslock/numlock display (zecke) * #1383 - Language settings now warns about losing open apps (Markus Litz) * #1393 - Fixed line wrap issues in opie-console for the default profile (mickeyl) * #1394 - Fixed oversized headline in opie-login (coredump) * #1396 - Opie-console captures the escape key and vim is working (zecke) * #1401 - Scrollbar is now only visible if necessary in DocTab (mickeyl) 2004-07-06 Opie 1.1.4 New Features ------------ * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) * Added Conversion tool for pim-data (eilers) * Introduced new OPimAccessFactory and OBackendFactory which simplyfies database access (eilers) * Modified the PIM API for providing generic use of OPimRecords (eilers) * Clicking on the application symbol now iterates over the application's top level widgets if already raised (zecke) Fixed Bugs -------- * #1068 - Country Drop Down Box Off Screen * #1291 - Opie tinykate does not open .desktop files (ar) * #1291 - Opie sheet not saving correctly (ar) * #1294 - Opie does not know about British Summer Time * #1314 - Drawpad initialization (mickeyl) * #1317 - Packagemanager crashes on hold-down or install (chicken) * #1321 - Batteryapplet graphic glitch (harlekin) * #1324 - ZSafe not starting up (mickeyl) * #1328 - Personal Home Address fields is trimmed to 1char (eilers) * #1327 - Opie-mail ipk does not depend on libopiedb2 (chicken) * #1345 - Networksettingsplugin wlan plugin dependency on libpcap0 (mickeyl) * #1348 - Datebook dependency on libopiedb2 (chicken) * #1328 - Switched SQLDatabase and VCards char encoding from latin1 to unicode (eilers) 2004-04-25 Opie 1.1.3 * Introduced first implementation of SQL-Support using SQLite (eilers) * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) * Added a real system graffiti character set (brad) * Added Generic Keyconfig Widget (zecke) * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) * Added new Bible reader app - opie-dagger (drw) * Added a new Image Viewer. Work is ongoing (zecke,alwin) * Added namespace usage in libopie2 and everywhere (zecke,alwin) * Enabled the possibility to pass command line arguments to applications (mickeyl) * Added an about applet showing some credits and information about Opie (mickeyl) * Added benchmarking functionality to sysinfo (mickeyl) * Added applet and configuration application for switching hardware keyboard layouts (alwin) * Ported applications from libopie1 to libopie2* (drw,ar,alwin) * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) * Clean-up of package information in control files (drw) * Repaired mediummount which was broken since integrating the quicklauncher (alwin) * Improved big-screen support (zecke,ar) * Improved multikeyboard support, added keyboard layout switching applet (mouse) * Added a new mail client based on libetpan (harlekin,alwin,jgf) * Added new package manager - opie-packagemanager (drw) * Improved light-n-power for C7x0 (mickeyl) * Added automatic rotation support for C7x0 (treke) * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) * Added scanning the wireless network neighbourhood to networksettings (mickeyl) 2003-11-29 Opie 1.0.3 * Released as Version 1.0.3 * Improved i18n (various contributors) * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) * Made the Documents Tab optional (mickeyl) * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) 2003-08-04 Opie 1.0.0 * Released as Version 1.0.0 * Including a PPP module for easy dial up (tille,harlekin,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 @@ -1,22 +1,22 @@ 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 \ memorystatus.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 \ memorystatus.cpp \ swapfile.cpp TARGET = memoryapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += -VERSION = 1.0.0 +VERSION = 1.0.1 LIBS += -lqpe -lopiecore2 -lopieui2 include( $(OPIEDIR)/include.pro ) 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 @@ -1,439 +1,452 @@ /********************************************************************** ** 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 "swapfile.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/resource.h> using namespace Opie::Core; /* QT */ #include <qfile.h> #include <qtextstream.h> #include <qlabel.h> #include <qtimer.h> #include <qlayout.h> #include <qpushbutton.h> #include <qhbuttongroup.h> #include <qradiobutton.h> #include <qlineedit.h> #include <qprogressbar.h> #include <qcombobox.h> #include <qvgroupbox.h> #include <qhbox.h> #include <qmessagebox.h> #include <qcopchannel_qws.h> /* STD */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/vfs.h> #include <mntent.h> #include <unistd.h> #include <sys/types.h> Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f ) : QWidget( parent, name, f ) { // are we running as root? isRoot = geteuid() == 0; QVBoxLayout* vb = new QVBoxLayout(this, 5); QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this); cfsdRBG->setRadioButtonExclusive(true); vb->addWidget(cfsdRBG); ramRB = new QRadioButton(tr("RAM"), cfsdRBG); cfRB = new QRadioButton(tr("CF Card"), cfsdRBG); sdRB = new QRadioButton(tr("SD Card"), cfsdRBG); QHBox *hb1 = new QHBox(this); hb1->setSpacing(5); swapPath1 = new QLineEdit(hb1); swapPath1->setEnabled(false); QPushButton* swapOn = new QPushButton(tr(" On "), hb1); QPushButton* swapOff = new QPushButton(tr(" Off "), hb1); vb->addWidget(hb1); QVGroupBox* box1 = new QVGroupBox(tr("Manage Swapfile"), this); vb->addWidget(box1); QHBox *hb2 = new QHBox(box1); hb2->setSpacing(5); QPushButton* mkSwap = new QPushButton(tr("Generate"), hb2); QPushButton* rmSwap = new QPushButton(tr("Remove"), hb2); QHBox *hb3 = new QHBox(box1); hb3->setSpacing(5); 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"))); mkswapProgress = new QProgressBar(3, hb3); mkswapProgress->setCenterIndicator(true); QHBox *hb4 = new QHBox(this); hb4->setSpacing(5); swapStatusIcon = new QLabel(hb4); swapStatus = new QLabel("", hb4); hb4->setStretchFactor(swapStatus, 99); vb->addWidget(hb4); connect(swapOn, SIGNAL(clicked()), this, SLOT(swapon())); connect(swapOff, SIGNAL(clicked()), this, SLOT(swapoff())); connect(cfRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); connect(sdRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); connect(ramRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); connect(mkSwap, SIGNAL(clicked()), this, SLOT(makeswapfile())); connect(rmSwap, SIGNAL(clicked()), this, SLOT(removeswapfile())); cfRB->setEnabled(FALSE); sdRB->setEnabled(FALSE); QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); connect(pcmciaChannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(cardnotify(const QCString&,const QByteArray&))); QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); connect(sdChannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(cardnotify(const QCString&,const QByteArray&))); cardInPcmcia0 = FALSE; cardInPcmcia1 = FALSE; cardInSd = FALSE; Swapfile::status(); Swapfile::getStatusPcmcia(); Swapfile::getStatusSd(); } int Swapfile::exec(const QString& arg) { return system((!isRoot ? "sudo " : "") + arg); } Swapfile::~Swapfile() { } void Swapfile::cardnotify(const QCString & msg, const QByteArray &) { if (msg == "stabChanged()") { getStatusPcmcia(); } else if (msg == "mtabChanged()") { getStatusSd(); } } void Swapfile::getStatusPcmcia() { bool cardWas0 = cardInPcmcia0; // remember last state bool cardWas1 = cardInPcmcia1; QString fileName; // one of these 3 files should exist if (QFile::exists("/var/run/stab")) { fileName = "/var/run/stab"; } else if (QFile::exists("/var/state/pcmcia/stab")) { fileName = "/var/state/pcmcia/stab"; } else { fileName = "/var/lib/pcmcia/stab"; } QFile f(fileName); if (f.open(IO_ReadOnly)) { QStringList list; QTextStream stream(&f); QString streamIn; streamIn = stream.read(); list = QStringList::split("\n", streamIn); for (QStringList::Iterator line = list.begin(); line != list.end(); line++) { if ((*line).startsWith("Socket 0:")) { if ((*line).startsWith("Socket 0: empty") && cardInPcmcia0) { cardInPcmcia0 = FALSE; } else if (!(*line).startsWith("Socket 0: empty") && !cardInPcmcia0) { cardInPcmcia0 = TRUE; } } else if ((*line).startsWith("Socket 1:")) { if ((*line).startsWith("Socket 1: empty") && cardInPcmcia1) { cardInPcmcia1 = FALSE; } else if (!(*line).startsWith("Socket 1: empty") && !cardInPcmcia1) { cardInPcmcia1 = TRUE; } } } f.close(); if (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) { QString text = QString::null; QString what = QString::null; if (cardWas0 != cardInPcmcia0) { if (cardInPcmcia0) { cfRB->setEnabled(TRUE); } else { cfRB->setChecked(FALSE); cfRB->setEnabled(FALSE); } } if (cardWas1 != cardInPcmcia1) { if (cardInPcmcia1) { cfRB->setEnabled(TRUE); } else { cfRB->setChecked(FALSE); cfRB->setEnabled(FALSE); } } } } else { // no file found odebug << "no file found" << oendl; cardInPcmcia0 = FALSE; cardInPcmcia1 = FALSE; } Swapfile::cfsdchecked(); } void Swapfile::getStatusSd() { bool cardWas = cardInSd; // remember last state cardInSd = FALSE; #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) struct mntent *me; FILE *mntfp = setmntent("/etc/mtab", "r"); if (mntfp) { while ((me = getmntent(mntfp)) != 0) { QString fs = me->mnt_fsname; if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd" || fs.left(9) == "/dev/mmcd") { cardInSd = TRUE; show(); } } endmntent(mntfp); } if (cardWas != cardInSd) { QString text = QString::null; QString what = QString::null; if (cardInSd) { sdRB->setEnabled(TRUE); } else { sdRB->setChecked(FALSE); sdRB->setEnabled(FALSE); } } #else #error "Not on Linux" #endif Swapfile::cfsdchecked(); } int rc=0; void Swapfile::swapon() { char swapcmd[128] ="swapon "; Swapfile::cfsdchecked(); strcat(swapcmd,swapPath1->text()); char *runcmd = swapcmd; rc = exec(QString("%1").arg(runcmd)); if (rc != 0) { setStatusMessage("Failed to attach swapfile.", true); } else { /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ setStatusMessage("Swapfile activated."); } Swapfile::status(); } void Swapfile::setStatusMessage(const QString& text, bool error /* = false */) { swapStatus->setText("<b>" + text + "</b>"); swapStatusIcon->setPixmap(Resource::loadPixmap(error ? "close" : "done")); } void Swapfile::swapoff() { char swapcmd[128] ="swapoff "; if (Swapfile::cfRB->isChecked() == TRUE) Swapfile::cfsdchecked(); strcat(swapcmd,swapPath1->text()); char *runcmd = swapcmd; rc = exec(QString("%1").arg(runcmd)); if (rc != 0) { setStatusMessage(tr("Failed to detach swapfile."), true); } else { /* QMessageBox::information(this, "Information", "Swapfile is inactive!"); */ setStatusMessage(tr("Swapfile deactivated.")); /* Swapfile::swapPath->clear();*/ } Swapfile::status(); } void Swapfile::cfsdchecked() { /* Swapfile::swapPath->clear();*/ Swapfile::swapPath1->clear(); if (Swapfile::ramRB->isChecked() == TRUE) { Swapfile::swapPath1->insert("/home/swapfile"); } if (Swapfile::sdRB->isChecked() == TRUE) { Swapfile::swapPath1->insert("/mnt/card/swapfile"); } if (Swapfile::cfRB->isChecked() == TRUE) { Swapfile::swapPath1->insert("/mnt/cf/swapfile"); } /* Swapfile::swapPath->insert(Swapfile::swapPath1->text());*/ } void Swapfile::makeswapfile() { int i = swapSize->currentItem(); mkswapProgress->setProgress(1); switch ( i ) { case 0: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=2048").arg(swapPath1->text())); break; case 1: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=4096").arg(swapPath1->text())); break; case 2: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=6144").arg(swapPath1->text())); break; case 3: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=8192").arg(swapPath1->text())); 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; + } if (rc != 0) { setStatusMessage(tr("Failed to create swapfile."), true); } mkswapProgress->setProgress(2); rc=exec(QString("mkswap %1").arg(swapPath1->text())); if (rc != 0) { setStatusMessage(tr("Failed to initialize swapfile."), true); } mkswapProgress->setProgress(3); mkswapProgress->reset(); setStatusMessage(tr("Swapfile created.")); } void Swapfile::removeswapfile() { exec(QString("swapoff %1").arg(swapPath1->text())); rc=exec(QString("rm -rf %1").arg(swapPath1->text())); if (rc != 0) { setStatusMessage(tr("Failed to remove swapfile."), true); } Swapfile::status(); Swapfile::cfsdchecked(); setStatusMessage(tr("Swapfile removed.")); } void Swapfile::status() { FILE *fp; char buffer[128], swapfile[128], temp[128]; int swapsize=2000, i=1; fp=fopen("/proc/swaps", "r"); while ( (fgets(buffer,128,fp)) != NULL ) { sscanf(buffer, "%s %s %d %s %s\n", swapfile, temp, &swapsize, temp, temp); } fclose(fp); ramRB->setChecked(FALSE); cfRB->setChecked(FALSE); sdRB->setChecked(FALSE); i=strcmp(swapfile, "/home/swapfile"); if ( i == 0 ) { ramRB->setChecked(TRUE); /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ setStatusMessage(tr("Swapfile activated.")); } i=strcmp(swapfile, "/usr/mnt.rom/cf/swapfile"); if ( i == 0 ) { cfRB->setChecked(TRUE); /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ setStatusMessage(tr("Swapfile activated.")); } i=strcmp(swapfile, "/mnt/cf/swapfile"); if ( i == 0 ) { cfRB->setChecked(TRUE); /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ setStatusMessage(tr("Swapfile activated.")); } i=strcmp(swapfile, "/usr/mnt.rom/card/swapfile"); if ( i == 0 ) { sdRB->setChecked(TRUE); /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ setStatusMessage(tr("Swapfile activated.")); } i=strcmp(swapfile, "/mnt/card/swapfile"); if ( i == 0 ) { sdRB->setChecked(TRUE); /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ setStatusMessage(tr("Swapfile activated.")); } Swapfile::cfsdchecked(); swapsize /=1000; switch ( swapsize ) { case 2: swapSize->setCurrentItem(0); break; case 4: swapSize->setCurrentItem(1); break; case 6: swapSize->setCurrentItem(2); break; case 8: swapSize->setCurrentItem(3); break; + case 16: swapSize->setCurrentItem(4); + break; + case 32: swapSize->setCurrentItem(5); + break; + case 64: swapSize->setCurrentItem(6); + break; } } |