You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kima/src/sources/omnibookthermalsrc.cpp

59 lines
2.4 KiB

/***************************************************************************
* Copyright (C) 2006 by Ken Werner *
* ken.werner@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "omnibookthermalsrc.h"
#include <qtextstream.h>
#include <qfile.h>
#include <klocale.h>
OmnibookThermalSrc::OmnibookThermalSrc(QWidget* inParent, const QFile& inSourceFile):
LabelSource(inParent),
mSourceFile(inSourceFile.name()),
mTrigger(this){
mID = "CPU";
mName = mID;
mDescription = i18n("This source is provided by the Omnibook Configuration Tools & Patches.");
}
OmnibookThermalSrc::~OmnibookThermalSrc(){
}
std::list<Source*>OmnibookThermalSrc::createInstances(QWidget* inParent){
std::list<Source*> list;
QFile omiFile( "/proc/omnibook/temperature" );
if(omiFile.open(IO_ReadOnly)){
list.push_back(new OmnibookThermalSrc(inParent, omiFile));
}
return list;
}
QString OmnibookThermalSrc::fetchValue(){
QString s = "n/a";
if(mSourceFile.open(IO_ReadOnly)){
QTextStream textStream( &mSourceFile );
s = textStream.readLine();
mSourceFile.close();
s = s.section(':',-1,-1, QString::SectionSkipEmpty).stripWhiteSpace();
s = formatTemperature(s.left(s.length()-1));
}
return s;
}