Connect signals and slots in LoadPreset and MainWindow
[qcpufreq] / src / mainwindow.cpp
index fd09327..737420d 100644 (file)
@@ -54,6 +54,10 @@ MainWindow::MainWindow(QWidget *parent) :
     settings = new Settings;
     settings->hide();
 
+    //load preset dialog
+    loadPresetDialog = new LoadPreset;
+    loadPresetDialog->hide();
+
     init();
 
     //applies the settings from the settings dialog
@@ -82,14 +86,16 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(ui->sr_box, SIGNAL(clicked()), this, SLOT(setSmartReflex()));
     connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
     connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
-    connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(loadPreset()));
+    connect(ui->actionLoad, SIGNAL(triggered()), loadPresetDialog, SLOT(show()));
     connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
     connect(settings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));
+    connect(loadPresetDialog, SIGNAL(load(QString)), this, SLOT(loadPreset(QString)));
 
 }
 
 MainWindow::~MainWindow()
 {
+    delete loadPresetDialog;
     delete settings;
     delete ui;
 }
@@ -383,9 +389,12 @@ void MainWindow::init()
   *  - starving
   *  - custom -> any preset named "custom"
   */
-void MainWindow::loadPreset()
+void MainWindow::loadPreset(QString presetName)
 {
-    return;
+    callHelper("loadpreset", presetName);
+    #if defined(Q_WS_MAEMO_5)
+        QMaemo5InformationBox::information(this, tr( "The preset was loaded." ), QMaemo5InformationBox::DefaultTimeout);
+    #endif
 }
 
 
@@ -515,6 +524,7 @@ void MainWindow::setAutoRotation()
 {
 #if defined(Q_WS_MAEMO_5)
     setAttribute(Qt::WA_Maemo5AutoOrientation, settings->useAutoRotate());
+    loadPresetDialog->setAttribute(Qt::WA_Maemo5AutoOrientation, settings->useAutoRotate());
     settings->setAttribute(Qt::WA_Maemo5AutoOrientation, settings->useAutoRotate());
 #endif
 }