From 8d544a68320b5ca6fcdfa5f1e548e4a3b1e10310 Mon Sep 17 00:00:00 2001 From: Daniel Klaffenbach Date: Sun, 31 Oct 2010 14:35:29 +0100 Subject: [PATCH 1/1] Added new (dummy) SettingsWidget Added a new widget which will be used to display all of the application's settings. Right now this is just a dummy widget. --- src/mainwindow.cpp | 15 ++++++++ src/mainwindow.h | 3 ++ src/mainwindow.ui | 8 +++- src/settingswidget.cpp | 24 ++++++++++++ src/settingswidget.h | 27 ++++++++++++++ src/settingswidget.ui | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ src/src.pro | 9 +++-- 7 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 src/settingswidget.cpp create mode 100644 src/settingswidget.h create mode 100644 src/settingswidget.ui diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 31d38d4..6fc41dc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -43,6 +43,8 @@ MainWindow::MainWindow(QWidget *parent) : refreshTimer( this ), //create a QGraphicsScene for the little chip icon scene( this ), + //the settings widget + settings(this), //show errors about the sudo setup only once showSudoError( true ) { @@ -71,6 +73,8 @@ MainWindow::MainWindow(QWidget *parent) : #endif helpWindow.setWindowFlags( windowFlags() | Qt::Window ); + settings.hide(); + //connect signals and slots connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(showHelp())); connect( ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()) ); @@ -79,6 +83,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->sr_box, SIGNAL(clicked()), this, SLOT(setSmartReflex())); connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); connect(ui->actionOverclocking, SIGNAL(toggled(bool)), this, SLOT(setOverclocking())); + connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettings())); //disable overclocking button on vanilla kernels @@ -501,6 +506,16 @@ void MainWindow::showHelp() /** + * SLOT: displays the settings widget + */ +void MainWindow::showSettings() +{ + settings.setWindowFlags(Qt::Popup); + settings.show(); +} + + +/** * Returns true when the device is in portrait mode */ bool MainWindow::usePortrait() diff --git a/src/mainwindow.h b/src/mainwindow.h index ba8d386..dd2d172 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -26,6 +26,7 @@ #include #include "helpwindow.h" +#include "settingswidget.h" namespace Ui { class MainWindow; @@ -48,6 +49,7 @@ public slots: void setOverclocking(); void setSmartReflex(); void showHelp(); + void showSettings(); private: @@ -81,6 +83,7 @@ private: //! the QGraphicsScene will contain the large chip icon displayed in the UI QGraphicsScene scene; bool showSudoError; + SettingsWidget settings; bool usePortrait(); }; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index ad98fb0..0ddb1e7 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -356,7 +356,7 @@ 0 0 469 - 21 + 23 @@ -366,6 +366,7 @@ + @@ -387,6 +388,11 @@ Enable overclocking + + + Settings + + diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp new file mode 100644 index 0000000..f5e8299 --- /dev/null +++ b/src/settingswidget.cpp @@ -0,0 +1,24 @@ +#include "settingswidget.h" +#include "ui_settingswidget.h" + + + + +SettingsWidget::SettingsWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::SettingsWidget) +{ + ui->setupUi(this); + settings = new QSettings("qcpufreq"); +} + +SettingsWidget::~SettingsWidget() +{ + delete ui; + delete settings; +} + + +void SettingsWidget::reset() +{ +} diff --git a/src/settingswidget.h b/src/settingswidget.h new file mode 100644 index 0000000..3b26355 --- /dev/null +++ b/src/settingswidget.h @@ -0,0 +1,27 @@ +#ifndef SETTINGSWIDGET_H +#define SETTINGSWIDGET_H + +#include +#include + +namespace Ui { + class SettingsWidget; +} + +class SettingsWidget : public QWidget +{ + Q_OBJECT + +public: + explicit SettingsWidget(QWidget *parent = 0); + ~SettingsWidget(); + +public slots: + void reset(); + +private: + Ui::SettingsWidget *ui; + QSettings *settings; +}; + +#endif // SETTINGSWIDGET_H diff --git a/src/settingswidget.ui b/src/settingswidget.ui new file mode 100644 index 0000000..afcd723 --- /dev/null +++ b/src/settingswidget.ui @@ -0,0 +1,97 @@ + + + SettingsWidget + + + + 0 + 0 + 355 + 130 + + + + Form + + + + + + + + + + + Enable Overclocking + + + + + + + Enable Auto-rotation + + + + + + + Display more accurate temperature + + + + + + + + + + + Save + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Cancel + + + + + + + + + + + btn_cancel + clicked() + SettingsWidget + close() + + + 304 + 106 + + + 177 + 64 + + + + + diff --git a/src/src.pro b/src/src.pro index c07d249..42eb06b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -12,13 +12,16 @@ TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ - helpwindow.cpp + helpwindow.cpp \ + settingswidget.cpp HEADERS += mainwindow.h \ - helpwindow.h + helpwindow.h \ + settingswidget.h FORMS += mainwindow.ui \ - helpwindow.ui + helpwindow.ui \ + settingswidget.ui TRANSLATIONS = de.ts zh.ts -- 1.7.9.5