2 #include "ui_settings.h"
8 #if defined(Q_WS_MAEMO_5)
9 #include <QMaemo5InformationBox>
12 #define DEFAULT_FREQUENCY 600000
14 Settings::Settings(QWidget *parent) :
21 //read values from config file
22 autoRotate = settings.value("main/autorotate", true).toBool();
23 overclocking = settings.value("main/overclocking", false).toBool();
24 advancedTemperature = settings.value("main/advanced_temperature", false).toBool();
26 /* The next few lines of code check if QCPUFreq is running on a power kernel.
27 * Basically we get the maximum available frequency - if it is greater than
28 * DEFAULT_FREQUENCY we can be sure that the current kernel is a power kernel.
30 QFile file( "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies" );
33 if ( !file.exists() || !file.open( QIODevice::ReadOnly ) ) {
34 QMessageBox::critical(this, tr("QCPUFreq"), tr("Could not get information from /sys!"));
38 QTextStream in( &file );
39 QStringList freqList = in.readLine().split(" ");
40 int maxFreq = freqList.at(0).toInt();
45 if (maxFreq > DEFAULT_FREQUENCY) {
52 //on non-power-kernels we can disable the overclocking and temperature options
54 ui->checkBox_oc->setDisabled(true);
55 ui->checkBox_temperature->setDisabled(true);
61 connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(save()));
62 connect(ui->checkBox_oc, SIGNAL(clicked()), this, SLOT(showOverclockingWarning()));
72 * Returns true if we are on a Maemo 5 OS.
74 bool Settings::platformMaemo()
76 #if defined(Q_WS_MAEMO_5)
85 * Resets the UI to the values stored by QSettings.
87 void Settings::reset()
89 ui->checkBox_rotate->setChecked(autoRotate);
90 ui->checkBox_oc->setChecked(overclocking);
91 ui->checkBox_temperature->setChecked(advancedTemperature);
96 * Saves the changes and hides the SettingsWidget.
100 autoRotate = ui->checkBox_rotate->isChecked();
101 overclocking = ui->checkBox_oc->isChecked();
102 advancedTemperature = ui->checkBox_temperature->isChecked();
104 settings.setValue("main/autorotate", autoRotate);
105 settings.setValue("main/overclocking", overclocking);
106 settings.setValue("main/advanced_temperature", advancedTemperature);
108 //save settings to file
116 * Displays a warning when overclocking is being enabled.
118 void Settings::showOverclockingWarning()
120 if (ui->checkBox_oc->isChecked()) {
121 #if defined(Q_WS_MAEMO_5)
122 QMaemo5InformationBox::information(this, tr( "Please note that overclocking voids your warranty and may break your device! Be careful!"), 0);
124 QMessageBox::warning(this, tr("Warning"), tr("Please note that overclocking voids your warranty and may break your device! Be careful!"));
131 * Returns true if the user wants to display a more
132 * accurate temperature.
134 bool Settings::useAdvancedTemperature()
136 return advancedTemperature;
141 * Returns true if auto-Rotate is enabled.
143 bool Settings::useAutoRotate()
150 * Returns true if the user enabled overclocking.
152 bool Settings::useOverclocking()
159 * Returns true if QCPUFreq is running on a power kernel.
161 bool Settings::usePowerKernel()