Implement settings as pointer
[qcpufreq] / src / mainwindow.cpp
index 3034c12..022d628 100644 (file)
@@ -32,6 +32,7 @@
 
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
+    ui(new Ui::MainWindow),
     //create helper process
     helperProcess( this ),
     //create a new, stackable help window
@@ -39,11 +40,7 @@ MainWindow::MainWindow(QWidget *parent) :
     //create UI refresh timer
     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 )
+    scene( this )
 {
     //this is a stacked window on Maemo 5
     #if defined(Q_WS_MAEMO_5)
@@ -71,7 +68,11 @@ MainWindow::MainWindow(QWidget *parent) :
     helpWindow.setWindowFlags( windowFlags() | Qt::Window );
 
     //Settings widget
-    settings.hide();
+    settings = new Settings;
+    settings->hide();
+
+    //show errors about the sudo setup only once
+    showSudoError = true;
 
     //connect signals and slots
     connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(showHelp()));
@@ -86,6 +87,7 @@ MainWindow::MainWindow(QWidget *parent) :
 
 MainWindow::~MainWindow()
 {
+    delete settings;
     delete ui;
 }
 
@@ -122,7 +124,7 @@ void MainWindow::adjustFreq()
 
     //check for overclocking
     #if defined(Q_WS_MAEMO_5)
-    if (!settings.useOverclocking() && newmax > 600000) {
+    if (!settings->useOverclocking() && newmax > 600000) {
         QMaemo5InformationBox::information(this, tr( "You need to enable overclocking in QCPUFreq's settings in order to set frequencies above 600MHz!"), 0);
         refresh();
         return;
@@ -436,7 +438,7 @@ void MainWindow::orientationChanged()
 void MainWindow::setAutoRotation()
 {
 #if defined(Q_WS_MAEMO_5)
-    setAttribute(Qt::WA_Maemo5AutoOrientation, settings.useAutoRotate());
+    setAttribute(Qt::WA_Maemo5AutoOrientation, settings->useAutoRotate());
 #endif
 }
 
@@ -475,8 +477,8 @@ void MainWindow::showHelp()
   */
 void MainWindow::showSettings()
 {
-    settings.reset();
-    settings.show();
+    settings->reset();
+    settings->show();
 }