Added new (dummy) SettingsWidget
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Sun, 31 Oct 2010 13:35:29 +0000 (14:35 +0100)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Sun, 31 Oct 2010 13:35:29 +0000 (14:35 +0100)
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
src/mainwindow.h
src/mainwindow.ui
src/settingswidget.cpp [new file with mode: 0644]
src/settingswidget.h [new file with mode: 0644]
src/settingswidget.ui [new file with mode: 0644]
src/src.pro

index 31d38d4..6fc41dc 100644 (file)
@@ -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()
index ba8d386..dd2d172 100644 (file)
@@ -26,6 +26,7 @@
 #include <QStringList>
 
 #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();
 };
 
index ad98fb0..0ddb1e7 100644 (file)
      <x>0</x>
      <y>0</y>
      <width>469</width>
-     <height>21</height>
+     <height>23</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
     <addaction name="actionOverclocking"/>
     <addaction name="actionHelp"/>
     <addaction name="actionAbout"/>
+    <addaction name="actionSettings"/>
    </widget>
    <addaction name="menuFile"/>
   </widget>
     <string>Enable overclocking</string>
    </property>
   </action>
+  <action name="actionSettings">
+   <property name="text">
+    <string>Settings</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources/>
diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp
new file mode 100644 (file)
index 0000000..f5e8299
--- /dev/null
@@ -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 (file)
index 0000000..3b26355
--- /dev/null
@@ -0,0 +1,27 @@
+#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();
+
+private:
+    Ui::SettingsWidget *ui;
+    QSettings *settings;
+};
+
+#endif // SETTINGSWIDGET_H
diff --git a/src/settingswidget.ui b/src/settingswidget.ui
new file mode 100644 (file)
index 0000000..afcd723
--- /dev/null
@@ -0,0 +1,97 @@
+<?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-rotation</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>
index c07d249..42eb06b 100644 (file)
@@ -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