From f6b9f450ccc7a7deae6cf02520cdbdefe98dc522 Mon Sep 17 00:00:00 2001 From: Daniel Klaffenbach Date: Tue, 21 Dec 2010 11:44:19 +0100 Subject: [PATCH] Add a dialog for loading a kernel-config preset --- src/loadpreset.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/loadpreset.h | 46 ++++++++++++++++++++++++++++++++++++ src/loadpreset.ui | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/src.pro | 9 ++++--- 4 files changed, 183 insertions(+), 3 deletions(-) create mode 100644 src/loadpreset.cpp create mode 100644 src/loadpreset.h create mode 100644 src/loadpreset.ui diff --git a/src/loadpreset.cpp b/src/loadpreset.cpp new file mode 100644 index 0000000..2f999aa --- /dev/null +++ b/src/loadpreset.cpp @@ -0,0 +1,65 @@ +/* + * QCPUFreq - a simple cpufreq GUI + * Copyright (C) 2010 Daniel Klaffenbach + * + * 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 . + */ + +#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 index 0000000..da781ce --- /dev/null +++ b/src/loadpreset.h @@ -0,0 +1,46 @@ +/* + * QCPUFreq - a simple cpufreq GUI + * Copyright (C) 2010 Daniel Klaffenbach + * + * 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 . + */ + +#ifndef LOADPRESET_H +#define LOADPRESET_H + +#include + +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 index 0000000..3ef3e4a --- /dev/null +++ b/src/loadpreset.ui @@ -0,0 +1,66 @@ + + + LoadPreset + + + + 0 + 0 + 451 + 88 + + + + Load preset + + + + + + + + + Default + + + + + + + Ideal + + + + + + + LV + + + + + + + ULV + + + + + + + XLV + + + + + + + Custom + + + + + + + + diff --git a/src/src.pro b/src/src.pro index 46d77b3..a441e65 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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 -- 1.7.9.5