From: Daniel Klaffenbach Date: Tue, 21 Dec 2010 12:55:00 +0000 (+0100) Subject: Make the settings dialog aware of the presence of kernel-config X-Git-Tag: v0.4.2~2 X-Git-Url: https://vcs.maemo.org/git/?p=qcpufreq;a=commitdiff_plain;h=5c5e19a39099ab6ff7cb3f7ab65ef1d12c3f4e3b Make the settings dialog aware of the presence of kernel-config --- diff --git a/src/settings.cpp b/src/settings.cpp index 23eab34..eaa72f1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -41,16 +41,20 @@ Settings::Settings(QWidget *parent) : overclocking = settings.value("main/overclocking", false).toBool(); advancedTemperature = settings.value("main/advanced_temperature", false).toBool(); - /* The next few lines of code check if QCPUFreq is running on a power kernel. + /* The next few lines of code check if QCPUFreq is running on a power kernel and if + * the kernel-config script is installed. + * * Basically we get the maximum available frequency - if it is greater than * DEFAULT_FREQUENCY we can be sure that the current kernel is a power kernel. */ QFile file( "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies" ); + powerKernel = false; + kernelConfigInstalled = false; + //open the file if ( !file.exists() || !file.open( QIODevice::ReadOnly ) ) { QMessageBox::critical(this, tr("QCPUFreq"), tr("Could not get information from /sys!")); - powerKernel = false; } else { //read the file QTextStream in( &file ); @@ -62,8 +66,12 @@ Settings::Settings(QWidget *parent) : if (maxFreq > DEFAULT_FREQUENCY) { powerKernel = true; - } else { - powerKernel = false; + } + + //Check if kernel-config is installed + file.setFileName("/usr/sbin/kernel-config"); + if (file.exists()) { + kernelConfigInstalled = true; } } @@ -87,6 +95,15 @@ Settings::~Settings() /** + * Returns True if the kernel-config script is installed. + */ +bool Settings::isKernelConfigInstalled() +{ + return kernelConfigInstalled; +} + + +/** * Returns true if we are on a Maemo 5 OS. */ bool Settings::platformMaemo() diff --git a/src/settings.h b/src/settings.h index 0ab3179..87c8463 100644 --- a/src/settings.h +++ b/src/settings.h @@ -33,6 +33,7 @@ class Settings : public QDialog public: explicit Settings(QWidget *parent = 0); ~Settings(); + bool isKernelConfigInstalled(); bool platformMaemo(); bool useAdvancedTemperature(); bool useAutoRotate(); @@ -52,6 +53,7 @@ private: bool autoRotate; bool overclocking; bool powerKernel; + bool kernelConfigInstalled; QSettings settings; Ui::Settings *ui; };