diff options
author | Ken Moore <ken@pcbsd.org> | 2015-05-22 12:11:01 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-05-22 12:11:01 -0400 |
commit | 766980aeaba64e23001c7437220dd67afd70c052 (patch) | |
tree | dad60ac664a3598aee13d0801b3334aeea0d1220 /libLumina/LuminaUtils.cpp | |
parent | Add a few new functions to LuminaOS: (diff) | |
download | lumina-766980aeaba64e23001c7437220dd67afd70c052.tar.gz lumina-766980aeaba64e23001c7437220dd67afd70c052.tar.bz2 lumina-766980aeaba64e23001c7437220dd67afd70c052.zip |
Finish cleaning up the new CPU/Memory desction routines in libLumina, and add a new desktop plugin for monitoring system statistics (CPU/Mem usage, CPU temps).
Diffstat (limited to 'libLumina/LuminaUtils.cpp')
-rw-r--r-- | libLumina/LuminaUtils.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index f1c007f0..8eee76ca 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -26,35 +26,33 @@ QString LUtils::LuminaDesktopVersion(){ } int LUtils::runCmd(QString cmd, QStringList args){ - QProcess *proc = new QProcess; - proc->setProcessChannelMode(QProcess::MergedChannels); + QProcess proc; + proc.setProcessChannelMode(QProcess::MergedChannels); if(args.isEmpty()){ - proc->start(cmd); + proc.start(cmd); }else{ - proc->start(cmd, args); + proc.start(cmd, args); } - while(!proc->waitForFinished(300)){ + while(!proc.waitForFinished(300)){ QCoreApplication::processEvents(); } - int ret = proc->exitCode(); - delete proc; + int ret = proc.exitCode(); return ret; } QStringList LUtils::getCmdOutput(QString cmd, QStringList args){ - QProcess *proc = new QProcess; - proc->setProcessChannelMode(QProcess::MergedChannels); + QProcess proc; + proc.setProcessChannelMode(QProcess::MergedChannels); if(args.isEmpty()){ - proc->start(cmd); + proc.start(cmd); }else{ - proc->start(cmd,args); + proc.start(cmd,args); } - while(!proc->waitForFinished(300)){ + while(!proc.waitForFinished(500)){ QCoreApplication::processEvents(); } - QStringList out = QString(proc->readAllStandardOutput()).split("\n"); - delete proc; + QStringList out = QString(proc.readAllStandardOutput()).split("\n"); return out; } @@ -148,6 +146,8 @@ void LUtils::LoadTranslation(QApplication *app, QString appname){ double LUtils::DisplaySizeToBytes(QString num){ num = num.toLower().simplified(); + num = num.remove(" "); + if(num.isEmpty()){ return 0.0; } if(num.endsWith("b")){ num.chop(1); } //remove the "bytes" marker (if there is one) QString lab = "b"; if(!num[num.size()-1].isNumber()){ |