1 /**************************************************************************
4 Copyright (C) 2010 Heli Hyvättinen
6 This file is part of KitchenAlert.
8 Kitchen Alert is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **************************************************************************/
27 #include "selectsounddialog.h"
28 #include "ui_selectsounddialog.h"
29 #include <QFileDialog>
34 SelectSoundDialog::SelectSoundDialog(QWidget *parent) :
36 ui(new Ui::SelectSoundDialog)
39 connect(ui->browseButton,SIGNAL(clicked()),this,SLOT(browse()));
41 QSettings settings("KitchenAlert","KitchenAlert");
42 QString filename = settings.value("soundfile").toString();
43 ui->lineEdit->setText(filename);
45 bool useDefaultSoundFile = settings.value("UseDefaultSound",true).toBool();
46 if (useDefaultSoundFile == true)
48 ui->DefaultSoundRadioButton->setChecked(true);
49 ui->browseButton->setDisabled(true);
50 ui->lineEdit->setDisabled(true);
52 else ui->CustomSoundRadioButton->setChecked(true);
53 qDebug() << "UseDefaultSoundfile is " << useDefaultSoundFile;
55 connect(ui->testButton,SIGNAL(clicked()),this,SLOT(testSound()));
56 pSound_ = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource(ui->lineEdit->displayText()));
61 SelectSoundDialog::~SelectSoundDialog()
66 void SelectSoundDialog::browse()
68 QString filename = QFileDialog::getOpenFileName(this, tr("Choose a sound file"),"/home/user/"); //Filters: to use or not...? //MAEMO specific dir here...
69 if (!filename.isEmpty()) //Empty string returned by the dialog if user pressed cancel...
71 ui->lineEdit->setText(filename);
75 QString SelectSoundDialog::getSoundFileName()
77 if (ui->CustomSoundRadioButton->isChecked() == true)
78 return ui->lineEdit->displayText();
79 else return QString();
82 bool SelectSoundDialog::isDefaultSoundChecked()
84 return ui->DefaultSoundRadioButton->isChecked();
87 void SelectSoundDialog::testSound( )
89 pSound_->setCurrentSource(ui->lineEdit->displayText());