Add a dialog for loading a kernel-config preset
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Tue, 21 Dec 2010 10:44:19 +0000 (11:44 +0100)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Tue, 21 Dec 2010 10:44:19 +0000 (11:44 +0100)
src/loadpreset.cpp [new file with mode: 0644]
src/loadpreset.h [new file with mode: 0644]
src/loadpreset.ui [new file with mode: 0644]
src/src.pro

diff --git a/src/loadpreset.cpp b/src/loadpreset.cpp
new file mode 100644 (file)
index 0000000..2f999aa
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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 "loadpreset.h"
+#include "ui_loadpreset.h"
+
+LoadPreset::LoadPreset(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::LoadPreset)
+{
+    ui->setupUi(this);
+
+    connect(ui->loadDefault, SIGNAL(toggled()), this, SLOT(buttonPressed("loadDefault")));
+    connect(ui->loadIdeal, SIGNAL(toggled()), this, SLOT(buttonPressed("loadIdeal")));
+    connect(ui->loadLV, SIGNAL(toggled()), this, SLOT(buttonPressed("loadLV")));
+    connect(ui->loadULV, SIGNAL(toggled()), this, SLOT(buttonPressed("loadULV")));
+    connect(ui->loadXLV, SIGNAL(toggled()), this, SLOT(buttonPressed("loadXLV")));
+    connect(ui->loadCustom, SIGNAL(toggled()), this, SLOT(buttonPressed("loadCustom")));
+
+}
+
+LoadPreset::~LoadPreset()
+{
+    delete ui;
+}
+
+
+/**
+  * This slot is called when a button was pressed. It takes care of emmiting
+  * the "load" signal. The load signal will contain the actual name of the
+  * preset which needs to be loaded.
+  *
+  * @emits: load(QString)
+  */
+void LoadPreset::buttonPressed(QString buttonName)
+{
+    if (buttonName == "loadDefault") {
+        emit load("default");
+    } else if (buttonName == "loadIdeal") {
+        emit load("ideal");
+    } else if (buttonName == "loadLV") {
+        emit load("lv");
+    } else if (buttonName == "loadULV") {
+        emit load("ulv");
+    } else if (buttonName == "loadXLV")
+        emit load("xlv");
+    } else if (buttonName == "loadCustom") {
+        emit load("custom");
+    }
+}
diff --git a/src/loadpreset.h b/src/loadpreset.h
new file mode 100644 (file)
index 0000000..da781ce
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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 LOADPRESET_H
+#define LOADPRESET_H
+
+#include <QDialog>
+
+namespace Ui {
+    class LoadPreset;
+}
+
+class LoadPreset : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit LoadPreset(QWidget *parent = 0);
+    ~LoadPreset();
+
+signals:
+    void load(QString presetName);
+
+public slots:
+    void buttonPressed(QString buttonName);
+
+private:
+    Ui::LoadPreset *ui;
+};
+
+#endif // LOADPRESET_H
diff --git a/src/loadpreset.ui b/src/loadpreset.ui
new file mode 100644 (file)
index 0000000..3ef3e4a
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LoadPreset</class>
+ <widget class="QDialog" name="LoadPreset">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>451</width>
+    <height>88</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Load preset</string>
+  </property>
+  <property name="locale">
+   <locale language="English" country="UnitedStates"/>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QPushButton" name="loadDefault">
+     <property name="text">
+      <string>Default</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QPushButton" name="loadIdeal">
+     <property name="text">
+      <string>Ideal</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QPushButton" name="loadLV">
+     <property name="text">
+      <string>LV</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QPushButton" name="loadULV">
+     <property name="text">
+      <string>ULV</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QPushButton" name="loadXLV">
+     <property name="text">
+      <string>XLV</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QPushButton" name="loadCustom">
+     <property name="text">
+      <string>Custom</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 46d77b3..a441e65 100644 (file)
@@ -13,15 +13,18 @@ TEMPLATE = app
 SOURCES += main.cpp\
         mainwindow.cpp \
     helpwindow.cpp \
-    settings.cpp
+    settings.cpp \
+    loadpreset.cpp
 
 HEADERS  += mainwindow.h \
     helpwindow.h \
-    settings.h
+    settings.h \
+    loadpreset.h
 
 FORMS    += mainwindow.ui \
     helpwindow.ui \
-    settings.ui
+    settings.ui \
+    loadpreset.ui
 
 TRANSLATIONS = de.ts zh.ts