helpWindow.setWindowFlags( windowFlags() | Qt::Window );
//Settings widget
- settings.setWindowFlags(Qt::Popup);
+ //settings.setWindowFlags(Qt::Popup);
settings.hide();
//connect signals and slots
#include <QStringList>
#include "helpwindow.h"
-#include "settingswidget.h"
+#include "settings.h"
namespace Ui {
class MainWindow;
//! the QGraphicsScene will contain the large chip icon displayed in the UI
QGraphicsScene scene;
bool showSudoError;
- SettingsWidget settings;
+ Settings settings;
bool usePortrait();
};
--- /dev/null
+#include "settings.h"
+#include "ui_settings.h"
+
+#include <QMessageBox>
+#if defined(Q_WS_MAEMO_5)
+ #include <QMaemo5InformationBox>
+#endif
+
+
+Settings::Settings(QWidget *parent) :
+ QDialog(parent),
+ settings("qcpufreq"),
+ ui(new Ui::Settings)
+{
+ ui->setupUi(this);
+
+ //read values from config file
+ autoRotate = settings.value("main/autorotate", true).toBool();
+ overclocking = settings.value("main/overclocking", false).toBool();
+ advancedTemperature = settings.value("main/advanced_temperature", true).toBool();
+
+ //reset GUI
+ reset();
+
+ connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(save()));
+ connect(ui->checkBox_oc, SIGNAL(clicked()), this, SLOT(showOverclockingWarning()));
+}
+
+Settings::~Settings()
+{
+ delete ui;
+}
+
+/**
+ * Returns true if we are on a Maemo 5 OS.
+ */
+bool Settings::platformMaemo()
+{
+ #if defined(Q_WS_MAEMO_5)
+ return true;
+ #else
+ return false;
+ #endif
+}
+
+
+/**
+ * Resets the UI to the values stored by QSettings.
+ */
+void Settings::reset()
+{
+ ui->checkBox_rotate->setChecked(autoRotate);
+ ui->checkBox_oc->setChecked(overclocking);
+ ui->checkBox_temperature->setChecked(advancedTemperature);
+}
+
+
+/**
+ * Saves the changes and hides the SettingsWidget.
+ */
+void Settings::save()
+{
+ autoRotate = ui->checkBox_rotate->isChecked();
+ overclocking = ui->checkBox_oc->isChecked();
+ advancedTemperature = ui->checkBox_temperature->isChecked();
+
+ settings.setValue("main/autorotate", autoRotate);
+ settings.setValue("main/overclocking", overclocking);
+ settings.setValue("main/advanced_temperature", advancedTemperature);
+
+ //save settings to file
+ settings.sync();
+
+ hide();
+}
+
+
+/**
+ * Displays a warning when overclocking is being enabled.
+ */
+void Settings::showOverclockingWarning()
+{
+
+#if defined(Q_WS_MAEMO_5)
+ QMaemo5InformationBox::information(this, tr( "Please note that overclocking voids your warranty and may break your device! Be careful!"), 0);
+#else
+ QMessageBox::warning(this, tr("Warning"), tr("Please note that overclocking voids your warranty and may break your device! Be careful!"));
+#endif
+
+}
--- /dev/null
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+#include <QDialog>
+#include <QSettings>
+
+namespace Ui {
+ class Settings;
+}
+
+class Settings : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit Settings(QWidget *parent = 0);
+ ~Settings();
+ bool platformMaemo();
+
+public slots:
+ void reset();
+ void save();
+ void showOverclockingWarning();
+
+private:
+ bool advancedTemperature;
+ bool autoRotate;
+ bool overclocking;
+ QSettings settings;
+ Ui::Settings *ui;
+};
+
+#endif // SETTINGS_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Settings</class>
+ <widget class="QDialog" name="Settings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>308</width>
+ <height>134</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <property name="locale">
+ <locale language="English" country="UnitedStates"/>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="checkBox_oc">
+ <property name="text">
+ <string>Enable Overclocking</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_rotate">
+ <property name="text">
+ <string>Enable Auto-rotate</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_temperature">
+ <property name="text">
+ <string>Display more accurate temperature</string>
+ </property>
+ </widget>
+ </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>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>Settings</receiver>
+ <slot>hide()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>153</x>
+ <y>107</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>153</x>
+ <y>66</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
+++ /dev/null
-/*
- * QCPUFreq - a simple cpufreq GUI
- * Copyright (C) 2010 Daniel Klaffenbach <danielklaffenbach@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "settingswidget.h"
-#include "ui_settingswidget.h"
-
-
-SettingsWidget::SettingsWidget(QWidget *parent) :
- QWidget(parent),
- settings("qcpufreq"),
- ui(new Ui::SettingsWidget)
-{
- ui->setupUi(this);
-
- //read values from config file
- autoRotate = settings.value("main/autorotate", true).toBool();
- overclocking = settings.value("main/overclocking", false).toBool();
- advancedTemperature = settings.value("main/advanced_temperature", true).toBool();
-
- //reset GUI
- reset();
-
- connect(ui->btn_save, SIGNAL(clicked()), this, SLOT(save()));
-}
-
-SettingsWidget::~SettingsWidget()
-{
- delete ui;
-}
-
-
-/**
- * Resets the UI to the values stored by QSettings.
- */
-void SettingsWidget::reset()
-{
- ui->checkBox_rotate->setChecked(autoRotate);
- ui->checkBox_oc->setChecked(overclocking);
- ui->checkBox_temperature->setChecked(advancedTemperature);
-}
-
-
-/**
- * Saves the changes and hides the SettingsWidget.
- */
-void SettingsWidget::save()
-{
- autoRotate = ui->checkBox_rotate->isChecked();
- overclocking = ui->checkBox_oc->isChecked();
- advancedTemperature = ui->checkBox_temperature->isChecked();
-
- settings.setValue("main/autorotate", autoRotate);
- settings.setValue("main/overclocking", overclocking);
- settings.setValue("main/advanced_temperature", advancedTemperature);
-
- //save settings to file
- settings.sync();
-
- hide();
-}
+++ /dev/null
-/*
- * QCPUFreq - a simple cpufreq GUI
- * Copyright (C) 2010 Daniel Klaffenbach <danielklaffenbach@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef SETTINGSWIDGET_H
-#define SETTINGSWIDGET_H
-
-#include <QWidget>
-#include <QSettings>
-
-namespace Ui {
- class SettingsWidget;
-}
-
-class SettingsWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit SettingsWidget(QWidget *parent = 0);
- ~SettingsWidget();
-
-public slots:
- void reset();
- void save();
- void showOverclockingWarning();
-
-private:
- bool advancedTemperature;
- bool autoRotate;
- bool overclocking;
- QSettings settings;
- Ui::SettingsWidget *ui;
-};
-
-#endif // SETTINGSWIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SettingsWidget</class>
- <widget class="QWidget" name="SettingsWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>355</width>
- <height>130</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <property name="locale">
- <locale language="English" country="UnitedStates"/>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QCheckBox" name="checkBox_oc">
- <property name="text">
- <string>Enable Overclocking</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="checkBox_rotate">
- <property name="text">
- <string>Enable Auto-rotate</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="checkBox_temperature">
- <property name="text">
- <string>Display more accurate temperature</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QPushButton" name="btn_save">
- <property name="text">
- <string>Save</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="btn_cancel">
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>btn_cancel</sender>
- <signal>clicked()</signal>
- <receiver>SettingsWidget</receiver>
- <slot>close()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>304</x>
- <y>106</y>
- </hint>
- <hint type="destinationlabel">
- <x>177</x>
- <y>64</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
SOURCES += main.cpp\
mainwindow.cpp \
helpwindow.cpp \
- settingswidget.cpp
+ settings.cpp
HEADERS += mainwindow.h \
helpwindow.h \
- settingswidget.h
+ settings.h
FORMS += mainwindow.ui \
helpwindow.ui \
- settingswidget.ui
+ settings.ui
TRANSLATIONS = de.ts zh.ts