Ask settings dialog about kernel-config
[qcpufreq] / src / settings.cpp
index a0b78f7..eaa72f1 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ * QCPUFreq - a simple cpufreq GUI
+ * Copyright (C) 2010 Daniel Klaffenbach <danielklaffenbach@gmail.com>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "settings.h"
 #include "ui_settings.h"
 
@@ -23,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 );
@@ -44,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;
         }
     }
 
@@ -69,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()
@@ -94,6 +129,8 @@ void Settings::reset()
 
 /**
   * Saves the changes and hides the SettingsWidget.
+  *
+  * @emits: settingsChanged()
   */
 void Settings::save()
 {
@@ -109,6 +146,8 @@ void Settings::save()
     settings.sync();
 
     hide();
+
+    emit settingsChanged();
 }