Ask for confirmation before applying new maximum frequency.
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Mon, 27 Dec 2010 10:45:47 +0000 (11:45 +0100)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Mon, 27 Dec 2010 10:45:47 +0000 (11:45 +0100)
This adds an option in the settings widget to enable a confirmation
dialog before actually applying a new maximum frequency.
This should prevent accidental changes.

src/mainwindow.cpp
src/settings.cpp
src/settings.h
src/settings.ui
src/src.pro

index 2d43625..e71837f 100644 (file)
@@ -146,9 +146,24 @@ void MainWindow::adjustFreq()
         max = "599000";
     }
 
-    callHelper( "set_maxfreq", max );
+    if (settings->useConfirmation()) {
+        QMessageBox box;
+        box.setStandardButtons(QMessageBox::Apply | QMessageBox::Cancel);
+        box.setDefaultButton(QMessageBox::Apply);
+        box.setIcon(QMessageBox::Question);
+        box.setText(tr("The frequency changed."));
+        box.setInformativeText("Do you want to use ? as new default frequency?");
+        int ret = box.exec();
+
+        if (ret != QMessageBox::Apply) {
+            refresh();
+            return;
+        }
+    }
 
+    callHelper( "set_maxfreq", max );
     refresh();
+
 }
 
 
index eaa72f1..a4b7b6f 100644 (file)
@@ -38,6 +38,7 @@ Settings::Settings(QWidget *parent) :
 
     //read values from config file
     autoRotate = settings.value("main/autorotate", true).toBool();
+    confirmApply = settings.value("main/confirm_apply", true).toBool();
     overclocking = settings.value("main/overclocking", false).toBool();
     advancedTemperature = settings.value("main/advanced_temperature", false).toBool();
 
@@ -122,6 +123,7 @@ bool Settings::platformMaemo()
 void Settings::reset()
 {
     ui->checkBox_rotate->setChecked(autoRotate);
+    ui->checkBox_confirmapply->setChecked(confirmApply);
     ui->checkBox_oc->setChecked(overclocking);
     ui->checkBox_temperature->setChecked(advancedTemperature);
 }
@@ -135,10 +137,12 @@ void Settings::reset()
 void Settings::save()
 {
     autoRotate = ui->checkBox_rotate->isChecked();
+    confirmApply = ui->checkBox_confirmapply->isChecked();
     overclocking = ui->checkBox_oc->isChecked();
     advancedTemperature = ui->checkBox_temperature->isChecked();
 
     settings.setValue("main/autorotate", autoRotate);
+    settings.setValue("main/confirm_apply", confirmApply);
     settings.setValue("main/overclocking", overclocking);
     settings.setValue("main/advanced_temperature", advancedTemperature);
 
@@ -177,6 +181,16 @@ bool Settings::useAdvancedTemperature()
 
 
 /**
+  * Do we need to display a confirmation dialog before applying new
+  * frequencies?
+  */
+bool Settings::useConfirmation()
+{
+    return confirmApply;
+}
+
+
+/**
   * Returns true if auto-Rotate is enabled.
   */
 bool Settings::useAutoRotate()
index 87c8463..c6b08e9 100644 (file)
@@ -37,6 +37,7 @@ public:
     bool platformMaemo();
     bool useAdvancedTemperature();
     bool useAutoRotate();
+    bool useConfirmation();
     bool useOverclocking();
     bool usePowerKernel();
 
@@ -51,6 +52,7 @@ signals:
 private:
     bool advancedTemperature;
     bool autoRotate;
+    bool confirmApply;
     bool overclocking;
     bool powerKernel;
     bool kernelConfigInstalled;
index 45464d1..0e1d5ee 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>308</width>
-    <height>134</height>
+    <width>364</width>
+    <height>183</height>
    </rect>
   </property>
   <property name="windowTitle">
    <item row="0" column="0">
     <layout class="QVBoxLayout" name="verticalLayout">
      <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Please have a look at the QCPUFreq help for an explanation of these settings!</string>
+       </property>
+       <property name="wordWrap">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
       <widget class="QCheckBox" name="checkBox_rotate">
        <property name="text">
         <string>Enable auto-rotation</string>
       </widget>
      </item>
      <item>
+      <widget class="QCheckBox" name="checkBox_confirmapply">
+       <property name="text">
+        <string>Confirm frequency before applying</string>
+       </property>
+      </widget>
+     </item>
+     <item>
       <widget class="QCheckBox" name="checkBox_oc">
        <property name="text">
         <string>Enable overclocking</string>
@@ -42,9 +59,6 @@
      </item>
      <item>
       <widget class="QDialogButtonBox" name="buttonBox">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
        <property name="standardButtons">
         <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
        </property>
index a441e65..43b41c2 100644 (file)
@@ -4,6 +4,7 @@
 #
 #-------------------------------------------------
 
+QT       -= gui dbus xml
 QT       += core gui maemo5
 
 TARGET = QCPUFreq
@@ -28,8 +29,8 @@ FORMS    += mainwindow.ui \
 
 TRANSLATIONS = de.ts zh.ts
 
-CONFIG += mobility
-MOBILITY = 
+#CONFIG += mobility
+#MOBILITY = 
 
 symbian {
     TARGET.UID3 = 0xeb3802d4