author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /noncore/settings | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
34 files changed, 2530 insertions, 0 deletions
diff --git a/noncore/settings/.cvsignore b/noncore/settings/.cvsignore new file mode 100644 index 0000000..e3d8c4b --- a/dev/null +++ b/noncore/settings/.cvsignore | |||
@@ -0,0 +1,13 @@ | |||
1 | moc_* | ||
2 | *.moc | ||
3 | Makefile | ||
4 | appearancesettingsbase.h | ||
5 | soundsettingsbase.h | ||
6 | lightsettingsbase.h | ||
7 | languagesettingsbase.cpp | ||
8 | rotationsettingsbase.cpp | ||
9 | appearancesettingsbase.cpp | ||
10 | lightsettingsbase.cpp | ||
11 | languagesettingsbase.h | ||
12 | rotationsettingsbase.h | ||
13 | soundsettingsbase.cpp | ||
diff --git a/noncore/settings/language/.cvsignore b/noncore/settings/language/.cvsignore new file mode 100644 index 0000000..30ff791 --- a/dev/null +++ b/noncore/settings/language/.cvsignore | |||
@@ -0,0 +1,4 @@ | |||
1 | moc_* | ||
2 | Makefile | ||
3 | languagesettingsbase.h | ||
4 | languagesettingsbase.cpp | ||
diff --git a/noncore/settings/language/Makefile.in b/noncore/settings/language/Makefile.in new file mode 100644 index 0000000..2babf6e --- a/dev/null +++ b/noncore/settings/language/Makefile.in | |||
@@ -0,0 +1,135 @@ | |||
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 | |||
17 | DESTDIR = ../../bin/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= language | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =settings.h | ||
27 | SOURCES =language.cpp \ | ||
28 | main.cpp | ||
29 | OBJECTS =language.o \ | ||
30 | main.o \ | ||
31 | languagesettingsbase.o | ||
32 | INTERFACES = languagesettingsbase.ui | ||
33 | UICDECLS = languagesettingsbase.h | ||
34 | UICIMPLS = languagesettingsbase.cpp | ||
35 | SRCMOC =moc_settings.cpp \ | ||
36 | moc_languagesettingsbase.cpp | ||
37 | OBJMOC =moc_settings.o \ | ||
38 | moc_languagesettingsbase.o | ||
39 | |||
40 | |||
41 | ####### Implicit rules | ||
42 | |||
43 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
44 | |||
45 | .cpp.o: | ||
46 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
47 | |||
48 | .cxx.o: | ||
49 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
50 | |||
51 | .cc.o: | ||
52 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
53 | |||
54 | .C.o: | ||
55 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
56 | |||
57 | .c.o: | ||
58 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
59 | |||
60 | ####### Build rules | ||
61 | |||
62 | |||
63 | all: $(DESTDIR)$(TARGET) | ||
64 | |||
65 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
66 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
67 | |||
68 | moc: $(SRCMOC) | ||
69 | |||
70 | tmake: | ||
71 | tmake language.pro | ||
72 | |||
73 | clean: | ||
74 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
75 | -rm -f *~ core | ||
76 | -rm -f allmoc.cpp | ||
77 | |||
78 | ####### Extension Modules | ||
79 | |||
80 | listpromodules: | ||
81 | @echo | ||
82 | |||
83 | listallmodules: | ||
84 | @echo | ||
85 | |||
86 | listaddonpromodules: | ||
87 | @echo | ||
88 | |||
89 | listaddonentmodules: | ||
90 | @echo | ||
91 | |||
92 | |||
93 | REQUIRES= | ||
94 | |||
95 | ####### Sub-libraries | ||
96 | |||
97 | |||
98 | ###### Combined headers | ||
99 | |||
100 | |||
101 | |||
102 | ####### Compile | ||
103 | |||
104 | language.o: language.cpp \ | ||
105 | settings.h \ | ||
106 | languagesettingsbase.h | ||
107 | |||
108 | main.o: main.cpp \ | ||
109 | settings.h \ | ||
110 | languagesettingsbase.h | ||
111 | |||
112 | languagesettingsbase.h: languagesettingsbase.ui | ||
113 | $(UIC) languagesettingsbase.ui -o $(INTERFACE_DECL_PATH)/languagesettingsbase.h | ||
114 | |||
115 | languagesettingsbase.cpp: languagesettingsbase.ui | ||
116 | $(UIC) languagesettingsbase.ui -i languagesettingsbase.h -o languagesettingsbase.cpp | ||
117 | |||
118 | languagesettingsbase.o: languagesettingsbase.cpp \ | ||
119 | languagesettingsbase.h \ | ||
120 | languagesettingsbase.ui | ||
121 | |||
122 | moc_settings.o: moc_settings.cpp \ | ||
123 | settings.h \ | ||
124 | languagesettingsbase.h | ||
125 | |||
126 | moc_languagesettingsbase.o: moc_languagesettingsbase.cpp \ | ||
127 | languagesettingsbase.h | ||
128 | |||
129 | moc_settings.cpp: settings.h | ||
130 | $(MOC) settings.h -o moc_settings.cpp | ||
131 | |||
132 | moc_languagesettingsbase.cpp: languagesettingsbase.h | ||
133 | $(MOC) languagesettingsbase.h -o moc_languagesettingsbase.cpp | ||
134 | |||
135 | |||
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp new file mode 100644 index 0000000..397d372 --- a/dev/null +++ b/noncore/settings/language/language.cpp | |||
@@ -0,0 +1,150 @@ | |||
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 "settings.h" | ||
22 | |||
23 | #include <qpe/global.h> | ||
24 | #include <qpe/fontmanager.h> | ||
25 | #include <qpe/config.h> | ||
26 | #include <qpe/applnk.h> | ||
27 | #include <qpe/qpedialog.h> | ||
28 | #include <qpe/qpeapplication.h> | ||
29 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
30 | #include <qpe/qcopenvelope_qws.h> | ||
31 | #endif | ||
32 | |||
33 | #include <qlabel.h> | ||
34 | #include <qcheckbox.h> | ||
35 | #include <qradiobutton.h> | ||
36 | #include <qtabwidget.h> | ||
37 | #include <qslider.h> | ||
38 | #include <qfile.h> | ||
39 | #include <qtextstream.h> | ||
40 | #include <qdatastream.h> | ||
41 | #include <qmessagebox.h> | ||
42 | #include <qcombobox.h> | ||
43 | #include <qspinbox.h> | ||
44 | #include <qlistbox.h> | ||
45 | #include <qdir.h> | ||
46 | #if QT_VERSION >= 300 | ||
47 | #include <qstylefactory.h> | ||
48 | #endif | ||
49 | |||
50 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | ||
51 | #include <unistd.h> | ||
52 | #include <linux/fb.h> | ||
53 | #include <sys/types.h> | ||
54 | #include <sys/stat.h> | ||
55 | #include <fcntl.h> | ||
56 | #include <sys/ioctl.h> | ||
57 | #endif | ||
58 | #include <stdlib.h> | ||
59 | |||
60 | |||
61 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) | ||
62 | : LanguageSettingsBase( parent, name, TRUE, fl ) | ||
63 | { | ||
64 | if ( FontManager::hasUnicodeFont() ) | ||
65 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); | ||
66 | |||
67 | QString tfn = QPEApplication::qpeDir()+"/i18n/"; | ||
68 | QDir langDir = tfn; | ||
69 | QStringList list = langDir.entryList("*", QDir::Dirs ); | ||
70 | |||
71 | QStringList::Iterator it; | ||
72 | |||
73 | for( it = list.begin(); it != list.end(); ++it ) { | ||
74 | QString name = (*it); | ||
75 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); | ||
76 | if( desktopFile.exists() ) { | ||
77 | langAvail.append(name); | ||
78 | Config conf( desktopFile.filePath(), Config::File ); | ||
79 | QString langName = conf.readEntry( "Name" ); | ||
80 | QString ownName = conf.readEntryDirect( "Name["+name+"]" ); | ||
81 | if ( ownName.isEmpty() ) | ||
82 | ownName = conf.readEntryDirect( "Name" ); | ||
83 | if ( !ownName.isEmpty() && ownName != langName ) | ||
84 | langName = langName + " [" + ownName + "]"; | ||
85 | languages->insertItem( langName ); | ||
86 | |||
87 | } | ||
88 | } | ||
89 | |||
90 | dl = new QPEDialogListener(this); | ||
91 | reset(); | ||
92 | } | ||
93 | |||
94 | LanguageSettings::~LanguageSettings() | ||
95 | { | ||
96 | } | ||
97 | |||
98 | void LanguageSettings::accept() | ||
99 | { | ||
100 | applyLanguage(); | ||
101 | QDialog::accept(); | ||
102 | } | ||
103 | |||
104 | void LanguageSettings::applyLanguage() | ||
105 | { | ||
106 | QString lang = langAvail.at( languages->currentItem() ); | ||
107 | setLanguage( lang ); | ||
108 | } | ||
109 | |||
110 | |||
111 | void LanguageSettings::reject() | ||
112 | { | ||
113 | reset(); | ||
114 | QDialog::reject(); | ||
115 | } | ||
116 | |||
117 | void LanguageSettings::reset() | ||
118 | { | ||
119 | QString l = getenv("LANG"); | ||
120 | Config config("language"); | ||
121 | l = config.readEntry( "Language", l ); | ||
122 | if(l.isEmpty()) l = "en"; | ||
123 | actualLanguage = l; | ||
124 | |||
125 | int n = langAvail.find( l ); | ||
126 | languages->setCurrentItem( n ); | ||
127 | } | ||
128 | |||
129 | QString LanguageSettings::actualLanguage; | ||
130 | |||
131 | void LanguageSettings::setLanguage(const QString& lang) | ||
132 | { | ||
133 | if( lang != actualLanguage ) { | ||
134 | Config config("locale"); | ||
135 | config.setGroup( "Language" ); | ||
136 | config.writeEntry( "Language", lang ); | ||
137 | config.write(); | ||
138 | |||
139 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
140 | QCopEnvelope e("QPE/System","language(QString)"); | ||
141 | e << lang; | ||
142 | #endif | ||
143 | } | ||
144 | } | ||
145 | |||
146 | void LanguageSettings::done(int r) | ||
147 | { | ||
148 | QDialog::done(r); | ||
149 | close(); | ||
150 | } | ||
diff --git a/noncore/settings/language/language.pro b/noncore/settings/language/language.pro new file mode 100644 index 0000000..d1f1bf0 --- a/dev/null +++ b/noncore/settings/language/language.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG += qt warn_on release | ||
3 | DESTDIR = ../../bin | ||
4 | HEADERS = settings.h | ||
5 | SOURCES = language.cpp main.cpp | ||
6 | INTERFACES= languagesettingsbase.ui | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH+= ../$(QPEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | TARGET = language | ||
11 | |||
12 | TRANSLATIONS = ../../i18n/de/language.ts | ||
diff --git a/noncore/settings/language/languagesettingsbase.ui b/noncore/settings/language/languagesettingsbase.ui new file mode 100644 index 0000000..62bdafa --- a/dev/null +++ b/noncore/settings/language/languagesettingsbase.ui | |||
@@ -0,0 +1,51 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>LanguageSettingsBase</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>LanguageSettingsBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>369</width> | ||
15 | <height>492</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Language</string> | ||
21 | </property> | ||
22 | <vbox> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>11</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>6</number> | ||
30 | </property> | ||
31 | <widget> | ||
32 | <class>QLabel</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>TextLabel1</cstring> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>text</name> | ||
39 | <string>Select language</string> | ||
40 | </property> | ||
41 | </widget> | ||
42 | <widget> | ||
43 | <class>QListBox</class> | ||
44 | <property stdset="1"> | ||
45 | <name>name</name> | ||
46 | <cstring>languages</cstring> | ||
47 | </property> | ||
48 | </widget> | ||
49 | </vbox> | ||
50 | </widget> | ||
51 | </UI> | ||
diff --git a/noncore/settings/language/main.cpp b/noncore/settings/language/main.cpp new file mode 100644 index 0000000..a760ff3 --- a/dev/null +++ b/noncore/settings/language/main.cpp | |||
@@ -0,0 +1,36 @@ | |||
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 "settings.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | |||
26 | int main(int argc, char** argv) | ||
27 | { | ||
28 | QPEApplication a(argc,argv); | ||
29 | |||
30 | LanguageSettings dlg; | ||
31 | |||
32 | a.showMainWidget(&dlg); | ||
33 | |||
34 | return a.exec(); | ||
35 | } | ||
36 | |||
diff --git a/noncore/settings/language/qpe-language.control b/noncore/settings/language/qpe-language.control new file mode 100644 index 0000000..b33c947 --- a/dev/null +++ b/noncore/settings/language/qpe-language.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: bin/language apps/Settings/Language.desktop | ||
2 | Priority: optional | ||
3 | Section: qpe/settings | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-3 | ||
7 | Depends: qpe-base ($QPE_VERSION) | ||
8 | Description: Language settings dialog | ||
9 | For the Qtopia environment. | ||
diff --git a/noncore/settings/language/settings.h b/noncore/settings/language/settings.h new file mode 100644 index 0000000..22cc987 --- a/dev/null +++ b/noncore/settings/language/settings.h | |||
@@ -0,0 +1,58 @@ | |||
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 | #ifndef SETTINGS_H | ||
21 | #define SETTINGS_H | ||
22 | |||
23 | |||
24 | #include <qstrlist.h> | ||
25 | #include <qasciidict.h> | ||
26 | #include "languagesettingsbase.h" | ||
27 | |||
28 | class QPEDialogListener; | ||
29 | |||
30 | class LanguageSettings : public LanguageSettingsBase | ||
31 | { | ||
32 | Q_OBJECT | ||
33 | |||
34 | public: | ||
35 | LanguageSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | ||
36 | ~LanguageSettings(); | ||
37 | |||
38 | protected: | ||
39 | void accept(); | ||
40 | void reject(); | ||
41 | void done(int); | ||
42 | |||
43 | QStrList langAvail; | ||
44 | |||
45 | private slots: | ||
46 | void applyLanguage(); | ||
47 | void reset(); | ||
48 | |||
49 | private: | ||
50 | static void setLanguage(const QString&); | ||
51 | static QString actualLanguage; | ||
52 | |||
53 | QPEDialogListener *dl; | ||
54 | }; | ||
55 | |||
56 | |||
57 | #endif // SETTINGS_H | ||
58 | |||
diff --git a/noncore/settings/sound/.cvsignore b/noncore/settings/sound/.cvsignore new file mode 100644 index 0000000..ba1f2fe --- a/dev/null +++ b/noncore/settings/sound/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | moc_* | ||
3 | *.moc | ||
4 | soundsettingsbase.cpp | ||
5 | soundsettingsbase.h | ||
diff --git a/noncore/settings/sound/Makefile.in b/noncore/settings/sound/Makefile.in new file mode 100644 index 0000000..1772e12 --- a/dev/null +++ b/noncore/settings/sound/Makefile.in | |||
@@ -0,0 +1,135 @@ | |||
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 | |||
17 | DESTDIR = ../../bin/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= sound | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =soundsettings.h | ||
27 | SOURCES =soundsettings.cpp \ | ||
28 | main.cpp | ||
29 | OBJECTS =soundsettings.o \ | ||
30 | main.o \ | ||
31 | soundsettingsbase.o | ||
32 | INTERFACES = soundsettingsbase.ui | ||
33 | UICDECLS = soundsettingsbase.h | ||
34 | UICIMPLS = soundsettingsbase.cpp | ||
35 | SRCMOC =moc_soundsettings.cpp \ | ||
36 | moc_soundsettingsbase.cpp | ||
37 | OBJMOC =moc_soundsettings.o \ | ||
38 | moc_soundsettingsbase.o | ||
39 | |||
40 | |||
41 | ####### Implicit rules | ||
42 | |||
43 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
44 | |||
45 | .cpp.o: | ||
46 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
47 | |||
48 | .cxx.o: | ||
49 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
50 | |||
51 | .cc.o: | ||
52 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
53 | |||
54 | .C.o: | ||
55 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
56 | |||
57 | .c.o: | ||
58 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
59 | |||
60 | ####### Build rules | ||
61 | |||
62 | |||
63 | all: $(DESTDIR)$(TARGET) | ||
64 | |||
65 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
66 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
67 | |||
68 | moc: $(SRCMOC) | ||
69 | |||
70 | tmake: | ||
71 | tmake sound.pro | ||
72 | |||
73 | clean: | ||
74 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
75 | -rm -f *~ core | ||
76 | -rm -f allmoc.cpp | ||
77 | |||
78 | ####### Extension Modules | ||
79 | |||
80 | listpromodules: | ||
81 | @echo | ||
82 | |||
83 | listallmodules: | ||
84 | @echo | ||
85 | |||
86 | listaddonpromodules: | ||
87 | @echo | ||
88 | |||
89 | listaddonentmodules: | ||
90 | @echo | ||
91 | |||
92 | |||
93 | REQUIRES= | ||
94 | |||
95 | ####### Sub-libraries | ||
96 | |||
97 | |||
98 | ###### Combined headers | ||
99 | |||
100 | |||
101 | |||
102 | ####### Compile | ||
103 | |||
104 | soundsettings.o: soundsettings.cpp \ | ||
105 | soundsettings.h \ | ||
106 | soundsettingsbase.h | ||
107 | |||
108 | main.o: main.cpp \ | ||
109 | soundsettings.h \ | ||
110 | soundsettingsbase.h | ||
111 | |||
112 | soundsettingsbase.h: soundsettingsbase.ui | ||
113 | $(UIC) soundsettingsbase.ui -o $(INTERFACE_DECL_PATH)/soundsettingsbase.h | ||
114 | |||
115 | soundsettingsbase.cpp: soundsettingsbase.ui | ||
116 | $(UIC) soundsettingsbase.ui -i soundsettingsbase.h -o soundsettingsbase.cpp | ||
117 | |||
118 | soundsettingsbase.o: soundsettingsbase.cpp \ | ||
119 | soundsettingsbase.h \ | ||
120 | soundsettingsbase.ui | ||
121 | |||
122 | moc_soundsettings.o: moc_soundsettings.cpp \ | ||
123 | soundsettings.h \ | ||
124 | soundsettingsbase.h | ||
125 | |||
126 | moc_soundsettingsbase.o: moc_soundsettingsbase.cpp \ | ||
127 | soundsettingsbase.h | ||
128 | |||
129 | moc_soundsettings.cpp: soundsettings.h | ||
130 | $(MOC) soundsettings.h -o moc_soundsettings.cpp | ||
131 | |||
132 | moc_soundsettingsbase.cpp: soundsettingsbase.h | ||
133 | $(MOC) soundsettingsbase.h -o moc_soundsettingsbase.cpp | ||
134 | |||
135 | |||
diff --git a/noncore/settings/sound/main.cpp b/noncore/settings/sound/main.cpp new file mode 100644 index 0000000..5d28a8c --- a/dev/null +++ b/noncore/settings/sound/main.cpp | |||
@@ -0,0 +1,36 @@ | |||
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 "soundsettings.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | |||
26 | int main(int argc, char** argv) | ||
27 | { | ||
28 | QPEApplication a(argc,argv); | ||
29 | |||
30 | SoundSettings dlg; | ||
31 | |||
32 | a.showMainWidget(&dlg); | ||
33 | |||
34 | return a.exec(); | ||
35 | } | ||
36 | |||
diff --git a/noncore/settings/sound/qpe-sound.control b/noncore/settings/sound/qpe-sound.control new file mode 100644 index 0000000..f7f1c4f --- a/dev/null +++ b/noncore/settings/sound/qpe-sound.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Files: bin/sound apps/Settings/Sound.desktop | ||
2 | Priority: optional | ||
3 | Section: qpe/settings | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Arch: iPAQ | ||
7 | Version: $QPE_VERSION-1 | ||
8 | Depends: qpe-base ($QPE_VERSION) | ||
9 | Description: Sound settings dialog | ||
10 | For the Qtopia environment. | ||
diff --git a/noncore/settings/sound/sound.pro b/noncore/settings/sound/sound.pro new file mode 100644 index 0000000..9028a44 --- a/dev/null +++ b/noncore/settings/sound/sound.pro | |||
@@ -0,0 +1,10 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG += qt warn_on release | ||
3 | DESTDIR = ../../bin | ||
4 | HEADERS = soundsettings.h | ||
5 | SOURCES = soundsettings.cpp main.cpp | ||
6 | INTERFACES= soundsettingsbase.ui | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH+= ../$(QPEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | TARGET = sound | ||
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp new file mode 100644 index 0000000..92281f8 --- a/dev/null +++ b/noncore/settings/sound/soundsettings.cpp | |||
@@ -0,0 +1,64 @@ | |||
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 "soundsettings.h" | ||
21 | |||
22 | #include <qpe/config.h> | ||
23 | #include <qpe/qcopenvelope_qws.h> | ||
24 | |||
25 | #include <qslider.h> | ||
26 | #include <qcheckbox.h> | ||
27 | |||
28 | SoundSettings::SoundSettings( QWidget* parent, const char* name, WFlags fl ) | ||
29 | : SoundSettingsBase( parent, name, TRUE, fl ) | ||
30 | { | ||
31 | Config config( "Sound" ); | ||
32 | |||
33 | config.setGroup( "System" ); | ||
34 | volume->setValue(100-config.readNumEntry("Volume")); | ||
35 | touchsound->setChecked(config.readBoolEntry("Touch")); | ||
36 | keysound->setChecked(config.readBoolEntry("Key")); | ||
37 | |||
38 | connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); | ||
39 | } | ||
40 | |||
41 | void SoundSettings::reject() | ||
42 | { | ||
43 | Config config( "Sound" ); | ||
44 | config.setGroup( "System" ); | ||
45 | setVolume(100-config.readNumEntry("Volume")); | ||
46 | |||
47 | QDialog::reject(); | ||
48 | } | ||
49 | |||
50 | void SoundSettings::accept() | ||
51 | { | ||
52 | Config config( "Sound" ); | ||
53 | config.setGroup( "System" ); | ||
54 | config.writeEntry("Volume",100-volume->value()); | ||
55 | config.writeEntry("Touch",touchsound->isChecked()); | ||
56 | config.writeEntry("Key",keysound->isChecked()); | ||
57 | setVolume(volume->value()); | ||
58 | QDialog::accept(); | ||
59 | } | ||
60 | |||
61 | void SoundSettings::setVolume(int v) | ||
62 | { | ||
63 | QCopEnvelope( "QPE/System", "setVolume(int,int)" ) << 0 << 100-v; | ||
64 | } | ||
diff --git a/noncore/settings/sound/soundsettings.h b/noncore/settings/sound/soundsettings.h new file mode 100644 index 0000000..b5c8cee --- a/dev/null +++ b/noncore/settings/sound/soundsettings.h | |||
@@ -0,0 +1,44 @@ | |||
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 | #ifndef SOUNDSETTINGS_H | ||
21 | #define SOUNDSETTINGS_H | ||
22 | |||
23 | |||
24 | #include "soundsettingsbase.h" | ||
25 | |||
26 | |||
27 | class SoundSettings : public SoundSettingsBase | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | |||
31 | public: | ||
32 | SoundSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | ||
33 | |||
34 | protected: | ||
35 | void accept(); | ||
36 | void reject(); | ||
37 | |||
38 | private slots: | ||
39 | void setVolume(int); | ||
40 | }; | ||
41 | |||
42 | |||
43 | #endif // SOUNDSETTINGS_H | ||
44 | |||
diff --git a/noncore/settings/sound/soundsettingsbase.ui b/noncore/settings/sound/soundsettingsbase.ui new file mode 100644 index 0000000..1aa4545 --- a/dev/null +++ b/noncore/settings/sound/soundsettingsbase.ui | |||
@@ -0,0 +1,281 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>SoundSettingsBase</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>SoundSettingsBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>246</width> | ||
15 | <height>299</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Sound Settings</string> | ||
21 | </property> | ||
22 | <property> | ||
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <vbox> | ||
29 | <property stdset="1"> | ||
30 | <name>margin</name> | ||
31 | <number>7</number> | ||
32 | </property> | ||
33 | <property stdset="1"> | ||
34 | <name>spacing</name> | ||
35 | <number>1</number> | ||
36 | </property> | ||
37 | <widget> | ||
38 | <class>QCheckBox</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>keysound</cstring> | ||
42 | </property> | ||
43 | <property stdset="1"> | ||
44 | <name>text</name> | ||
45 | <string>Keyboard sound</string> | ||
46 | </property> | ||
47 | </widget> | ||
48 | <widget> | ||
49 | <class>QCheckBox</class> | ||
50 | <property stdset="1"> | ||
51 | <name>name</name> | ||
52 | <cstring>touchsound</cstring> | ||
53 | </property> | ||
54 | <property stdset="1"> | ||
55 | <name>text</name> | ||
56 | <string>Screen sound</string> | ||
57 | </property> | ||
58 | </widget> | ||
59 | <widget> | ||
60 | <class>QLayoutWidget</class> | ||
61 | <property stdset="1"> | ||
62 | <name>name</name> | ||
63 | <cstring>Layout10</cstring> | ||
64 | </property> | ||
65 | <hbox> | ||
66 | <property stdset="1"> | ||
67 | <name>margin</name> | ||
68 | <number>0</number> | ||
69 | </property> | ||
70 | <property stdset="1"> | ||
71 | <name>spacing</name> | ||
72 | <number>6</number> | ||
73 | </property> | ||
74 | <widget> | ||
75 | <class>QSlider</class> | ||
76 | <property stdset="1"> | ||
77 | <name>name</name> | ||
78 | <cstring>volume</cstring> | ||
79 | </property> | ||
80 | <property stdset="1"> | ||
81 | <name>maxValue</name> | ||
82 | <number>100</number> | ||
83 | </property> | ||
84 | <property stdset="1"> | ||
85 | <name>value</name> | ||
86 | <number>50</number> | ||
87 | </property> | ||
88 | <property stdset="1"> | ||
89 | <name>orientation</name> | ||
90 | <enum>Vertical</enum> | ||
91 | </property> | ||
92 | <property stdset="1"> | ||
93 | <name>tickmarks</name> | ||
94 | <enum>Right</enum> | ||
95 | </property> | ||
96 | <property stdset="1"> | ||
97 | <name>tickInterval</name> | ||
98 | <number>5</number> | ||
99 | </property> | ||
100 | </widget> | ||
101 | <widget> | ||
102 | <class>QLayoutWidget</class> | ||
103 | <property stdset="1"> | ||
104 | <name>name</name> | ||
105 | <cstring>Layout9</cstring> | ||
106 | </property> | ||
107 | <vbox> | ||
108 | <property stdset="1"> | ||
109 | <name>margin</name> | ||
110 | <number>0</number> | ||
111 | </property> | ||
112 | <property stdset="1"> | ||
113 | <name>spacing</name> | ||
114 | <number>6</number> | ||
115 | </property> | ||
116 | <widget> | ||
117 | <class>QLayoutWidget</class> | ||
118 | <property stdset="1"> | ||
119 | <name>name</name> | ||
120 | <cstring>Layout10_2</cstring> | ||
121 | </property> | ||
122 | <hbox> | ||
123 | <property stdset="1"> | ||
124 | <name>margin</name> | ||
125 | <number>0</number> | ||
126 | </property> | ||
127 | <property stdset="1"> | ||
128 | <name>spacing</name> | ||
129 | <number>6</number> | ||
130 | </property> | ||
131 | <widget> | ||
132 | <class>QLabel</class> | ||
133 | <property stdset="1"> | ||
134 | <name>name</name> | ||
135 | <cstring>PixmapLabel1_2</cstring> | ||
136 | </property> | ||
137 | <property stdset="1"> | ||
138 | <name>pixmap</name> | ||
139 | <pixmap>image0</pixmap> | ||
140 | </property> | ||
141 | <property stdset="1"> | ||
142 | <name>scaledContents</name> | ||
143 | <bool>false</bool> | ||
144 | </property> | ||
145 | </widget> | ||
146 | <widget> | ||
147 | <class>QLabel</class> | ||
148 | <property stdset="1"> | ||
149 | <name>name</name> | ||
150 | <cstring>TextLabel1_2</cstring> | ||
151 | </property> | ||
152 | <property stdset="1"> | ||
153 | <name>text</name> | ||
154 | <string>Loud</string> | ||
155 | </property> | ||
156 | </widget> | ||
157 | <spacer> | ||
158 | <property> | ||
159 | <name>name</name> | ||
160 | <cstring>Spacer3_2</cstring> | ||
161 | </property> | ||
162 | <property stdset="1"> | ||
163 | <name>orientation</name> | ||
164 | <enum>Horizontal</enum> | ||
165 | </property> | ||
166 | <property stdset="1"> | ||
167 | <name>sizeType</name> | ||
168 | <enum>Expanding</enum> | ||
169 | </property> | ||
170 | <property> | ||
171 | <name>sizeHint</name> | ||
172 | <size> | ||
173 | <width>20</width> | ||
174 | <height>20</height> | ||
175 | </size> | ||
176 | </property> | ||
177 | </spacer> | ||
178 | </hbox> | ||
179 | </widget> | ||
180 | <spacer> | ||
181 | <property> | ||
182 | <name>name</name> | ||
183 | <cstring>Spacer5_2</cstring> | ||
184 | </property> | ||
185 | <property stdset="1"> | ||
186 | <name>orientation</name> | ||
187 | <enum>Vertical</enum> | ||
188 | </property> | ||
189 | <property stdset="1"> | ||
190 | <name>sizeType</name> | ||
191 | <enum>Expanding</enum> | ||
192 | </property> | ||
193 | <property> | ||
194 | <name>sizeHint</name> | ||
195 | <size> | ||
196 | <width>20</width> | ||
197 | <height>20</height> | ||
198 | </size> | ||
199 | </property> | ||
200 | </spacer> | ||
201 | <widget> | ||
202 | <class>QLayoutWidget</class> | ||
203 | <property stdset="1"> | ||
204 | <name>name</name> | ||
205 | <cstring>Layout9_2</cstring> | ||
206 | </property> | ||
207 | <hbox> | ||
208 | <property stdset="1"> | ||
209 | <name>margin</name> | ||
210 | <number>0</number> | ||
211 | </property> | ||
212 | <property stdset="1"> | ||
213 | <name>spacing</name> | ||
214 | <number>6</number> | ||
215 | </property> | ||
216 | <widget> | ||
217 | <class>QLabel</class> | ||
218 | <property stdset="1"> | ||
219 | <name>name</name> | ||
220 | <cstring>PixmapLabel2_2</cstring> | ||
221 | </property> | ||
222 | <property stdset="1"> | ||
223 | <name>pixmap</name> | ||
224 | <pixmap>image1</pixmap> | ||
225 | </property> | ||
226 | <property stdset="1"> | ||
227 | <name>scaledContents</name> | ||
228 | <bool>false</bool> | ||
229 | </property> | ||
230 | </widget> | ||
231 | <widget> | ||
232 | <class>QLabel</class> | ||
233 | <property stdset="1"> | ||
234 | <name>name</name> | ||
235 | <cstring>TextLabel2_2</cstring> | ||
236 | </property> | ||
237 | <property stdset="1"> | ||
238 | <name>text</name> | ||
239 | <string>Silent</string> | ||
240 | </property> | ||
241 | </widget> | ||
242 | <spacer> | ||
243 | <property> | ||
244 | <name>name</name> | ||
245 | <cstring>Spacer2_2</cstring> | ||
246 | </property> | ||
247 | <property stdset="1"> | ||
248 | <name>orientation</name> | ||
249 | <enum>Horizontal</enum> | ||
250 | </property> | ||
251 | <property stdset="1"> | ||
252 | <name>sizeType</name> | ||
253 | <enum>Expanding</enum> | ||
254 | </property> | ||
255 | <property> | ||
256 | <name>sizeHint</name> | ||
257 | <size> | ||
258 | <width>20</width> | ||
259 | <height>20</height> | ||
260 | </size> | ||
261 | </property> | ||
262 | </spacer> | ||
263 | </hbox> | ||
264 | </widget> | ||
265 | </vbox> | ||
266 | </widget> | ||
267 | </hbox> | ||
268 | </widget> | ||
269 | </vbox> | ||
270 | </widget> | ||
271 | <images> | ||
272 | <image> | ||
273 | <name>image0</name> | ||
274 | <data format="XPM.GZ" length="409">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022630543251d2e253d856405bffcbc54103b11c856360003105719c44d4b8371f590803210638829a38b2983115c2c112a8224969808d60716868a2582c440aa94a1628960a00755a5ac8c2aa64c8118c23c6cf6c2dda787e23eb03f602af1fa17395c6aadb9008c9350cb</data> | ||
275 | </image> | ||
276 | <image> | ||
277 | <name>image1</name> | ||
278 | <data format="XPM.GZ" length="409">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022630543251d2e253d856405bffcbc54105b19c856360003103711c44d4b8371f5d000c962ca9862ca9862ca60b1440806bb0a0c80dcc444304616030924a2a983a8d423a80ed93c6cf6e2701f567f100c835a6b2e0025ab4ee4</data> | ||
279 | </image> | ||
280 | </images> | ||
281 | </UI> | ||
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 @@ | |||
1 | moc_* | ||
2 | *.moc | ||
3 | Makefile | ||
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 | |||
17 | DESTDIR = $(QPEDIR)/bin/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= sysinfo | ||
22 | TARGET1 = 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 | ||
46 | INTERFACES = | ||
47 | UICDECLS = | ||
48 | UICIMPLS = | ||
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 | |||
85 | all: $(DESTDIR)$(TARGET) | ||
86 | |||
87 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
88 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
89 | |||
90 | moc: $(SRCMOC) | ||
91 | |||
92 | tmake: | ||
93 | tmake sysinfo.pro | ||
94 | |||
95 | clean: | ||
96 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
97 | -rm -f *~ core | ||
98 | -rm -f allmoc.cpp | ||
99 | |||
100 | ####### Extension Modules | ||
101 | |||
102 | listpromodules: | ||
103 | @echo | ||
104 | |||
105 | listallmodules: | ||
106 | @echo | ||
107 | |||
108 | listaddonpromodules: | ||
109 | @echo | ||
110 | |||
111 | listaddonentmodules: | ||
112 | @echo | ||
113 | |||
114 | |||
115 | REQUIRES= | ||
116 | |||
117 | ####### Sub-libraries | ||
118 | |||
119 | |||
120 | ###### Combined headers | ||
121 | |||
122 | |||
123 | |||
124 | ####### Compile | ||
125 | |||
126 | main.o: main.cpp \ | ||
127 | sysinfo.h \ | ||
128 | $(QPEDIR)/include/qpe/qpeapplication.h | ||
129 | |||
130 | memory.o: memory.cpp \ | ||
131 | graph.h \ | ||
132 | memory.h | ||
133 | |||
134 | graph.o: graph.cpp \ | ||
135 | graph.h | ||
136 | |||
137 | load.o: load.cpp \ | ||
138 | load.h | ||
139 | |||
140 | storage.o: storage.cpp \ | ||
141 | graph.h \ | ||
142 | storage.h | ||
143 | |||
144 | versioninfo.o: versioninfo.cpp \ | ||
145 | $(QPEDIR)/include/qpe/resource.h \ | ||
146 | $(QPEDIR)/include/qpe/version.h \ | ||
147 | versioninfo.h | ||
148 | |||
149 | sysinfo.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 | |||
157 | moc_memory.o: moc_memory.cpp \ | ||
158 | memory.h | ||
159 | |||
160 | moc_graph.o: moc_graph.cpp \ | ||
161 | graph.h | ||
162 | |||
163 | moc_load.o: moc_load.cpp \ | ||
164 | load.h | ||
165 | |||
166 | moc_storage.o: moc_storage.cpp \ | ||
167 | storage.h | ||
168 | |||
169 | moc_versioninfo.o: moc_versioninfo.cpp \ | ||
170 | versioninfo.h | ||
171 | |||
172 | moc_sysinfo.o: moc_sysinfo.cpp \ | ||
173 | sysinfo.h | ||
174 | |||
175 | moc_memory.cpp: memory.h | ||
176 | $(MOC) memory.h -o moc_memory.cpp | ||
177 | |||
178 | moc_graph.cpp: graph.h | ||
179 | $(MOC) graph.h -o moc_graph.cpp | ||
180 | |||
181 | moc_load.cpp: load.h | ||
182 | $(MOC) load.h -o moc_load.cpp | ||
183 | |||
184 | moc_storage.cpp: storage.h | ||
185 | $(MOC) storage.h -o moc_storage.cpp | ||
186 | |||
187 | moc_versioninfo.cpp: versioninfo.h | ||
188 | $(MOC) versioninfo.h -o moc_versioninfo.cpp | ||
189 | |||
190 | moc_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 | |||
25 | void GraphData::clear() | ||
26 | { | ||
27 | names.clear(); | ||
28 | values.resize(0); | ||
29 | } | ||
30 | |||
31 | void 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 | |||
38 | Graph::Graph(QWidget *parent, const char *name, WFlags f ) | ||
39 | : QFrame( parent, name, f ) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | PieGraph::PieGraph(QWidget *parent, const char *name, WFlags f ) | ||
44 | : Graph( parent, name, f ) | ||
45 | { | ||
46 | } | ||
47 | |||
48 | void 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 | |||
72 | BarGraph::BarGraph(QWidget *parent, const char *name, WFlags f ) | ||
73 | : Graph( parent, name, f ) | ||
74 | { | ||
75 | setMinimumHeight( 10 ); | ||
76 | setMaximumHeight( 45 ); | ||
77 | } | ||
78 | |||
79 | void 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 | |||
102 | void 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 | |||
124 | GraphLegend::GraphLegend( QWidget *parent, const char *name, WFlags f ) | ||
125 | : QFrame( parent, name, f ) | ||
126 | { | ||
127 | horz = FALSE; | ||
128 | } | ||
129 | |||
130 | void GraphLegend::setOrientation(Orientation o) | ||
131 | { | ||
132 | horz = o == Horizontal; | ||
133 | } | ||
134 | |||
135 | void 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 | |||
161 | QSize 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 | |||
177 | void 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 | |||
25 | class GraphData | ||
26 | { | ||
27 | public: | ||
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 | |||
35 | private: | ||
36 | QStringList names; | ||
37 | QArray<int> values; | ||
38 | }; | ||
39 | |||
40 | class Graph : public QFrame | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | Graph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
45 | |||
46 | void setData( const GraphData *p ) { data = p; } | ||
47 | |||
48 | protected: | ||
49 | const GraphData *data; | ||
50 | }; | ||
51 | |||
52 | class PieGraph : public Graph | ||
53 | { | ||
54 | Q_OBJECT | ||
55 | public: | ||
56 | PieGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
57 | |||
58 | protected: | ||
59 | virtual void drawContents( QPainter *p ); | ||
60 | }; | ||
61 | |||
62 | class BarGraph : public Graph | ||
63 | { | ||
64 | Q_OBJECT | ||
65 | public: | ||
66 | BarGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
67 | |||
68 | protected: | ||
69 | virtual void drawContents( QPainter *p ); | ||
70 | void drawSegment( QPainter *p, const QRect &r, const QColor &c ); | ||
71 | }; | ||
72 | |||
73 | class GraphLegend : public QFrame | ||
74 | { | ||
75 | Q_OBJECT | ||
76 | public: | ||
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 | |||
83 | protected: | ||
84 | virtual void drawContents( QPainter *p ); | ||
85 | |||
86 | private: | ||
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 | |||
31 | LoadInfo::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 | |||
49 | QPixmap 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 | |||
64 | QString 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 | |||
104 | Load::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 | |||
126 | void 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 | |||
156 | void 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 | */ | ||
27 | class Load : public QWidget { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | Load( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
31 | |||
32 | protected: | ||
33 | void paintEvent( QPaintEvent *ev ); | ||
34 | |||
35 | private slots: | ||
36 | void timeout(); | ||
37 | |||
38 | private: | ||
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 | |||
51 | class LoadInfo : public QWidget | ||
52 | { | ||
53 | Q_OBJECT | ||
54 | public: | ||
55 | LoadInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
56 | |||
57 | private: | ||
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 | |||
25 | int 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 | |||
29 | MemoryInfo::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 | |||
56 | MemoryInfo::~MemoryInfo() | ||
57 | { | ||
58 | delete data; | ||
59 | } | ||
60 | |||
61 | void 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 | |||
26 | class GraphData; | ||
27 | class Graph; | ||
28 | class GraphLegend; | ||
29 | class QLabel; | ||
30 | |||
31 | class MemoryInfo : public QWidget | ||
32 | { | ||
33 | Q_OBJECT | ||
34 | public: | ||
35 | MemoryInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
36 | ~MemoryInfo(); | ||
37 | |||
38 | private slots: | ||
39 | void updateData(); | ||
40 | |||
41 | private: | ||
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 @@ | |||
1 | Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/qpe-logo.png pics/tux-logo.png | ||
2 | Priority: optional | ||
3 | Section: qpe/applications | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-3 | ||
7 | Depends: qpe-base ($QPE_VERSION) | ||
8 | Description: 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 | |||
34 | StorageInfo::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 | |||
44 | void StorageInfo::timerEvent(QTimerEvent*) | ||
45 | { | ||
46 | updateMounts(); | ||
47 | } | ||
48 | |||
49 | static 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 | |||
73 | void 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 | |||
147 | MountInfo::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 | |||
170 | MountInfo::~MountInfo() | ||
171 | { | ||
172 | delete data; | ||
173 | delete fs; | ||
174 | } | ||
175 | |||
176 | void 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 | |||
199 | FileSystem::FileSystem( const QString &p ) | ||
200 | : fspath( p ), blkSize(512), totalBlks(0), availBlks(0) | ||
201 | { | ||
202 | update(); | ||
203 | } | ||
204 | |||
205 | void 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 | |||
25 | class QLabel; | ||
26 | class GraphData; | ||
27 | class Graph; | ||
28 | class GraphLegend; | ||
29 | class FileSystem; | ||
30 | class MountInfo; | ||
31 | class QVBoxLayout; | ||
32 | |||
33 | |||
34 | class StorageInfo : public QWidget | ||
35 | { | ||
36 | Q_OBJECT | ||
37 | public: | ||
38 | StorageInfo( QWidget *parent=0, const char *name=0 ); | ||
39 | |||
40 | protected: | ||
41 | void timerEvent(QTimerEvent*); | ||
42 | |||
43 | private: | ||
44 | void updateMounts(); | ||
45 | QDict<MountInfo> disks; | ||
46 | QList<QFrame> lines; | ||
47 | QVBoxLayout *vb; | ||
48 | }; | ||
49 | |||
50 | class MountInfo : public QWidget | ||
51 | { | ||
52 | Q_OBJECT | ||
53 | public: | ||
54 | MountInfo( const QString &path, const QString &ttl, QWidget *parent=0, const char *name=0 ); | ||
55 | ~MountInfo(); | ||
56 | |||
57 | void updateData(); | ||
58 | |||
59 | private: | ||
60 | QString title; | ||
61 | FileSystem *fs; | ||
62 | QLabel *totalSize; | ||
63 | GraphData *data; | ||
64 | Graph *graph; | ||
65 | GraphLegend *legend; | ||
66 | }; | ||
67 | |||
68 | class FileSystem | ||
69 | { | ||
70 | public: | ||
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 | |||
80 | private: | ||
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 | |||
34 | SystemInfo::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 | |||
23 | class SystemInfo : public QWidget | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | public: | ||
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 | |||
19 | INCLUDEPATH += $(QPEDIR)/include | ||
20 | DEPENDPATH+= $(QPEDIR)/include | ||
21 | LIBS += -lqpe | ||
22 | |||
23 | TARGET = sysinfo | ||
24 | |||
25 | TRANSLATIONS = ../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 | |||
34 | VersionInfo::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 | |||
106 | VersionInfo::~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 | |||
26 | class VersionInfo : public QWidget | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | VersionInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
31 | ~VersionInfo(); | ||
32 | }; | ||
33 | |||
34 | #endif | ||