Fix 600MHz issue on power kernels
[qcpufreq] / src / mainwindow.cpp
index 318f471..518c7e1 100644 (file)
@@ -55,10 +55,9 @@ MainWindow::MainWindow(QWidget *parent) :
     settings->hide();
 
     init();
-    refresh();
 
-    // setup auto rotation
-    setAutoRotation();
+    //applies the settings from the settings dialog
+    applySettings();
 
     //initialize orientation
     orientationChanged();
@@ -83,7 +82,7 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(ui->sr_box, SIGNAL(clicked()), this, SLOT(setSmartReflex()));
     connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
     connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
-    connect(settings, SIGNAL(settingsChanged()), this, SLOT(setAutoRotation()));
+    connect(settings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));
 
 }
 
@@ -133,6 +132,12 @@ void MainWindow::adjustFreq()
     }
     #endif
 
+    //check for 599MHz <-> 600MHz problem on power kernels
+    if (max == "600000" && settings->usePowerKernel()) {
+        //we really need to set the maximum to 599MHz
+        max = "599000";
+    }
+
     callHelper( "set_maxfreq", max );
 
     refresh();
@@ -140,6 +145,19 @@ void MainWindow::adjustFreq()
 
 
 /**
+  * SLOT: applies the settings from the Settings dialog.
+  */
+void MainWindow::applySettings()
+{
+    setAutoRotation();
+    setAdvancedTemperature();
+
+    //refresh the GUI after applying the settings
+    refresh();
+}
+
+
+/**
   * Calls the QCPUFreq helper script with "sudo action param"
   *
   * @param  action : the action of the helper script
@@ -435,6 +453,17 @@ void MainWindow::orientationChanged()
 
 
 /**
+  * Checks the settings if the "bq27x00_battery" needs to be loaded.
+  */
+void MainWindow::setAdvancedTemperature()
+{
+    if (settings->usePowerKernel() && settings->useAdvancedTemperature()) {
+       callHelper( "load_bq27", "null" );
+    }
+}
+
+
+/**
   * Enables or disables the auto-rotation feature of Maemo5 devices.
   */
 void MainWindow::setAutoRotation()