summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/.cvsignore3
-rw-r--r--noncore/settings/sysinfo/Makefile.in193
-rw-r--r--noncore/settings/sysinfo/graph.cpp183
-rw-r--r--noncore/settings/sysinfo/graph.h89
-rw-r--r--noncore/settings/sysinfo/load.cpp207
-rw-r--r--noncore/settings/sysinfo/load.h60
-rw-r--r--noncore/settings/sysinfo/main.cpp34
-rw-r--r--noncore/settings/sysinfo/memory.cpp94
-rw-r--r--noncore/settings/sysinfo/memory.h48
-rw-r--r--noncore/settings/sysinfo/qpe-sysinfo.control9
-rw-r--r--noncore/settings/sysinfo/storage.cpp220
-rw-r--r--noncore/settings/sysinfo/storage.h87
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp53
-rw-r--r--noncore/settings/sysinfo/sysinfo.h29
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro25
-rw-r--r--noncore/settings/sysinfo/versioninfo.cpp109
-rw-r--r--noncore/settings/sysinfo/versioninfo.h34
17 files changed, 1477 insertions, 0 deletions
diff --git a/noncore/settings/sysinfo/.cvsignore b/noncore/settings/sysinfo/.cvsignore
new file mode 100644
index 0000000..edfa921
--- a/dev/null
+++ b/noncore/settings/sysinfo/.cvsignore
@@ -0,0 +1,3 @@
1moc_*
2*.moc
3Makefile
diff --git a/noncore/settings/sysinfo/Makefile.in b/noncore/settings/sysinfo/Makefile.in
new file mode 100644
index 0000000..1149304
--- a/dev/null
+++ b/noncore/settings/sysinfo/Makefile.in
@@ -0,0 +1,193 @@
1#############################################################################
2
3####### Compiler, tools and options
4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS)
9 INCPATH =-I$(QPEDIR)/include
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC)
14
15####### Target
16
17DESTDIR = $(QPEDIR)/bin/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= sysinfo
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =memory.h \
27 graph.h \
28 load.h \
29 storage.h \
30 versioninfo.h \
31 sysinfo.h
32 SOURCES =main.cpp \
33 memory.cpp \
34 graph.cpp \
35 load.cpp \
36 storage.cpp \
37 versioninfo.cpp \
38 sysinfo.cpp
39 OBJECTS =main.o \
40 memory.o \
41 graph.o \
42 load.o \
43 storage.o \
44 versioninfo.o \
45 sysinfo.o
46INTERFACES =
47UICDECLS =
48UICIMPLS =
49 SRCMOC =moc_memory.cpp \
50 moc_graph.cpp \
51 moc_load.cpp \
52 moc_storage.cpp \
53 moc_versioninfo.cpp \
54 moc_sysinfo.cpp
55 OBJMOC =moc_memory.o \
56 moc_graph.o \
57 moc_load.o \
58 moc_storage.o \
59 moc_versioninfo.o \
60 moc_sysinfo.o
61
62
63####### Implicit rules
64
65.SUFFIXES: .cpp .cxx .cc .C .c
66
67.cpp.o:
68 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
69
70.cxx.o:
71 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
72
73.cc.o:
74 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
75
76.C.o:
77 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
78
79.c.o:
80 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
81
82####### Build rules
83
84
85all: $(DESTDIR)$(TARGET)
86
87$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
88 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
89
90moc: $(SRCMOC)
91
92tmake:
93 tmake sysinfo.pro
94
95clean:
96 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
97 -rm -f *~ core
98 -rm -f allmoc.cpp
99
100####### Extension Modules
101
102listpromodules:
103 @echo
104
105listallmodules:
106 @echo
107
108listaddonpromodules:
109 @echo
110
111listaddonentmodules:
112 @echo
113
114
115REQUIRES=
116
117####### Sub-libraries
118
119
120###### Combined headers
121
122
123
124####### Compile
125
126main.o: main.cpp \
127 sysinfo.h \
128 $(QPEDIR)/include/qpe/qpeapplication.h
129
130memory.o: memory.cpp \
131 graph.h \
132 memory.h
133
134graph.o: graph.cpp \
135 graph.h
136
137load.o: load.cpp \
138 load.h
139
140storage.o: storage.cpp \
141 graph.h \
142 storage.h
143
144versioninfo.o: versioninfo.cpp \
145 $(QPEDIR)/include/qpe/resource.h \
146 $(QPEDIR)/include/qpe/version.h \
147 versioninfo.h
148
149sysinfo.o: sysinfo.cpp \
150 memory.h \
151 load.h \
152 storage.h \
153 versioninfo.h \
154 sysinfo.h \
155 $(QPEDIR)/include/qpe/resource.h
156
157moc_memory.o: moc_memory.cpp \
158 memory.h
159
160moc_graph.o: moc_graph.cpp \
161 graph.h
162
163moc_load.o: moc_load.cpp \
164 load.h
165
166moc_storage.o: moc_storage.cpp \
167 storage.h
168
169moc_versioninfo.o: moc_versioninfo.cpp \
170 versioninfo.h
171
172moc_sysinfo.o: moc_sysinfo.cpp \
173 sysinfo.h
174
175moc_memory.cpp: memory.h
176 $(MOC) memory.h -o moc_memory.cpp
177
178moc_graph.cpp: graph.h
179 $(MOC) graph.h -o moc_graph.cpp
180
181moc_load.cpp: load.h
182 $(MOC) load.h -o moc_load.cpp
183
184moc_storage.cpp: storage.h
185 $(MOC) storage.h -o moc_storage.cpp
186
187moc_versioninfo.cpp: versioninfo.h
188 $(MOC) versioninfo.h -o moc_versioninfo.cpp
189
190moc_sysinfo.cpp: sysinfo.h
191 $(MOC) sysinfo.h -o moc_sysinfo.cpp
192
193
diff --git a/noncore/settings/sysinfo/graph.cpp b/noncore/settings/sysinfo/graph.cpp
new file mode 100644
index 0000000..0b02bf7
--- a/dev/null
+++ b/noncore/settings/sysinfo/graph.cpp
@@ -0,0 +1,183 @@
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
21#include <qpainter.h>
22#include <qpixmap.h>
23#include "graph.h"
24
25void GraphData::clear()
26{
27 names.clear();
28 values.resize(0);
29}
30
31void GraphData::addItem( const QString &name, int value )
32{
33 names.append( name );
34 values.resize( values.size() + 1 );
35 values[values.size()-1] = value;
36}
37
38Graph::Graph(QWidget *parent, const char *name, WFlags f )
39 : QFrame( parent, name, f )
40{
41}
42
43PieGraph::PieGraph(QWidget *parent, const char *name, WFlags f )
44 : Graph( parent, name, f )
45{
46}
47
48void PieGraph::drawContents( QPainter *p )
49{
50 int size = QMIN( contentsRect().width(), contentsRect().height() ) - 1;
51
52 int total = 0;
53 for ( unsigned i = 0; i < data->count(); i++ )
54 total += data->value(i);
55
56 int angle = 0;
57 for ( unsigned i = 0; i < data->count(); i++ ) {
58 int len;
59 if ( i == data->count() - 1 || !total )
60 len = 5760 - angle;
61 else
62 len = data->value(i) * 5760 / total;
63 QColor col;
64 col.setHsv( i * 360 / data->count(), 255, 255 );
65 p->setBrush( col );
66 p->drawPie ( contentsRect().x(), contentsRect().y(),
67 size, size, angle, len+32 );
68 angle += len;
69 }
70}
71
72BarGraph::BarGraph(QWidget *parent, const char *name, WFlags f )
73 : Graph( parent, name, f )
74{
75 setMinimumHeight( 10 );
76 setMaximumHeight( 45 );
77}
78
79void BarGraph::drawContents( QPainter *p )
80{
81 int h = contentsRect().height();
82 int y = contentsRect().top();
83
84 int total = 0;
85 for ( unsigned i = 0; i < data->count(); i++ )
86 total += data->value(i);
87
88 int pos = 0;
89 for ( unsigned i = 0; i < data->count(); i++ ) {
90 int len;
91 if ( i == data->count() - 1 || !total )
92 len = contentsRect().width() - pos;
93 else
94 len = data->value(i) * contentsRect().width() / total;
95 QColor col;
96 col.setHsv( i * 360 / data->count(), 255, 255 );
97 drawSegment( p, QRect(contentsRect().x() + pos, y, len, h), col );
98 pos += len;
99 }
100}
101
102void BarGraph::drawSegment( QPainter *p, const QRect &r, const QColor &c )
103{
104 if ( QPixmap::defaultDepth() > 8 ) {
105 QColor topgrad = c.light(170);
106 QColor botgrad = c.dark();
107
108 int h1, h2, s1, s2, v1, v2;
109 topgrad.hsv( &h1, &s1, &v1 );
110 botgrad.hsv( &h2, &s2, &v2 );
111 int ng = r.height();
112 for ( int j =0; j < ng; j++ ) {
113 p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1),
114 s1 + ((s2-s1)*j)/(ng-1),
115 v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
116 p->drawLine( r.x(), r.top()+j, r.x()+r.width(), r.top()+j );
117 }
118 } else {
119 p->fillRect( r.x(), r.top(), r.width(), r.height(), c );
120 }
121}
122
123
124GraphLegend::GraphLegend( QWidget *parent, const char *name, WFlags f )
125 : QFrame( parent, name, f )
126{
127 horz = FALSE;
128}
129
130void GraphLegend::setOrientation(Orientation o)
131{
132 horz = o == Horizontal;
133}
134
135void GraphLegend::drawContents( QPainter *p )
136{
137 int total = 0;
138 for ( unsigned i = 0; i < data->count(); i++ )
139 total += data->value(i);
140
141 int tw = width()/data->count()-1;
142 int th = height()/(horz ? 1 : data->count());
143 if ( th > p->fontMetrics().height() )
144 th = p->fontMetrics().height();
145 int x = 0;
146 int y = 0;
147 for ( unsigned i = 0; i < data->count(); i++ ) {
148 QColor col;
149 col.setHsv( i * 360 / data->count(), 255, 255 );
150 p->setBrush( col );
151 p->drawRect( x+1, y+1, th - 2, th - 2 );
152 p->drawText( x+th + 1, y + p->fontMetrics().ascent()+1, data->name(i) );
153 if ( horz ) {
154 x += tw;
155 } else {
156 y += th;
157 }
158 }
159}
160
161QSize GraphLegend::sizeHint() const
162{
163 int th = fontMetrics().height() + 2;
164 int maxw = 0;
165 for ( unsigned i = 0; i < data->count(); i++ ) {
166 int w = fontMetrics().width( data->name(i) );
167 if ( w > maxw )
168 maxw = w;
169 }
170 if ( 0 && horz ) {
171 return QSize( maxw * data->count(), th );
172 } else {
173 return QSize( maxw, th * data->count() );
174 }
175}
176
177void GraphLegend::setData( const GraphData *p )
178{
179 data = p;
180 int th = fontMetrics().height();
181 setMinimumHeight( th * ( horz ? 1 : data->count() ) );
182 updateGeometry();
183}
diff --git a/noncore/settings/sysinfo/graph.h b/noncore/settings/sysinfo/graph.h
new file mode 100644
index 0000000..5a65e79
--- a/dev/null
+++ b/noncore/settings/sysinfo/graph.h
@@ -0,0 +1,89 @@
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
21#include <qframe.h>
22#include <qarray.h>
23#include <qstringlist.h>
24
25class GraphData
26{
27public:
28 void clear();
29 void addItem( const QString &name, int value );
30
31 const QString &name( int i ) const { return names[i]; }
32 int value( int i ) const { return values[i]; }
33 unsigned count() const { return values.size(); }
34
35private:
36 QStringList names;
37 QArray<int> values;
38};
39
40class Graph : public QFrame
41{
42 Q_OBJECT
43public:
44 Graph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
45
46 void setData( const GraphData *p ) { data = p; }
47
48protected:
49 const GraphData *data;
50};
51
52class PieGraph : public Graph
53{
54 Q_OBJECT
55public:
56 PieGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
57
58protected:
59 virtual void drawContents( QPainter *p );
60};
61
62class BarGraph : public Graph
63{
64 Q_OBJECT
65public:
66 BarGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
67
68protected:
69 virtual void drawContents( QPainter *p );
70 void drawSegment( QPainter *p, const QRect &r, const QColor &c );
71};
72
73class GraphLegend : public QFrame
74{
75 Q_OBJECT
76public:
77 GraphLegend( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
78
79 void setData( const GraphData *p );
80 virtual QSize sizeHint() const;
81 void setOrientation(Orientation o);
82
83protected:
84 virtual void drawContents( QPainter *p );
85
86private:
87 const GraphData *data;
88 bool horz;
89};
diff --git a/noncore/settings/sysinfo/load.cpp b/noncore/settings/sysinfo/load.cpp
new file mode 100644
index 0000000..0fcfa6b
--- a/dev/null
+++ b/noncore/settings/sysinfo/load.cpp
@@ -0,0 +1,207 @@
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
21#include <stdio.h>
22#include <qlayout.h>
23#include <qlabel.h>
24#include <qpainter.h>
25#include <qpixmap.h>
26#include <qtimer.h>
27#include <qfile.h>
28#include <qtextstream.h>
29#include "load.h"
30
31LoadInfo::LoadInfo( QWidget *parent, const char *name, WFlags f )
32 : QWidget( parent, name, f )
33{
34 QVBoxLayout *vb = new QVBoxLayout( this, 6 );
35
36 QString cpuInfo = getCpuInfo();
37 if ( !cpuInfo.isNull() )
38 vb->addWidget( new QLabel( cpuInfo, this ) );
39 vb->addWidget( new Load( this ), 100 );
40 QLabel *l = new QLabel( this );
41 l->setPixmap( makeLabel( red, tr("Application CPU usage (%)") ) );
42 vb->addWidget( l, 1 );
43 l = new QLabel( this );
44 l->setPixmap( makeLabel( green, tr("System CPU usage (%)") ) );
45 vb->addWidget( l, 1 );
46 vb->addStretch(50);
47}
48
49QPixmap LoadInfo::makeLabel( const QColor &col, const QString &text )
50{
51 int h = fontMetrics().height();
52 QPixmap pm( 20 + fontMetrics().width( text ), h );
53 QPainter p( &pm );
54 p.fillRect( pm.rect(), colorGroup().background() );
55 p.fillRect( 0, h/2-4, 18, h/2+3, black );
56 p.setPen( col );
57 p.drawLine( 2, h/2, 15, h/2 );
58 p.setPen( colorGroup().text() );
59 p.drawText( 20, fontMetrics().ascent(), text );
60
61 return pm;
62}
63
64QString LoadInfo::getCpuInfo()
65{
66 bool haveInfo = FALSE;
67 QString info = tr("Type: ");
68 QFile f( "/proc/cpuinfo" );
69 if ( f.open( IO_ReadOnly ) ) {
70 QTextStream ts( &f );
71
72 while ( !ts.atEnd() ) {
73 QString s = ts.readLine();
74 if ( s.find( "model name" ) == 0 ) {
75 info += s.mid( s.find( ':' ) + 2 );
76 haveInfo = TRUE;
77 } else if ( s.find( "cpu MHz" ) == 0 ) {
78 double mhz = s.mid( s.find( ':' ) + 2 ).toDouble();
79 info += " " + QString::number( mhz, 'f', 0 );
80 info += "MHz";
81 break;
82 } else if ( s.find( "Processor" ) == 0 ) {
83 info += s.mid( s.find( ':' ) + 2 );
84 haveInfo = TRUE;
85 break;
86#ifdef __MIPSEL__
87 } else if ( s.find( "cpu model" ) == 0 ) {
88 info += " " + s.mid( s.find( ':' ) + 2 );
89 break;
90 } else if ( s.find( "cpu" ) == 0 ) {
91 info += s.mid( s.find( ':' ) + 2 );
92 haveInfo = TRUE;
93#endif
94 }
95 }
96 }
97
98 if ( !haveInfo )
99 info = QString();
100
101 return info;
102}
103
104Load::Load( QWidget *parent, const char *name, WFlags f )
105 : QWidget( parent, name, f )
106{
107 setMinimumHeight( 30 );
108 setBackgroundColor( black );
109 points = 100;
110 setMinimumWidth( points );
111 userLoad = new double [points];
112 systemLoad = new double [points];
113 for ( int i = 0; i < points; i++ ) {
114 userLoad[i] = 0.0;
115 systemLoad[i] = 0.0;
116 }
117 maxLoad = 1.3;
118 QTimer *timer = new QTimer( this );
119 connect( timer, SIGNAL(timeout()), SLOT(timeout()) );
120 timer->start( 2000 );
121 gettimeofday( &last, 0 );
122 first = TRUE;
123 timeout();
124}
125
126void Load::paintEvent( QPaintEvent *ev )
127{
128 QPainter p( this );
129
130 int h = height() - 5;
131
132 int mult = (int)(h / maxLoad);
133
134 p.setPen( gray );
135 p.drawLine( 0, h - mult, width(), h - mult );
136 p.drawText( 0, h - mult, "100" );
137 p.drawText( 0, h, "0" );
138
139 p.setPen( green );
140 for ( int i = 1; i < points; i++ ) {
141 int x1 = (i - 1) * width() / points;
142 int x2 = i * width() / points;
143 p.drawLine( x1, h - systemLoad[i-1] * mult,
144 x2, h - systemLoad[i] * mult );
145 }
146
147 p.setPen( red );
148 for ( int i = 1; i < points; i++ ) {
149 int x1 = (i - 1) * width() / points;
150 int x2 = i * width() / points;
151 p.drawLine( x1, h - userLoad[i-1] * mult,
152 x2, h - userLoad[i] * mult );
153 }
154}
155
156void Load::timeout()
157{
158 int user;
159 int usernice;
160 int sys;
161 int idle;
162 FILE *fp;
163 fp = fopen( "/proc/stat", "r" );
164 fscanf( fp, "cpu %d %d %d %d", &user, &usernice, &sys, &idle );
165 fclose( fp );
166 struct timeval now;
167 gettimeofday( &now, 0 );
168 int tdiff = now.tv_usec - last.tv_usec;
169 tdiff += (now.tv_sec - last.tv_sec) * 1000000;
170 tdiff /= 10000;
171
172 int udiff = user - lastUser;
173 int sdiff = sys - lastSys;
174 if ( tdiff > 0 ) {
175 double uload = (double)udiff / (double)tdiff;
176 double sload = (double)sdiff / (double)tdiff;
177 if ( !first ) {
178 for ( int i = 1; i < points; i++ ) {
179 userLoad[i-1] = userLoad[i];
180 systemLoad[i-1] = systemLoad[i];
181 }
182 userLoad[points-1] = uload;
183 systemLoad[points-1] = sload;
184 // scroll( -width()/points, 0, QRect( 0, 0, width() - width()/points + 1, height() ) );
185 repaint( TRUE );
186 double ml = 1.3;
187 /*
188 for ( int i = 0; i < points; i++ ) {
189 if ( userLoad[i] > ml )
190 ml = userLoad[i];
191 }
192 */
193 if ( maxLoad != ml ) {
194 maxLoad = ml;
195 update();
196 }
197 }
198
199 last = now;
200 lastUser = user;
201 lastSys = sys;
202 first = FALSE;
203 } else if ( tdiff < 0 ) {
204 last = now;
205 }
206}
207
diff --git a/noncore/settings/sysinfo/load.h b/noncore/settings/sysinfo/load.h
new file mode 100644
index 0000000..e7f5388
--- a/dev/null
+++ b/noncore/settings/sysinfo/load.h
@@ -0,0 +1,60 @@
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
21#include <sys/time.h>
22#include <qwidget.h>
23
24/*
25 Little load meter
26*/
27class Load : public QWidget {
28 Q_OBJECT
29public:
30 Load( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
31
32protected:
33 void paintEvent( QPaintEvent *ev );
34
35private slots:
36 void timeout();
37
38private:
39 int points;
40 double *userLoad;
41 double *systemLoad;
42 double maxLoad;
43 struct timeval last;
44 int lastUser;
45 int lastUsernice;
46 int lastSys;
47 int lastIdle;
48 bool first;
49};
50
51class LoadInfo : public QWidget
52{
53 Q_OBJECT
54public:
55 LoadInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
56
57private:
58 QPixmap makeLabel( const QColor &col, const QString &text );
59 QString getCpuInfo();
60};
diff --git a/noncore/settings/sysinfo/main.cpp b/noncore/settings/sysinfo/main.cpp
new file mode 100644
index 0000000..6e889db
--- a/dev/null
+++ b/noncore/settings/sysinfo/main.cpp
@@ -0,0 +1,34 @@
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
21#include "sysinfo.h"
22
23#include <qpe/qpeapplication.h>
24
25int main( int argc, char *argv[] )
26{
27 QPEApplication a( argc, argv );
28
29 SystemInfo *si = new SystemInfo();
30 a.showMainWidget( si );
31
32 return a.exec();
33}
34
diff --git a/noncore/settings/sysinfo/memory.cpp b/noncore/settings/sysinfo/memory.cpp
new file mode 100644
index 0000000..781f0df
--- a/dev/null
+++ b/noncore/settings/sysinfo/memory.cpp
@@ -0,0 +1,94 @@
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
21#include <qlabel.h>
22#include <qtimer.h>
23#include <qfile.h>
24#include <qtextstream.h>
25#include <qlayout.h>
26#include "graph.h"
27#include "memory.h"
28
29MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags f )
30 : QWidget( parent, name, f )
31{
32 QVBoxLayout *vb = new QVBoxLayout( this, 5 );
33
34 totalMem = new QLabel( this );
35 vb->addWidget( totalMem );
36
37 data = new GraphData();
38// graph = new PieGraph( this );
39 graph = new BarGraph( this );
40 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
41 vb->addWidget( graph, 1 );
42 graph->setData( data );
43
44 legend = new GraphLegend( this );
45 vb->addWidget( legend );
46 legend->setData( data );
47
48 vb->addStretch( 1 );
49 updateData();
50
51 QTimer *t = new QTimer( this );
52 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
53 t->start( 5000 );
54}
55
56MemoryInfo::~MemoryInfo()
57{
58 delete data;
59}
60
61void MemoryInfo::updateData()
62{
63 QFile file( "/proc/meminfo" );
64
65 if ( file.open( IO_ReadOnly ) ) {
66 QTextStream t( &file );
67 QString dummy = t.readLine();// title
68 t >> dummy;
69 int total, used, memfree, shared, buffers, cached;
70 t >> total;
71 total /= 1000;
72 t >> used;
73 used /= 1000;
74 t >> memfree;
75 memfree /= 1000;
76 t >> shared;
77 shared /= 1000;
78 t >> buffers;
79 buffers /= 1000;
80 t >> cached;
81 cached /= 1000;
82 int realUsed = total - ( buffers + cached + memfree );
83 data->clear();
84 data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed );
85 data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers );
86 data->addItem( tr("Cached (%1 kB)").arg(cached), cached );
87 data->addItem( tr("Free (%1 kB)").arg(memfree), memfree );
88 totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) );
89 graph->repaint( FALSE );
90 legend->update();
91 }
92}
93
94
diff --git a/noncore/settings/sysinfo/memory.h b/noncore/settings/sysinfo/memory.h
new file mode 100644
index 0000000..696f97c
--- a/dev/null
+++ b/noncore/settings/sysinfo/memory.h
@@ -0,0 +1,48 @@
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
21#ifndef MEMORY_H
22#define MEMORY_H
23
24#include <qwidget.h>
25
26class GraphData;
27class Graph;
28class GraphLegend;
29class QLabel;
30
31class MemoryInfo : public QWidget
32{
33 Q_OBJECT
34public:
35 MemoryInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
36 ~MemoryInfo();
37
38private slots:
39 void updateData();
40
41private:
42 QLabel *totalMem;
43 GraphData *data;
44 Graph *graph;
45 GraphLegend *legend;
46};
47
48#endif
diff --git a/noncore/settings/sysinfo/qpe-sysinfo.control b/noncore/settings/sysinfo/qpe-sysinfo.control
new file mode 100644
index 0000000..e5ed583
--- a/dev/null
+++ b/noncore/settings/sysinfo/qpe-sysinfo.control
@@ -0,0 +1,9 @@
1Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/qpe-logo.png pics/tux-logo.png
2Priority: optional
3Section: qpe/applications
4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm
6Version: $QPE_VERSION-3
7Depends: qpe-base ($QPE_VERSION)
8Description: System Information dialog
9 For the Qtopia environment.
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
new file mode 100644
index 0000000..4e81170
--- a/dev/null
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -0,0 +1,220 @@
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
21#include <qlabel.h>
22#include <qlayout.h>
23#include <qtimer.h>
24#include <qlayout.h>
25#include "graph.h"
26#include "storage.h"
27
28#include <stdio.h>
29#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
30#include <sys/vfs.h>
31#include <mntent.h>
32#endif
33
34StorageInfo::StorageInfo( QWidget *parent, const char *name )
35 : QWidget( parent, name )
36{
37 vb = 0;
38 disks.setAutoDelete(TRUE);
39 lines.setAutoDelete(TRUE);
40 updateMounts();
41 startTimer( 5000 );
42}
43
44void StorageInfo::timerEvent(QTimerEvent*)
45{
46 updateMounts();
47}
48
49static bool isCF(const QString& m)
50{
51 FILE* f = fopen("/var/run/stab", "r");
52 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
53 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
54 if ( f ) {
55 char line[1024];
56 char devtype[80];
57 char devname[80];
58 while ( fgets( line, 1024, f ) ) {
59 // 0 ide ide-cs 0 hda 3 0
60 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
61 {
62 if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
63 fclose(f);
64 return TRUE;
65 }
66 }
67 }
68 fclose(f);
69 }
70 return FALSE;
71}
72
73void StorageInfo::updateMounts()
74{
75#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
76 struct mntent *me;
77 FILE *mntfp = setmntent( "/etc/mtab", "r" );
78 QStringList curdisks;
79 QStringList curfs;
80 bool rebuild = FALSE;
81 int n=0;
82 if ( mntfp ) {
83 while ( (me = getmntent( mntfp )) != 0 ) {
84 QString fs = me->mnt_fsname;
85 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
86 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" )
87 {
88 n++;
89 curdisks.append(fs);
90 QString d = me->mnt_dir;
91 curfs.append(d);
92 if ( !disks.find(d) )
93 rebuild = TRUE;
94 }
95 }
96 endmntent( mntfp );
97 }
98 if ( rebuild || n != (int)disks.count() ) {
99 disks.clear();
100 lines.clear();
101 delete vb;
102 vb = new QVBoxLayout( this, n > 3 ? 1 : 5 );
103 bool frst=TRUE;
104 QStringList::ConstIterator it=curdisks.begin();
105 QStringList::ConstIterator fsit=curfs.begin();
106 for (; it!=curdisks.end(); ++it, ++fsit) {
107 if ( !frst ) {
108 QFrame *f = new QFrame( this );
109 vb->addWidget(f);
110 f->setFrameStyle( QFrame::HLine | QFrame::Sunken );
111 lines.append(f);
112 f->show();
113 } frst=FALSE;
114 QString humanname=*it;
115 if ( isCF(humanname) )
116 humanname = tr("CF Card");
117 else if ( humanname == "/dev/hda1" )
118 humanname = tr("Hard Disk");
119 else if ( humanname.left(9) == "/dev/mmcd" )
120 humanname = tr("SD Card");
121 else if ( humanname.left(7) == "/dev/hd" )
122 humanname = tr("Hard Disk") + " " + humanname.mid(7);
123 else if ( humanname.left(7) == "/dev/sd" )
124 humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7);
125 else if ( humanname == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
126 humanname = tr("Internal Storage");
127 else if ( humanname.left(14) == "/dev/mtdblock/" )
128 humanname = tr("Internal Storage") + " " + humanname.mid(14);
129 else if ( humanname.left(13) == "/dev/mtdblock" )
130 humanname = tr("Internal Storage") + " " + humanname.mid(13);
131 // etc.
132 MountInfo* mi = new MountInfo( *fsit, humanname, this );
133 vb->addWidget(mi);
134 disks.insert(*fsit,mi);
135 mi->show();
136 }
137 vb->addStretch();
138 } else {
139 // just update them
140 for (QDictIterator<MountInfo> i(disks); i.current(); ++i)
141 i.current()->updateData();
142 }
143#endif
144}
145
146
147MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name )
148 : QWidget( parent, name ), title(ttl)
149{
150 fs = new FileSystem( path );
151 QVBoxLayout *vb = new QVBoxLayout( this, 3 );
152
153 totalSize = new QLabel( this );
154 vb->addWidget( totalSize );
155
156 data = new GraphData();
157 graph = new BarGraph( this );
158 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
159 vb->addWidget( graph, 1 );
160 graph->setData( data );
161
162 legend = new GraphLegend( this );
163 legend->setOrientation(Horizontal);
164 vb->addWidget( legend );
165 legend->setData( data );
166
167 updateData();
168}
169
170MountInfo::~MountInfo()
171{
172 delete data;
173 delete fs;
174}
175
176void MountInfo::updateData()
177{
178 fs->update();
179
180 long mult = fs->blockSize() / 1024;
181 long div = 1024 / fs->blockSize();
182 if ( !mult ) mult = 1;
183 if ( !div ) div = 1;
184 long total = fs->totalBlocks() * mult / div;
185 long avail = fs->availBlocks() * mult / div;
186 long used = total - avail;
187 totalSize->setText( title + tr(" total: %1 kB").arg( total ) );
188 data->clear();
189 data->addItem( tr("Used (%1 kB)").arg(used), used );
190 data->addItem( tr("Available (%1 kB)").arg(avail), avail );
191 graph->repaint( FALSE );
192 legend->update();
193 graph->show();
194 legend->show();
195}
196
197//---------------------------------------------------------------------------
198
199FileSystem::FileSystem( const QString &p )
200 : fspath( p ), blkSize(512), totalBlks(0), availBlks(0)
201{
202 update();
203}
204
205void FileSystem::update()
206{
207#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
208 struct statfs fs;
209 if ( !statfs( fspath.latin1(), &fs ) ) {
210 blkSize = fs.f_bsize;
211 totalBlks = fs.f_blocks;
212 availBlks = fs.f_bavail;
213 } else {
214 blkSize = 0;
215 totalBlks = 0;
216 availBlks = 0;
217 }
218#endif
219}
220
diff --git a/noncore/settings/sysinfo/storage.h b/noncore/settings/sysinfo/storage.h
new file mode 100644
index 0000000..3fa5b79
--- a/dev/null
+++ b/noncore/settings/sysinfo/storage.h
@@ -0,0 +1,87 @@
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 <qwidget.h>
21#include <qframe.h>
22#include <qlist.h>
23#include <qdict.h>
24
25class QLabel;
26class GraphData;
27class Graph;
28class GraphLegend;
29class FileSystem;
30class MountInfo;
31class QVBoxLayout;
32
33
34class StorageInfo : public QWidget
35{
36 Q_OBJECT
37public:
38 StorageInfo( QWidget *parent=0, const char *name=0 );
39
40protected:
41 void timerEvent(QTimerEvent*);
42
43private:
44 void updateMounts();
45 QDict<MountInfo> disks;
46 QList<QFrame> lines;
47 QVBoxLayout *vb;
48};
49
50class MountInfo : public QWidget
51{
52 Q_OBJECT
53public:
54 MountInfo( const QString &path, const QString &ttl, QWidget *parent=0, const char *name=0 );
55 ~MountInfo();
56
57 void updateData();
58
59private:
60 QString title;
61 FileSystem *fs;
62 QLabel *totalSize;
63 GraphData *data;
64 Graph *graph;
65 GraphLegend *legend;
66};
67
68class FileSystem
69{
70public:
71 FileSystem( const QString &p );
72
73 void update();
74
75 const QString &path() const { return fspath; }
76 long blockSize() const { return blkSize; }
77 long totalBlocks() const { return totalBlks; }
78 long availBlocks() const { return availBlks; }
79
80private:
81 QString fspath;
82 long blkSize;
83 long totalBlks;
84 long availBlks;
85};
86
87
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
new file mode 100644
index 0000000..bc483aa
--- a/dev/null
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -0,0 +1,53 @@
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
21#include "memory.h"
22#include "load.h"
23#include "storage.h"
24//#include "graphics.h"
25#include "versioninfo.h"
26#include "sysinfo.h"
27
28
29#include <qpe/resource.h>
30
31#include <qtabwidget.h>
32#include <qlayout.h>
33
34SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
35 : QWidget( parent, name, f )
36{
37 setIcon( Resource::loadPixmap( "system_icon" ) );
38 setCaption( tr("System Info") );
39 QVBoxLayout *lay = new QVBoxLayout( this );
40 QTabWidget *tab = new QTabWidget( this );
41 lay->addWidget( tab );
42 tab->addTab( new MemoryInfo( tab ), tr("Memory") );
43#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
44 tab->addTab( new StorageInfo( tab ), tr("Storage") );
45#endif
46 tab->addTab( new LoadInfo( tab ), tr("CPU") );
47// tab->addTab( new Graphics( tab ), tr("Graphics") );
48 tab->addTab( new VersionInfo( tab ), tr("Version") );
49
50 resize( 220, 180 );
51}
52
53
diff --git a/noncore/settings/sysinfo/sysinfo.h b/noncore/settings/sysinfo/sysinfo.h
new file mode 100644
index 0000000..abbf955
--- a/dev/null
+++ b/noncore/settings/sysinfo/sysinfo.h
@@ -0,0 +1,29 @@
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
21#include <qwidget.h>
22
23class SystemInfo : public QWidget
24{
25 Q_OBJECT
26public:
27 SystemInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
28};
29
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
new file mode 100644
index 0000000..0c7d907
--- a/dev/null
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -0,0 +1,25 @@
1 TEMPLATE= app
2 CONFIG = qt warn_on release
3 DESTDIR = $(QPEDIR)/bin
4 HEADERS = memory.h \
5 graph.h \
6 load.h \
7 storage.h \
8 versioninfo.h \
9 sysinfo.h
10 SOURCES = main.cpp \
11 memory.cpp \
12 graph.cpp \
13 load.cpp \
14 storage.cpp \
15 versioninfo.cpp \
16 sysinfo.cpp
17 INTERFACES=
18
19INCLUDEPATH += $(QPEDIR)/include
20 DEPENDPATH+= $(QPEDIR)/include
21LIBS += -lqpe
22
23 TARGET = sysinfo
24
25TRANSLATIONS = ../i18n/de/sysinfo.ts
diff --git a/noncore/settings/sysinfo/versioninfo.cpp b/noncore/settings/sysinfo/versioninfo.cpp
new file mode 100644
index 0000000..d60a445
--- a/dev/null
+++ b/noncore/settings/sysinfo/versioninfo.cpp
@@ -0,0 +1,109 @@
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
21#include <qpe/resource.h>
22#include <qpe/version.h>
23
24#include <qlabel.h>
25#include <qpixmap.h>
26#include <qpainter.h>
27#include <qimage.h>
28#include <qtimer.h>
29#include <qfile.h>
30#include <qtextstream.h>
31#include <qlayout.h>
32#include "versioninfo.h"
33
34VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
35 : QWidget( parent, name, f )
36{
37 setMinimumSize( 200, 150 );
38
39 QVBoxLayout *vb = new QVBoxLayout( this, 4 );
40
41 QString kernelVersionString;
42 QFile file( "/proc/version" );
43 if ( file.open( IO_ReadOnly ) ) {
44 QTextStream t( &file );
45 QString v;
46 t >> v; t >> v; t >> v;
47 v = v.left( 20 );
48 kernelVersionString = tr( "<b>Linux Kernel</b><p>Version: " ) + v + "<p>";
49 t >> v;
50 kernelVersionString += tr( "Compiled by: " ) + v;
51 file.close();
52 }
53
54 QString palmtopVersionString;
55 palmtopVersionString = tr( "<b>Qtopia</b><p>Version: " ) + QPE_VERSION + "<p>";
56#ifdef QPE_VENDOR
57 QString builder = QPE_VENDOR;
58#else
59 QString builder = "Unknown";
60#endif
61 palmtopVersionString += tr( "Compiled by: " ) + builder + "<p>";
62 palmtopVersionString += tr( "Built on: " ) + __DATE__;
63
64
65 QHBoxLayout *hb1 = new QHBoxLayout( vb );
66 hb1->setSpacing( 2 );
67
68 QLabel *palmtopLogo = new QLabel( this );
69 QImage logo1 = Resource::loadImage( "qpe-logo" );
70 logo1 = logo1.smoothScale( 50, 55 );
71 QPixmap logo1Pixmap;
72 logo1Pixmap.convertFromImage( logo1 );
73 palmtopLogo->setPixmap( logo1Pixmap );
74 palmtopLogo->setFixedSize( 60, 60 );
75 hb1->addWidget( palmtopLogo, 0, Qt::AlignTop + Qt::AlignLeft );
76
77 QLabel *palmtopVersion = new QLabel( this );
78 palmtopVersion->setText( palmtopVersionString );
79 hb1->addWidget( palmtopVersion, 1, Qt::AlignTop + Qt::AlignLeft );
80
81
82 QHBoxLayout *hb2 = new QHBoxLayout( vb );
83 hb1->setSpacing( 2 );
84
85 QLabel *linuxLogo = new QLabel( this );
86
87 // Need to do this extra qpainter code with this image becuase for some
88 // reason it doesn't alpha belnd if directly converted to a pixmap
89 QPixmap logo2Pixmap( 60, 60 );
90 QColor bgColor = colorGroup().background();
91 QPainter painter( &logo2Pixmap );
92 painter.fillRect( QRect( 0, 0, 60, 60 ), QBrush( bgColor ) );
93 QImage logo2 = Resource::loadImage( "tux-logo" );
94 logo2 = logo2.smoothScale( 40, 47 );
95 painter.drawImage( 0, 0, logo2 );
96 painter.end();
97 linuxLogo->setPixmap( logo2Pixmap );
98 linuxLogo->setFixedSize( 60, 60 );
99 hb2->addWidget( linuxLogo, 0, Qt::AlignTop + Qt::AlignLeft );
100
101 QLabel *kernelVersion = new QLabel( this );
102 kernelVersion->setText( kernelVersionString );
103 hb2->addWidget( kernelVersion, 1, Qt::AlignTop + Qt::AlignLeft );
104}
105
106VersionInfo::~VersionInfo()
107{
108}
109
diff --git a/noncore/settings/sysinfo/versioninfo.h b/noncore/settings/sysinfo/versioninfo.h
new file mode 100644
index 0000000..1b5c851
--- a/dev/null
+++ b/noncore/settings/sysinfo/versioninfo.h
@@ -0,0 +1,34 @@
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
21#ifndef VERSIONINFO_H
22#define VERSIONINFO_H
23
24#include <qwidget.h>
25
26class VersionInfo : public QWidget
27{
28 Q_OBJECT
29public:
30 VersionInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
31 ~VersionInfo();
32};
33
34#endif