author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (side-by-side diff) | |
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 @@ +moc_* +*.moc +Makefile +appearancesettingsbase.h +soundsettingsbase.h +lightsettingsbase.h +languagesettingsbase.cpp +rotationsettingsbase.cpp +appearancesettingsbase.cpp +lightsettingsbase.cpp +languagesettingsbase.h +rotationsettingsbase.h +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 @@ +moc_* +Makefile +languagesettingsbase.h +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 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = language +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = settings.h +SOURCES = language.cpp \ + main.cpp +OBJECTS = language.o \ + main.o \ + languagesettingsbase.o +INTERFACES = languagesettingsbase.ui +UICDECLS = languagesettingsbase.h +UICIMPLS = languagesettingsbase.cpp +SRCMOC = moc_settings.cpp \ + moc_languagesettingsbase.cpp +OBJMOC = moc_settings.o \ + moc_languagesettingsbase.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake language.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +language.o: language.cpp \ + settings.h \ + languagesettingsbase.h + +main.o: main.cpp \ + settings.h \ + languagesettingsbase.h + +languagesettingsbase.h: languagesettingsbase.ui + $(UIC) languagesettingsbase.ui -o $(INTERFACE_DECL_PATH)/languagesettingsbase.h + +languagesettingsbase.cpp: languagesettingsbase.ui + $(UIC) languagesettingsbase.ui -i languagesettingsbase.h -o languagesettingsbase.cpp + +languagesettingsbase.o: languagesettingsbase.cpp \ + languagesettingsbase.h \ + languagesettingsbase.ui + +moc_settings.o: moc_settings.cpp \ + settings.h \ + languagesettingsbase.h + +moc_languagesettingsbase.o: moc_languagesettingsbase.cpp \ + languagesettingsbase.h + +moc_settings.cpp: settings.h + $(MOC) settings.h -o moc_settings.cpp + +moc_languagesettingsbase.cpp: languagesettingsbase.h + $(MOC) languagesettingsbase.h -o moc_languagesettingsbase.cpp + + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "settings.h" + +#include <qpe/global.h> +#include <qpe/fontmanager.h> +#include <qpe/config.h> +#include <qpe/applnk.h> +#include <qpe/qpedialog.h> +#include <qpe/qpeapplication.h> +#if defined(Q_WS_QWS) && !defined(QT_NO_COP) +#include <qpe/qcopenvelope_qws.h> +#endif + +#include <qlabel.h> +#include <qcheckbox.h> +#include <qradiobutton.h> +#include <qtabwidget.h> +#include <qslider.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qdatastream.h> +#include <qmessagebox.h> +#include <qcombobox.h> +#include <qspinbox.h> +#include <qlistbox.h> +#include <qdir.h> +#if QT_VERSION >= 300 +#include <qstylefactory.h> +#endif + +#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) +#include <unistd.h> +#include <linux/fb.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#endif +#include <stdlib.h> + + +LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) + : LanguageSettingsBase( parent, name, TRUE, fl ) +{ + if ( FontManager::hasUnicodeFont() ) + languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); + + QString tfn = QPEApplication::qpeDir()+"/i18n/"; + QDir langDir = tfn; + QStringList list = langDir.entryList("*", QDir::Dirs ); + + QStringList::Iterator it; + + for( it = list.begin(); it != list.end(); ++it ) { + QString name = (*it); + QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); + if( desktopFile.exists() ) { + langAvail.append(name); + Config conf( desktopFile.filePath(), Config::File ); + QString langName = conf.readEntry( "Name" ); + QString ownName = conf.readEntryDirect( "Name["+name+"]" ); + if ( ownName.isEmpty() ) + ownName = conf.readEntryDirect( "Name" ); + if ( !ownName.isEmpty() && ownName != langName ) + langName = langName + " [" + ownName + "]"; + languages->insertItem( langName ); + + } + } + + dl = new QPEDialogListener(this); + reset(); +} + +LanguageSettings::~LanguageSettings() +{ +} + +void LanguageSettings::accept() +{ + applyLanguage(); + QDialog::accept(); +} + +void LanguageSettings::applyLanguage() +{ + QString lang = langAvail.at( languages->currentItem() ); + setLanguage( lang ); +} + + +void LanguageSettings::reject() +{ + reset(); + QDialog::reject(); +} + +void LanguageSettings::reset() +{ + QString l = getenv("LANG"); + Config config("language"); + l = config.readEntry( "Language", l ); + if(l.isEmpty()) l = "en"; + actualLanguage = l; + + int n = langAvail.find( l ); + languages->setCurrentItem( n ); +} + +QString LanguageSettings::actualLanguage; + +void LanguageSettings::setLanguage(const QString& lang) +{ + if( lang != actualLanguage ) { + Config config("locale"); + config.setGroup( "Language" ); + config.writeEntry( "Language", lang ); + config.write(); + +#if defined(Q_WS_QWS) && !defined(QT_NO_COP) + QCopEnvelope e("QPE/System","language(QString)"); + e << lang; +#endif + } +} + +void LanguageSettings::done(int r) +{ + QDialog::done(r); + close(); +} 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 @@ +TEMPLATE = app +CONFIG += qt warn_on release +DESTDIR = ../../bin +HEADERS = settings.h +SOURCES = language.cpp main.cpp +INTERFACES = languagesettingsbase.ui +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include +LIBS += -lqpe +TARGET = language + +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 @@ +<!DOCTYPE UI><UI> +<class>LanguageSettingsBase</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>LanguageSettingsBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>369</width> + <height>492</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Language</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Select language</string> + </property> + </widget> + <widget> + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>languages</cstring> + </property> + </widget> + </vbox> +</widget> +</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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "settings.h" + +#include <qpe/qpeapplication.h> + + +int main(int argc, char** argv) +{ + QPEApplication a(argc,argv); + + LanguageSettings dlg; + + a.showMainWidget(&dlg); + + return a.exec(); +} + 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 @@ +Files: bin/language apps/Settings/Language.desktop +Priority: optional +Section: qpe/settings +Maintainer: Warwick Allison <warwick@trolltech.com> +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: Language settings dialog + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef SETTINGS_H +#define SETTINGS_H + + +#include <qstrlist.h> +#include <qasciidict.h> +#include "languagesettingsbase.h" + +class QPEDialogListener; + +class LanguageSettings : public LanguageSettingsBase +{ + Q_OBJECT + +public: + LanguageSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~LanguageSettings(); + +protected: + void accept(); + void reject(); + void done(int); + + QStrList langAvail; + +private slots: + void applyLanguage(); + void reset(); + +private: + static void setLanguage(const QString&); + static QString actualLanguage; + + QPEDialogListener *dl; +}; + + +#endif // SETTINGS_H + 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 @@ +Makefile +moc_* +*.moc +soundsettingsbase.cpp +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 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = sound +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = soundsettings.h +SOURCES = soundsettings.cpp \ + main.cpp +OBJECTS = soundsettings.o \ + main.o \ + soundsettingsbase.o +INTERFACES = soundsettingsbase.ui +UICDECLS = soundsettingsbase.h +UICIMPLS = soundsettingsbase.cpp +SRCMOC = moc_soundsettings.cpp \ + moc_soundsettingsbase.cpp +OBJMOC = moc_soundsettings.o \ + moc_soundsettingsbase.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake sound.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +soundsettings.o: soundsettings.cpp \ + soundsettings.h \ + soundsettingsbase.h + +main.o: main.cpp \ + soundsettings.h \ + soundsettingsbase.h + +soundsettingsbase.h: soundsettingsbase.ui + $(UIC) soundsettingsbase.ui -o $(INTERFACE_DECL_PATH)/soundsettingsbase.h + +soundsettingsbase.cpp: soundsettingsbase.ui + $(UIC) soundsettingsbase.ui -i soundsettingsbase.h -o soundsettingsbase.cpp + +soundsettingsbase.o: soundsettingsbase.cpp \ + soundsettingsbase.h \ + soundsettingsbase.ui + +moc_soundsettings.o: moc_soundsettings.cpp \ + soundsettings.h \ + soundsettingsbase.h + +moc_soundsettingsbase.o: moc_soundsettingsbase.cpp \ + soundsettingsbase.h + +moc_soundsettings.cpp: soundsettings.h + $(MOC) soundsettings.h -o moc_soundsettings.cpp + +moc_soundsettingsbase.cpp: soundsettingsbase.h + $(MOC) soundsettingsbase.h -o moc_soundsettingsbase.cpp + + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "soundsettings.h" + +#include <qpe/qpeapplication.h> + + +int main(int argc, char** argv) +{ + QPEApplication a(argc,argv); + + SoundSettings dlg; + + a.showMainWidget(&dlg); + + return a.exec(); +} + 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 @@ +Files: bin/sound apps/Settings/Sound.desktop +Priority: optional +Section: qpe/settings +Maintainer: Warwick Allison <warwick@trolltech.com> +Architecture: arm +Arch: iPAQ +Version: $QPE_VERSION-1 +Depends: qpe-base ($QPE_VERSION) +Description: Sound settings dialog + 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 @@ +TEMPLATE = app +CONFIG += qt warn_on release +DESTDIR = ../../bin +HEADERS = soundsettings.h +SOURCES = soundsettings.cpp main.cpp +INTERFACES = soundsettingsbase.ui +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include +LIBS += -lqpe +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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#include "soundsettings.h" + +#include <qpe/config.h> +#include <qpe/qcopenvelope_qws.h> + +#include <qslider.h> +#include <qcheckbox.h> + +SoundSettings::SoundSettings( QWidget* parent, const char* name, WFlags fl ) + : SoundSettingsBase( parent, name, TRUE, fl ) +{ + Config config( "Sound" ); + + config.setGroup( "System" ); + volume->setValue(100-config.readNumEntry("Volume")); + touchsound->setChecked(config.readBoolEntry("Touch")); + keysound->setChecked(config.readBoolEntry("Key")); + + connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); +} + +void SoundSettings::reject() +{ + Config config( "Sound" ); + config.setGroup( "System" ); + setVolume(100-config.readNumEntry("Volume")); + + QDialog::reject(); +} + +void SoundSettings::accept() +{ + Config config( "Sound" ); + config.setGroup( "System" ); + config.writeEntry("Volume",100-volume->value()); + config.writeEntry("Touch",touchsound->isChecked()); + config.writeEntry("Key",keysound->isChecked()); + setVolume(volume->value()); + QDialog::accept(); +} + +void SoundSettings::setVolume(int v) +{ + QCopEnvelope( "QPE/System", "setVolume(int,int)" ) << 0 << 100-v; +} 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef SOUNDSETTINGS_H +#define SOUNDSETTINGS_H + + +#include "soundsettingsbase.h" + + +class SoundSettings : public SoundSettingsBase +{ + Q_OBJECT + +public: + SoundSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + +protected: + void accept(); + void reject(); + +private slots: + void setVolume(int); +}; + + +#endif // SOUNDSETTINGS_H + 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 @@ +<!DOCTYPE UI><UI> +<class>SoundSettingsBase</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>SoundSettingsBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>246</width> + <height>299</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Sound Settings</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>7</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>1</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>keysound</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Keyboard sound</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>touchsound</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Screen sound</string> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QSlider</class> + <property stdset="1"> + <name>name</name> + <cstring>volume</cstring> + </property> + <property stdset="1"> + <name>maxValue</name> + <number>100</number> + </property> + <property stdset="1"> + <name>value</name> + <number>50</number> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>tickmarks</name> + <enum>Right</enum> + </property> + <property stdset="1"> + <name>tickInterval</name> + <number>5</number> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10_2</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>PixmapLabel1_2</cstring> + </property> + <property stdset="1"> + <name>pixmap</name> + <pixmap>image0</pixmap> + </property> + <property stdset="1"> + <name>scaledContents</name> + <bool>false</bool> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Loud</string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer3_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer5_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9_2</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>PixmapLabel2_2</cstring> + </property> + <property stdset="1"> + <name>pixmap</name> + <pixmap>image1</pixmap> + </property> + <property stdset="1"> + <name>scaledContents</name> + <bool>false</bool> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Silent</string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer2_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="409">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022630543251d2e253d856405bffcbc54103b11c856360003105719c44d4b8371f590803210638829a38b2983115c2c112a8224969808d60716868a2582c440aa94a1628960a00755a5ac8c2aa64c8118c23c6cf6c2dda787e23eb03f602af1fa17395c6aadb9008c9350cb</data> + </image> + <image> + <name>image1</name> + <data format="XPM.GZ" length="409">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022630543251d2e253d856405bffcbc54105b19c856360003103711c44d4b8371f5d000c962ca9862ca9862ca60b1440806bb0a0c80dcc444304616030924a2a983a8d423a80ed93c6cf6e2701f567f100c835a6b2e0025ab4ee4</data> + </image> +</images> +</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 @@ +moc_* +*.moc +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 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = $(QPEDIR)/bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = sysinfo +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = memory.h \ + graph.h \ + load.h \ + storage.h \ + versioninfo.h \ + sysinfo.h +SOURCES = main.cpp \ + memory.cpp \ + graph.cpp \ + load.cpp \ + storage.cpp \ + versioninfo.cpp \ + sysinfo.cpp +OBJECTS = main.o \ + memory.o \ + graph.o \ + load.o \ + storage.o \ + versioninfo.o \ + sysinfo.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_memory.cpp \ + moc_graph.cpp \ + moc_load.cpp \ + moc_storage.cpp \ + moc_versioninfo.cpp \ + moc_sysinfo.cpp +OBJMOC = moc_memory.o \ + moc_graph.o \ + moc_load.o \ + moc_storage.o \ + moc_versioninfo.o \ + moc_sysinfo.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake sysinfo.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +main.o: main.cpp \ + sysinfo.h \ + $(QPEDIR)/include/qpe/qpeapplication.h + +memory.o: memory.cpp \ + graph.h \ + memory.h + +graph.o: graph.cpp \ + graph.h + +load.o: load.cpp \ + load.h + +storage.o: storage.cpp \ + graph.h \ + storage.h + +versioninfo.o: versioninfo.cpp \ + $(QPEDIR)/include/qpe/resource.h \ + $(QPEDIR)/include/qpe/version.h \ + versioninfo.h + +sysinfo.o: sysinfo.cpp \ + memory.h \ + load.h \ + storage.h \ + versioninfo.h \ + sysinfo.h \ + $(QPEDIR)/include/qpe/resource.h + +moc_memory.o: moc_memory.cpp \ + memory.h + +moc_graph.o: moc_graph.cpp \ + graph.h + +moc_load.o: moc_load.cpp \ + load.h + +moc_storage.o: moc_storage.cpp \ + storage.h + +moc_versioninfo.o: moc_versioninfo.cpp \ + versioninfo.h + +moc_sysinfo.o: moc_sysinfo.cpp \ + sysinfo.h + +moc_memory.cpp: memory.h + $(MOC) memory.h -o moc_memory.cpp + +moc_graph.cpp: graph.h + $(MOC) graph.h -o moc_graph.cpp + +moc_load.cpp: load.h + $(MOC) load.h -o moc_load.cpp + +moc_storage.cpp: storage.h + $(MOC) storage.h -o moc_storage.cpp + +moc_versioninfo.cpp: versioninfo.h + $(MOC) versioninfo.h -o moc_versioninfo.cpp + +moc_sysinfo.cpp: sysinfo.h + $(MOC) sysinfo.h -o moc_sysinfo.cpp + + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qpainter.h> +#include <qpixmap.h> +#include "graph.h" + +void GraphData::clear() +{ + names.clear(); + values.resize(0); +} + +void GraphData::addItem( const QString &name, int value ) +{ + names.append( name ); + values.resize( values.size() + 1 ); + values[values.size()-1] = value; +} + +Graph::Graph(QWidget *parent, const char *name, WFlags f ) + : QFrame( parent, name, f ) +{ +} + +PieGraph::PieGraph(QWidget *parent, const char *name, WFlags f ) + : Graph( parent, name, f ) +{ +} + +void PieGraph::drawContents( QPainter *p ) +{ + int size = QMIN( contentsRect().width(), contentsRect().height() ) - 1; + + int total = 0; + for ( unsigned i = 0; i < data->count(); i++ ) + total += data->value(i); + + int angle = 0; + for ( unsigned i = 0; i < data->count(); i++ ) { + int len; + if ( i == data->count() - 1 || !total ) + len = 5760 - angle; + else + len = data->value(i) * 5760 / total; + QColor col; + col.setHsv( i * 360 / data->count(), 255, 255 ); + p->setBrush( col ); + p->drawPie ( contentsRect().x(), contentsRect().y(), + size, size, angle, len+32 ); + angle += len; + } +} + +BarGraph::BarGraph(QWidget *parent, const char *name, WFlags f ) + : Graph( parent, name, f ) +{ + setMinimumHeight( 10 ); + setMaximumHeight( 45 ); +} + +void BarGraph::drawContents( QPainter *p ) +{ + int h = contentsRect().height(); + int y = contentsRect().top(); + + int total = 0; + for ( unsigned i = 0; i < data->count(); i++ ) + total += data->value(i); + + int pos = 0; + for ( unsigned i = 0; i < data->count(); i++ ) { + int len; + if ( i == data->count() - 1 || !total ) + len = contentsRect().width() - pos; + else + len = data->value(i) * contentsRect().width() / total; + QColor col; + col.setHsv( i * 360 / data->count(), 255, 255 ); + drawSegment( p, QRect(contentsRect().x() + pos, y, len, h), col ); + pos += len; + } +} + +void BarGraph::drawSegment( QPainter *p, const QRect &r, const QColor &c ) +{ + if ( QPixmap::defaultDepth() > 8 ) { + QColor topgrad = c.light(170); + QColor botgrad = c.dark(); + + int h1, h2, s1, s2, v1, v2; + topgrad.hsv( &h1, &s1, &v1 ); + botgrad.hsv( &h2, &s2, &v2 ); + int ng = r.height(); + for ( int j =0; j < ng; j++ ) { + p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), + s1 + ((s2-s1)*j)/(ng-1), + v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); + p->drawLine( r.x(), r.top()+j, r.x()+r.width(), r.top()+j ); + } + } else { + p->fillRect( r.x(), r.top(), r.width(), r.height(), c ); + } +} + + +GraphLegend::GraphLegend( QWidget *parent, const char *name, WFlags f ) + : QFrame( parent, name, f ) +{ + horz = FALSE; +} + +void GraphLegend::setOrientation(Orientation o) +{ + horz = o == Horizontal; +} + +void GraphLegend::drawContents( QPainter *p ) +{ + int total = 0; + for ( unsigned i = 0; i < data->count(); i++ ) + total += data->value(i); + + int tw = width()/data->count()-1; + int th = height()/(horz ? 1 : data->count()); + if ( th > p->fontMetrics().height() ) + th = p->fontMetrics().height(); + int x = 0; + int y = 0; + for ( unsigned i = 0; i < data->count(); i++ ) { + QColor col; + col.setHsv( i * 360 / data->count(), 255, 255 ); + p->setBrush( col ); + p->drawRect( x+1, y+1, th - 2, th - 2 ); + p->drawText( x+th + 1, y + p->fontMetrics().ascent()+1, data->name(i) ); + if ( horz ) { + x += tw; + } else { + y += th; + } + } +} + +QSize GraphLegend::sizeHint() const +{ + int th = fontMetrics().height() + 2; + int maxw = 0; + for ( unsigned i = 0; i < data->count(); i++ ) { + int w = fontMetrics().width( data->name(i) ); + if ( w > maxw ) + maxw = w; + } + if ( 0 && horz ) { + return QSize( maxw * data->count(), th ); + } else { + return QSize( maxw, th * data->count() ); + } +} + +void GraphLegend::setData( const GraphData *p ) +{ + data = p; + int th = fontMetrics().height(); + setMinimumHeight( th * ( horz ? 1 : data->count() ) ); + updateGeometry(); +} diff --git a/noncore/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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qframe.h> +#include <qarray.h> +#include <qstringlist.h> + +class GraphData +{ +public: + void clear(); + void addItem( const QString &name, int value ); + + const QString &name( int i ) const { return names[i]; } + int value( int i ) const { return values[i]; } + unsigned count() const { return values.size(); } + +private: + QStringList names; + QArray<int> values; +}; + +class Graph : public QFrame +{ + Q_OBJECT +public: + Graph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + void setData( const GraphData *p ) { data = p; } + +protected: + const GraphData *data; +}; + +class PieGraph : public Graph +{ + Q_OBJECT +public: + PieGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + +protected: + virtual void drawContents( QPainter *p ); +}; + +class BarGraph : public Graph +{ + Q_OBJECT +public: + BarGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + +protected: + virtual void drawContents( QPainter *p ); + void drawSegment( QPainter *p, const QRect &r, const QColor &c ); +}; + +class GraphLegend : public QFrame +{ + Q_OBJECT +public: + GraphLegend( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + void setData( const GraphData *p ); + virtual QSize sizeHint() const; + void setOrientation(Orientation o); + +protected: + virtual void drawContents( QPainter *p ); + +private: + const GraphData *data; + bool horz; +}; diff --git a/noncore/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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <stdio.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qpixmap.h> +#include <qtimer.h> +#include <qfile.h> +#include <qtextstream.h> +#include "load.h" + +LoadInfo::LoadInfo( QWidget *parent, const char *name, WFlags f ) + : QWidget( parent, name, f ) +{ + QVBoxLayout *vb = new QVBoxLayout( this, 6 ); + + QString cpuInfo = getCpuInfo(); + if ( !cpuInfo.isNull() ) + vb->addWidget( new QLabel( cpuInfo, this ) ); + vb->addWidget( new Load( this ), 100 ); + QLabel *l = new QLabel( this ); + l->setPixmap( makeLabel( red, tr("Application CPU usage (%)") ) ); + vb->addWidget( l, 1 ); + l = new QLabel( this ); + l->setPixmap( makeLabel( green, tr("System CPU usage (%)") ) ); + vb->addWidget( l, 1 ); + vb->addStretch(50); +} + +QPixmap LoadInfo::makeLabel( const QColor &col, const QString &text ) +{ + int h = fontMetrics().height(); + QPixmap pm( 20 + fontMetrics().width( text ), h ); + QPainter p( &pm ); + p.fillRect( pm.rect(), colorGroup().background() ); + p.fillRect( 0, h/2-4, 18, h/2+3, black ); + p.setPen( col ); + p.drawLine( 2, h/2, 15, h/2 ); + p.setPen( colorGroup().text() ); + p.drawText( 20, fontMetrics().ascent(), text ); + + return pm; +} + +QString LoadInfo::getCpuInfo() +{ + bool haveInfo = FALSE; + QString info = tr("Type: "); + QFile f( "/proc/cpuinfo" ); + if ( f.open( IO_ReadOnly ) ) { + QTextStream ts( &f ); + + while ( !ts.atEnd() ) { + QString s = ts.readLine(); + if ( s.find( "model name" ) == 0 ) { + info += s.mid( s.find( ':' ) + 2 ); + haveInfo = TRUE; + } else if ( s.find( "cpu MHz" ) == 0 ) { + double mhz = s.mid( s.find( ':' ) + 2 ).toDouble(); + info += " " + QString::number( mhz, 'f', 0 ); + info += "MHz"; + break; + } else if ( s.find( "Processor" ) == 0 ) { + info += s.mid( s.find( ':' ) + 2 ); + haveInfo = TRUE; + break; +#ifdef __MIPSEL__ + } else if ( s.find( "cpu model" ) == 0 ) { + info += " " + s.mid( s.find( ':' ) + 2 ); + break; + } else if ( s.find( "cpu" ) == 0 ) { + info += s.mid( s.find( ':' ) + 2 ); + haveInfo = TRUE; +#endif + } + } + } + + if ( !haveInfo ) + info = QString(); + + return info; +} + +Load::Load( QWidget *parent, const char *name, WFlags f ) + : QWidget( parent, name, f ) +{ + setMinimumHeight( 30 ); + setBackgroundColor( black ); + points = 100; + setMinimumWidth( points ); + userLoad = new double [points]; + systemLoad = new double [points]; + for ( int i = 0; i < points; i++ ) { + userLoad[i] = 0.0; + systemLoad[i] = 0.0; + } + maxLoad = 1.3; + QTimer *timer = new QTimer( this ); + connect( timer, SIGNAL(timeout()), SLOT(timeout()) ); + timer->start( 2000 ); + gettimeofday( &last, 0 ); + first = TRUE; + timeout(); +} + +void Load::paintEvent( QPaintEvent *ev ) +{ + QPainter p( this ); + + int h = height() - 5; + + int mult = (int)(h / maxLoad); + + p.setPen( gray ); + p.drawLine( 0, h - mult, width(), h - mult ); + p.drawText( 0, h - mult, "100" ); + p.drawText( 0, h, "0" ); + + p.setPen( green ); + for ( int i = 1; i < points; i++ ) { + int x1 = (i - 1) * width() / points; + int x2 = i * width() / points; + p.drawLine( x1, h - systemLoad[i-1] * mult, + x2, h - systemLoad[i] * mult ); + } + + p.setPen( red ); + for ( int i = 1; i < points; i++ ) { + int x1 = (i - 1) * width() / points; + int x2 = i * width() / points; + p.drawLine( x1, h - userLoad[i-1] * mult, + x2, h - userLoad[i] * mult ); + } +} + +void Load::timeout() +{ + int user; + int usernice; + int sys; + int idle; + FILE *fp; + fp = fopen( "/proc/stat", "r" ); + fscanf( fp, "cpu %d %d %d %d", &user, &usernice, &sys, &idle ); + fclose( fp ); + struct timeval now; + gettimeofday( &now, 0 ); + int tdiff = now.tv_usec - last.tv_usec; + tdiff += (now.tv_sec - last.tv_sec) * 1000000; + tdiff /= 10000; + + int udiff = user - lastUser; + int sdiff = sys - lastSys; + if ( tdiff > 0 ) { + double uload = (double)udiff / (double)tdiff; + double sload = (double)sdiff / (double)tdiff; + if ( !first ) { + for ( int i = 1; i < points; i++ ) { + userLoad[i-1] = userLoad[i]; + systemLoad[i-1] = systemLoad[i]; + } + userLoad[points-1] = uload; + systemLoad[points-1] = sload; +// scroll( -width()/points, 0, QRect( 0, 0, width() - width()/points + 1, height() ) ); + repaint( TRUE ); + double ml = 1.3; + /* + for ( int i = 0; i < points; i++ ) { + if ( userLoad[i] > ml ) + ml = userLoad[i]; + } + */ + if ( maxLoad != ml ) { + maxLoad = ml; + update(); + } + } + + last = now; + lastUser = user; + lastSys = sys; + first = FALSE; + } else if ( tdiff < 0 ) { + last = now; + } +} + diff --git a/noncore/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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <sys/time.h> +#include <qwidget.h> + +/* + Little load meter +*/ +class Load : public QWidget { + Q_OBJECT +public: + Load( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + +protected: + void paintEvent( QPaintEvent *ev ); + +private slots: + void timeout(); + +private: + int points; + double *userLoad; + double *systemLoad; + double maxLoad; + struct timeval last; + int lastUser; + int lastUsernice; + int lastSys; + int lastIdle; + bool first; +}; + +class LoadInfo : public QWidget +{ + Q_OBJECT +public: + LoadInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + +private: + QPixmap makeLabel( const QColor &col, const QString &text ); + QString getCpuInfo(); +}; diff --git a/noncore/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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "sysinfo.h" + +#include <qpe/qpeapplication.h> + +int main( int argc, char *argv[] ) +{ + QPEApplication a( argc, argv ); + + SystemInfo *si = new SystemInfo(); + a.showMainWidget( si ); + + return a.exec(); +} + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qlabel.h> +#include <qtimer.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qlayout.h> +#include "graph.h" +#include "memory.h" + +MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags f ) + : QWidget( parent, name, f ) +{ + QVBoxLayout *vb = new QVBoxLayout( this, 5 ); + + totalMem = new QLabel( this ); + vb->addWidget( totalMem ); + + data = new GraphData(); +// graph = new PieGraph( this ); + graph = new BarGraph( this ); + graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + vb->addWidget( graph, 1 ); + graph->setData( data ); + + legend = new GraphLegend( this ); + vb->addWidget( legend ); + legend->setData( data ); + + vb->addStretch( 1 ); + updateData(); + + QTimer *t = new QTimer( this ); + connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); + t->start( 5000 ); +} + +MemoryInfo::~MemoryInfo() +{ + delete data; +} + +void MemoryInfo::updateData() +{ + QFile file( "/proc/meminfo" ); + + if ( file.open( IO_ReadOnly ) ) { + QTextStream t( &file ); + QString dummy = t.readLine(); // title + t >> dummy; + int total, used, memfree, shared, buffers, cached; + t >> total; + total /= 1000; + t >> used; + used /= 1000; + t >> memfree; + memfree /= 1000; + t >> shared; + shared /= 1000; + t >> buffers; + buffers /= 1000; + t >> cached; + cached /= 1000; + int realUsed = total - ( buffers + cached + memfree ); + data->clear(); + data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed ); + data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers ); + data->addItem( tr("Cached (%1 kB)").arg(cached), cached ); + data->addItem( tr("Free (%1 kB)").arg(memfree), memfree ); + totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) ); + graph->repaint( FALSE ); + legend->update(); + } +} + + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef MEMORY_H +#define MEMORY_H + +#include <qwidget.h> + +class GraphData; +class Graph; +class GraphLegend; +class QLabel; + +class MemoryInfo : public QWidget +{ + Q_OBJECT +public: + MemoryInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + ~MemoryInfo(); + +private slots: + void updateData(); + +private: + QLabel *totalMem; + GraphData *data; + Graph *graph; + GraphLegend *legend; +}; + +#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 @@ +Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/qpe-logo.png pics/tux-logo.png +Priority: optional +Section: qpe/applications +Maintainer: Warwick Allison <warwick@trolltech.com> +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: System Information dialog + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qlabel.h> +#include <qlayout.h> +#include <qtimer.h> +#include <qlayout.h> +#include "graph.h" +#include "storage.h" + +#include <stdio.h> +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) +#include <sys/vfs.h> +#include <mntent.h> +#endif + +StorageInfo::StorageInfo( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + vb = 0; + disks.setAutoDelete(TRUE); + lines.setAutoDelete(TRUE); + updateMounts(); + startTimer( 5000 ); +} + +void StorageInfo::timerEvent(QTimerEvent*) +{ + updateMounts(); +} + +static bool isCF(const QString& m) +{ + FILE* f = fopen("/var/run/stab", "r"); + if (!f) f = fopen("/var/state/pcmcia/stab", "r"); + if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); + if ( f ) { + char line[1024]; + char devtype[80]; + char devname[80]; + while ( fgets( line, 1024, f ) ) { + // 0 ide ide-cs 0 hda 3 0 + if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) + { + if ( QString(devtype) == "ide" && m.find(devname)>0 ) { + fclose(f); + return TRUE; + } + } + } + fclose(f); + } + return FALSE; +} + +void StorageInfo::updateMounts() +{ +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) + struct mntent *me; + FILE *mntfp = setmntent( "/etc/mtab", "r" ); + QStringList curdisks; + QStringList curfs; + bool rebuild = FALSE; + int n=0; + if ( mntfp ) { + while ( (me = getmntent( mntfp )) != 0 ) { + QString fs = me->mnt_fsname; + if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" + || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" ) + { + n++; + curdisks.append(fs); + QString d = me->mnt_dir; + curfs.append(d); + if ( !disks.find(d) ) + rebuild = TRUE; + } + } + endmntent( mntfp ); + } + if ( rebuild || n != (int)disks.count() ) { + disks.clear(); + lines.clear(); + delete vb; + vb = new QVBoxLayout( this, n > 3 ? 1 : 5 ); + bool frst=TRUE; + QStringList::ConstIterator it=curdisks.begin(); + QStringList::ConstIterator fsit=curfs.begin(); + for (; it!=curdisks.end(); ++it, ++fsit) { + if ( !frst ) { + QFrame *f = new QFrame( this ); + vb->addWidget(f); + f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + lines.append(f); + f->show(); + } frst=FALSE; + QString humanname=*it; + if ( isCF(humanname) ) + humanname = tr("CF Card"); + else if ( humanname == "/dev/hda1" ) + humanname = tr("Hard Disk"); + else if ( humanname.left(9) == "/dev/mmcd" ) + humanname = tr("SD Card"); + else if ( humanname.left(7) == "/dev/hd" ) + humanname = tr("Hard Disk") + " " + humanname.mid(7); + else if ( humanname.left(7) == "/dev/sd" ) + humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7); + else if ( humanname == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) + humanname = tr("Internal Storage"); + else if ( humanname.left(14) == "/dev/mtdblock/" ) + humanname = tr("Internal Storage") + " " + humanname.mid(14); + else if ( humanname.left(13) == "/dev/mtdblock" ) + humanname = tr("Internal Storage") + " " + humanname.mid(13); + // etc. + MountInfo* mi = new MountInfo( *fsit, humanname, this ); + vb->addWidget(mi); + disks.insert(*fsit,mi); + mi->show(); + } + vb->addStretch(); + } else { + // just update them + for (QDictIterator<MountInfo> i(disks); i.current(); ++i) + i.current()->updateData(); + } +#endif +} + + +MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name ) + : QWidget( parent, name ), title(ttl) +{ + fs = new FileSystem( path ); + QVBoxLayout *vb = new QVBoxLayout( this, 3 ); + + totalSize = new QLabel( this ); + vb->addWidget( totalSize ); + + data = new GraphData(); + graph = new BarGraph( this ); + graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + vb->addWidget( graph, 1 ); + graph->setData( data ); + + legend = new GraphLegend( this ); + legend->setOrientation(Horizontal); + vb->addWidget( legend ); + legend->setData( data ); + + updateData(); +} + +MountInfo::~MountInfo() +{ + delete data; + delete fs; +} + +void MountInfo::updateData() +{ + fs->update(); + + long mult = fs->blockSize() / 1024; + long div = 1024 / fs->blockSize(); + if ( !mult ) mult = 1; + if ( !div ) div = 1; + long total = fs->totalBlocks() * mult / div; + long avail = fs->availBlocks() * mult / div; + long used = total - avail; + totalSize->setText( title + tr(" total: %1 kB").arg( total ) ); + data->clear(); + data->addItem( tr("Used (%1 kB)").arg(used), used ); + data->addItem( tr("Available (%1 kB)").arg(avail), avail ); + graph->repaint( FALSE ); + legend->update(); + graph->show(); + legend->show(); +} + +//--------------------------------------------------------------------------- + +FileSystem::FileSystem( const QString &p ) + : fspath( p ), blkSize(512), totalBlks(0), availBlks(0) +{ + update(); +} + +void FileSystem::update() +{ +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) + struct statfs fs; + if ( !statfs( fspath.latin1(), &fs ) ) { + blkSize = fs.f_bsize; + totalBlks = fs.f_blocks; + availBlks = fs.f_bavail; + } else { + blkSize = 0; + totalBlks = 0; + availBlks = 0; + } +#endif +} + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#include <qwidget.h> +#include <qframe.h> +#include <qlist.h> +#include <qdict.h> + +class QLabel; +class GraphData; +class Graph; +class GraphLegend; +class FileSystem; +class MountInfo; +class QVBoxLayout; + + +class StorageInfo : public QWidget +{ + Q_OBJECT +public: + StorageInfo( QWidget *parent=0, const char *name=0 ); + +protected: + void timerEvent(QTimerEvent*); + +private: + void updateMounts(); + QDict<MountInfo> disks; + QList<QFrame> lines; + QVBoxLayout *vb; +}; + +class MountInfo : public QWidget +{ + Q_OBJECT +public: + MountInfo( const QString &path, const QString &ttl, QWidget *parent=0, const char *name=0 ); + ~MountInfo(); + + void updateData(); + +private: + QString title; + FileSystem *fs; + QLabel *totalSize; + GraphData *data; + Graph *graph; + GraphLegend *legend; +}; + +class FileSystem +{ +public: + FileSystem( const QString &p ); + + void update(); + + const QString &path() const { return fspath; } + long blockSize() const { return blkSize; } + long totalBlocks() const { return totalBlks; } + long availBlocks() const { return availBlks; } + +private: + QString fspath; + long blkSize; + long totalBlks; + long availBlks; +}; + + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "memory.h" +#include "load.h" +#include "storage.h" +//#include "graphics.h" +#include "versioninfo.h" +#include "sysinfo.h" + + +#include <qpe/resource.h> + +#include <qtabwidget.h> +#include <qlayout.h> + +SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f ) + : QWidget( parent, name, f ) +{ + setIcon( Resource::loadPixmap( "system_icon" ) ); + setCaption( tr("System Info") ); + QVBoxLayout *lay = new QVBoxLayout( this ); + QTabWidget *tab = new QTabWidget( this ); + lay->addWidget( tab ); + tab->addTab( new MemoryInfo( tab ), tr("Memory") ); +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) + tab->addTab( new StorageInfo( tab ), tr("Storage") ); +#endif + tab->addTab( new LoadInfo( tab ), tr("CPU") ); +// tab->addTab( new Graphics( tab ), tr("Graphics") ); + tab->addTab( new VersionInfo( tab ), tr("Version") ); + + resize( 220, 180 ); +} + + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qwidget.h> + +class SystemInfo : public QWidget +{ + Q_OBJECT +public: + SystemInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); +}; + 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 @@ +TEMPLATE = app +CONFIG = qt warn_on release +DESTDIR = $(QPEDIR)/bin +HEADERS = memory.h \ + graph.h \ + load.h \ + storage.h \ + versioninfo.h \ + sysinfo.h +SOURCES = main.cpp \ + memory.cpp \ + graph.cpp \ + load.cpp \ + storage.cpp \ + versioninfo.cpp \ + sysinfo.cpp +INTERFACES = + +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += $(QPEDIR)/include +LIBS += -lqpe + +TARGET = sysinfo + +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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qpe/resource.h> +#include <qpe/version.h> + +#include <qlabel.h> +#include <qpixmap.h> +#include <qpainter.h> +#include <qimage.h> +#include <qtimer.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qlayout.h> +#include "versioninfo.h" + +VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f ) + : QWidget( parent, name, f ) +{ + setMinimumSize( 200, 150 ); + + QVBoxLayout *vb = new QVBoxLayout( this, 4 ); + + QString kernelVersionString; + QFile file( "/proc/version" ); + if ( file.open( IO_ReadOnly ) ) { + QTextStream t( &file ); + QString v; + t >> v; t >> v; t >> v; + v = v.left( 20 ); + kernelVersionString = tr( "<b>Linux Kernel</b><p>Version: " ) + v + "<p>"; + t >> v; + kernelVersionString += tr( "Compiled by: " ) + v; + file.close(); + } + + QString palmtopVersionString; + palmtopVersionString = tr( "<b>Qtopia</b><p>Version: " ) + QPE_VERSION + "<p>"; +#ifdef QPE_VENDOR + QString builder = QPE_VENDOR; +#else + QString builder = "Unknown"; +#endif + palmtopVersionString += tr( "Compiled by: " ) + builder + "<p>"; + palmtopVersionString += tr( "Built on: " ) + __DATE__; + + + QHBoxLayout *hb1 = new QHBoxLayout( vb ); + hb1->setSpacing( 2 ); + + QLabel *palmtopLogo = new QLabel( this ); + QImage logo1 = Resource::loadImage( "qpe-logo" ); + logo1 = logo1.smoothScale( 50, 55 ); + QPixmap logo1Pixmap; + logo1Pixmap.convertFromImage( logo1 ); + palmtopLogo->setPixmap( logo1Pixmap ); + palmtopLogo->setFixedSize( 60, 60 ); + hb1->addWidget( palmtopLogo, 0, Qt::AlignTop + Qt::AlignLeft ); + + QLabel *palmtopVersion = new QLabel( this ); + palmtopVersion->setText( palmtopVersionString ); + hb1->addWidget( palmtopVersion, 1, Qt::AlignTop + Qt::AlignLeft ); + + + QHBoxLayout *hb2 = new QHBoxLayout( vb ); + hb1->setSpacing( 2 ); + + QLabel *linuxLogo = new QLabel( this ); + + // Need to do this extra qpainter code with this image becuase for some + // reason it doesn't alpha belnd if directly converted to a pixmap + QPixmap logo2Pixmap( 60, 60 ); + QColor bgColor = colorGroup().background(); + QPainter painter( &logo2Pixmap ); + painter.fillRect( QRect( 0, 0, 60, 60 ), QBrush( bgColor ) ); + QImage logo2 = Resource::loadImage( "tux-logo" ); + logo2 = logo2.smoothScale( 40, 47 ); + painter.drawImage( 0, 0, logo2 ); + painter.end(); + linuxLogo->setPixmap( logo2Pixmap ); + linuxLogo->setFixedSize( 60, 60 ); + hb2->addWidget( linuxLogo, 0, Qt::AlignTop + Qt::AlignLeft ); + + QLabel *kernelVersion = new QLabel( this ); + kernelVersion->setText( kernelVersionString ); + hb2->addWidget( kernelVersion, 1, Qt::AlignTop + Qt::AlignLeft ); +} + +VersionInfo::~VersionInfo() +{ +} + 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 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef VERSIONINFO_H +#define VERSIONINFO_H + +#include <qwidget.h> + +class VersionInfo : public QWidget +{ + Q_OBJECT +public: + VersionInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + ~VersionInfo(); +}; + +#endif |