loadPresetDialog = new LoadPreset;
loadPresetDialog->hide();
- init();
+ //enable save and load option on power kernels
+ if (settings->usePowerKernel() && settings->isKernelConfigInstalled()) {
+ ui->actionSave->setEnabled(true);
+ //loading presets may cause overclocking - only enable it if overclokcing is enabled
+ if (settings->useOverclocking()) {
+ ui->actionLoad->setEnabled(true);
+ }
+ }
+
+ //display the correct minimum frequency
+ calculateMinFreq();
//applies the settings from the settings dialog
applySettings();
/**
+ * Calculates the minimum frequency according to scaling_min_freq and avoid_frequencies.
+ *
+ * Since this is a somewhat complex calculation it sould only be performed when it is
+ * really necessary (on startup, after loading presets, etc.).
+ */
+void MainWindow::calculateMinFreq()
+{
+ this->minFreq = 0;
+ QString freqs = readSysFile( "devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies" );
+ QStringList freqList = freqs.split( " " );
+ //change the order of the QStringList - last element becomes first
+ for (int i=freqList.size() - 1; i>=0; --i) {
+ if (freqList.at(i) != "")
+ this->scalingFrequencies << freqList.at(i);
+ }
+ this->scalingSteps = (this->scalingFrequencies.size());
+
+ //set minFreq and check avoid_frequencies
+ QString min = readSysFile( "devices/system/cpu/cpu0/cpufreq/scaling_min_freq" );
+ //check if avoid file exists (only on power kernel)
+ QFile file( "/sys/devices/system/cpu/cpu0/cpufreq/ondemand/avoid_frequencies" );
+ if (file.exists()) {
+ QString avoid = readSysFile( "devices/system/cpu/cpu0/cpufreq/ondemand/avoid_frequencies" );
+ QStringList avoidList = avoid.split( " " );
+
+ //check if min is in avoid_frequencies
+ for (int i = getScalingStep( min.toInt() ); i <= this->scalingSteps; ++i) {
+ min.setNum( getScalingFreq(i) );
+ if (!avoidList.contains(min)) {
+ this->minFreq = min.toInt();
+ break;
+ }
+ }
+ } else {
+ this->minFreq = min.toInt();
+ }
+ file.close();
+}
+
+
+/**
* Calls the QCPUFreq helper script with "sudo action param"
*
* @param action : the action of the helper script
/**
- * Initializes internal variables, such as:
- * - scalingSteps
- * - scalingFrequencies
- * - minFreq
- */
-void MainWindow::init()
-{
- this->minFreq = 0;
- QString freqs = readSysFile( "devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies" );
- QStringList freqList = freqs.split( " " );
- //change the order of the QStringList - last element becomes first
- for (int i=freqList.size() - 1; i>=0; --i) {
- if (freqList.at(i) != "")
- this->scalingFrequencies << freqList.at(i);
- }
- this->scalingSteps = (this->scalingFrequencies.size());
-
- //set minFreq and check avoid_frequencies
- QString min = readSysFile( "devices/system/cpu/cpu0/cpufreq/scaling_min_freq" );
- //check if avoid file exists (only on power kernel)
- QFile file( "/sys/devices/system/cpu/cpu0/cpufreq/ondemand/avoid_frequencies" );
- if (file.exists()) {
- QString avoid = readSysFile( "devices/system/cpu/cpu0/cpufreq/ondemand/avoid_frequencies" );
- QStringList avoidList = avoid.split( " " );
-
- //check if min is in avoid_frequencies
- for (int i = getScalingStep( min.toInt() ); i <= this->scalingSteps; ++i) {
- min.setNum( getScalingFreq(i) );
- if (!avoidList.contains(min)) {
- this->minFreq = min.toInt();
- break;
- }
- }
- } else {
- this->minFreq = min.toInt();
- }
- file.close();
-
- //enable save and load option on power kernels
- if (settings->usePowerKernel() && settings->isKernelConfigInstalled()) {
- ui->actionSave->setEnabled(true);
- //loading presets may cause overclocking - only enable it if overclokcing is enabled
- if (settings->useOverclocking()) {
- ui->actionLoad->setEnabled(true);
- }
- }
-}
-
-
-/**
* Loads a voltage preset by calling kernel-config.
*
* Available presets are: