00001 /********************************************************************** 00002 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 00021 #include <sys/time.h> 00022 #include <qwidget.h> 00023 00024 /* 00025 Little load meter 00026 */ 00027 class Load : public QWidget { 00028 Q_OBJECT 00029 public: 00030 Load( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 00031 00032 protected: 00033 void paintEvent( QPaintEvent *ev ); 00034 00035 private slots: 00036 void timeout(); 00037 00038 private: 00039 int points; 00040 double *userLoad; 00041 double *systemLoad; 00042 double maxLoad; 00043 struct timeval last; 00044 int lastUser; 00045 int lastUsernice; 00046 int lastSys; 00047 int lastIdle; 00048 bool first; 00049 }; 00050 00051 class LoadInfo : public QWidget 00052 { 00053 Q_OBJECT 00054 public: 00055 LoadInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 00056 00057 private: 00058 QPixmap makeLabel( const QColor &col, const QString &text ); 00059 QString getCpuInfo(); 00060 };
1.4.2