Add support for saving maximum frequency on power kernel
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Tue, 9 Nov 2010 23:28:52 +0000 (00:28 +0100)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Tue, 9 Nov 2010 23:28:52 +0000 (00:28 +0100)
Call "kernel-config default" to save the current maximum frequency on
power kernels.

src/data/scripts/QCPUFreq.helper
src/mainwindow.cpp
src/mainwindow.h

index a867e8a..c911753 100755 (executable)
@@ -13,6 +13,10 @@ case "$1" in
         /sbin/modprobe bq27x00_battery
         exit 0
         ;;
+    "save")
+        /usr/sbin/kernel-config default
+        exit 0
+        ;;
        "set_maxfreq")
                #set scaling_max_freq
                echo $2 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
index 518c7e1..5749f65 100644 (file)
@@ -81,6 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
     connect(ui->sr_box, SIGNAL(clicked()), this, SLOT(setSmartReflex()));
     connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
+    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
     connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
     connect(settings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));
 
@@ -355,6 +356,11 @@ void MainWindow::init()
     } else {
         this->minFreq = min.toInt();
     }
+
+    //enable save option on power kernels
+    if (settings->usePowerKernel()) {
+        ui->actionSave->setEnabled(true);
+    }
 }
 
 
@@ -453,6 +459,20 @@ void MainWindow::orientationChanged()
 
 
 /**
+  * Saves the current maximim frequency as default (only on power kernel).
+  */
+void MainWindow::save()
+{
+    if (settings->usePowerKernel()) {
+        callHelper( "save", "null" );
+        #if defined(Q_WS_MAEMO_5)
+            QMaemo5InformationBox::information(this, tr( "The current frequency settings have been saved as default." ), QMaemo5InformationBox::DefaultTimeout);
+        #endif
+    }
+}
+
+
+/**
   * Checks the settings if the "bq27x00_battery" needs to be loaded.
   */
 void MainWindow::setAdvancedTemperature()
index 0d0bdcc..aae3b9d 100644 (file)
@@ -46,6 +46,7 @@ public slots:
     void applySettings();
     void orientationChanged();
     void refresh();
+    void save();
     void setAdvancedTemperature();
     void setAutoRotation();
     void setSmartReflex();