From 8f081c22212f2388ac42818b977e663af382732e Mon Sep 17 00:00:00 2001 From: Daniel Klaffenbach Date: Tue, 21 Dec 2010 13:15:30 +0100 Subject: [PATCH] Connect signals and slots in LoadPreset and MainWindow --- src/loadpreset.cpp | 101 +++++++++++++++++++++++++++++++++++++++------------- src/loadpreset.h | 7 +++- src/mainwindow.cpp | 16 +++++++-- src/mainwindow.h | 5 ++- 4 files changed, 100 insertions(+), 29 deletions(-) diff --git a/src/loadpreset.cpp b/src/loadpreset.cpp index 2f999aa..0217c97 100644 --- a/src/loadpreset.cpp +++ b/src/loadpreset.cpp @@ -25,12 +25,12 @@ LoadPreset::LoadPreset(QWidget *parent) : { 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"))); + connect(ui->loadDefault, SIGNAL(clicked()), this, SLOT(buttonLoadDefaultPressed())); + connect(ui->loadIdeal, SIGNAL(clicked()), this, SLOT(buttonLoadIdealPressed())); + connect(ui->loadLV, SIGNAL(clicked()), this, SLOT(buttonLoadLvPressed())); + connect(ui->loadULV, SIGNAL(clicked()), this, SLOT(buttonLoadUlvPressed())); + connect(ui->loadXLV, SIGNAL(clicked()), this, SLOT(buttonLoadXlvPressed())); + connect(ui->loadCustom, SIGNAL(clicked()), this, SLOT(buttonLoadCustomPressed())); } @@ -41,25 +41,78 @@ LoadPreset::~LoadPreset() /** - * 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. + * This slot is called when the loadCustom button was pressed. + * It emits the "load" signal and hides the dialog. * - * @emits: load(QString) + * @emits: load("custom") */ -void LoadPreset::buttonPressed(QString buttonName) +void LoadPreset::buttonLoadCustomPressed() { - 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"); - } + emit load("custom"); + hide(); +} + + +/** + * This slot is called when the loadDefault button was pressed. + * It emits the "load" signal and hides the dialog. + * + * @emits: load("default") + */ +void LoadPreset::buttonLoadDefaultPressed() +{ + emit load("default"); + hide(); +} + + +/** + * This slot is called when the loadIdeal button was pressed. + * It emits the "load" signal and hides the dialog. + * + * @emits: load("ideal") + */ +void LoadPreset::buttonLoadIdealPressed() +{ + emit load("ideal"); + hide(); +} + + +/** + * This slot is called when the loadLV button was pressed. + * It emits the "load" signal and hides the dialog. + * + * @emits: load("lv") + */ +void LoadPreset::buttonLoadLvPressed() +{ + emit load("lv"); + hide(); +} + + +/** + * This slot is called when the loadULV button was pressed. + * It emits the "load" signal and hides the dialog. + * + * @emits: load("ulv") + */ +void LoadPreset::buttonLoadUlvPressed() +{ + emit load("ulv"); + hide(); +} + + +/** + * This slot is called when the loadXLV button was pressed. + * It emits the "load" signal and hides the dialog. + * + * @emits: load("xlv") + */ +void LoadPreset::buttonLoadXlvPressed() +{ + emit load("xlv"); + hide(); } diff --git a/src/loadpreset.h b/src/loadpreset.h index da781ce..e4a2e45 100644 --- a/src/loadpreset.h +++ b/src/loadpreset.h @@ -37,7 +37,12 @@ signals: void load(QString presetName); public slots: - void buttonPressed(QString buttonName); + void buttonLoadDefaultPressed(); + void buttonLoadIdealPressed(); + void buttonLoadLvPressed(); + void buttonLoadUlvPressed(); + void buttonLoadXlvPressed(); + void buttonLoadCustomPressed(); private: Ui::LoadPreset *ui; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fd09327..737420d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 } diff --git a/src/mainwindow.h b/src/mainwindow.h index 920f6a5..93c39c5 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -26,6 +26,7 @@ #include #include "helpwindow.h" +#include "loadpreset.h" #include "settings.h" namespace Ui { @@ -44,7 +45,7 @@ public slots: void about(); void adjustFreq(); void applySettings(); - void loadPreset(); + void loadPreset(QString presetName); void orientationChanged(); void refresh(); void save(); @@ -52,6 +53,7 @@ public slots: void setAutoRotation(); void setSmartReflex(); void showHelp(); + //void showLoadPresetDialog(); void showSettings(); @@ -72,6 +74,7 @@ private: HelpWindow helpWindow; //! Initializes the application void init(); + LoadPreset *loadPresetDialog; int minFreq; QString readSysFile( QString sys_file ); //! the timer for refreshing the UI -- 1.7.9.5