From d703fb607c0291912211a5d43cdd04b60b6e87c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Sat, 26 Jun 2010 09:54:35 +0300 Subject: [PATCH] Added sound to the alert --- src/KitchenAlert.pro | 13 +++++-- src/alertsound.cpp | 50 ++++++++++++++++++++++++++ src/alertsound.h | 72 +++++++++++++++++++++++++++++++++++++ src/choosetimersequencedialog.cpp | 6 ++-- src/choosetimersequencedialog.h | 18 ++++++++-- src/createtimersequencedialog.cpp | 6 ++-- src/createtimersequencedialog.h | 18 ++++++++-- src/currentalertstablemodel.cpp | 6 ++-- src/currentalertstablemodel.h | 18 ++++++++-- src/kitchenalertmainwindow.cpp | 21 +++++++---- src/kitchenalertmainwindow.h | 20 +++++++++-- src/licence template | 6 ++-- src/main.cpp | 6 ++-- src/timer.cpp | 6 ++-- src/timer.h | 18 ++++++++-- src/timerschedule.cpp | 30 ++++++++++++++++ src/timerschedule.h | 42 ++++++++++++++++++++++ 17 files changed, 324 insertions(+), 32 deletions(-) create mode 100644 src/alertsound.cpp create mode 100644 src/alertsound.h create mode 100644 src/timerschedule.cpp create mode 100644 src/timerschedule.h diff --git a/src/KitchenAlert.pro b/src/KitchenAlert.pro index deb1cb2..60442ae 100644 --- a/src/KitchenAlert.pro +++ b/src/KitchenAlert.pro @@ -5,6 +5,7 @@ #------------------------------------------------- QT += core gui +QT += phonon TARGET = KitchenAlert TEMPLATE = app @@ -15,20 +16,24 @@ SOURCES += main.cpp\ choosetimersequencedialog.cpp \ createtimersequencedialog.cpp \ timer.cpp \ - currentalertstablemodel.cpp + currentalertstablemodel.cpp \ + alertsound.cpp HEADERS += kitchenalertmainwindow.h \ choosetimersequencedialog.h \ createtimersequencedialog.h \ timer.h \ - currentalertstablemodel.h + currentalertstablemodel.h \ + alertsound.h FORMS += kitchenalertmainwindow.ui \ choosetimersequencedialog.ui \ createtimersequencedialog.ui CONFIG += mobility -MOBILITY = +MOBILITY = + + symbian { TARGET.UID3 = 0xe1020059 @@ -36,3 +41,5 @@ symbian { TARGET.EPOCSTACKSIZE = 0x14000 TARGET.EPOCHEAPSIZE = 0x020000 0x800000 } + +RESOURCES += diff --git a/src/alertsound.cpp b/src/alertsound.cpp new file mode 100644 index 0000000..fc8e6d3 --- /dev/null +++ b/src/alertsound.cpp @@ -0,0 +1,50 @@ +/************************************************************************** + This file is part of KitchenAlert v.0.09 + + Copyright (C) 2010 Heli Hyvättinen + + Kitchen Alert is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +**************************************************************************/ + + + + + +#include "alertsound.h" + +#include + + + +AlertSound::AlertSound(QObject *parent) : + QObject(parent) +{ + + + pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource("/home/user/MyDocs/KitchenAlertTestSound1.wav")); +} + +void AlertSound::play() +{ + + pSound_->play(); + qDebug() << "Sound should be played now"; +} + +void AlertSound::stop() +{ + + pSound_->stop(); +} diff --git a/src/alertsound.h b/src/alertsound.h new file mode 100644 index 0000000..d754087 --- /dev/null +++ b/src/alertsound.h @@ -0,0 +1,72 @@ +/************************************************************************** + KitchenAlert + + Copyright (C) 2010 Heli Hyvättinen + + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +**************************************************************************/ + + + + + +#ifndef ALERTSOUND_H +#define ALERTSOUND_H + +#include + + + + #include + + + +/*! Class for playing the alert sound' + + @author Heli Hyvättinen + @date 2010-06-26 + @version 0.09 + +Class for playing (and stopping) the alert sound. + +*/ + +class AlertSound : public QObject +{ + Q_OBJECT +public: + explicit AlertSound(QObject *parent = 0); + +signals: + +public slots: + /*! Plays the sound */ + void play(); + + /*! Stops the sound from playing */ + void stop(); + +private: + + + + Phonon::MediaObject *pSound_; + + +}; + +#endif // ALERTSOUND_H diff --git a/src/choosetimersequencedialog.cpp b/src/choosetimersequencedialog.cpp index 814a87c..7c7810f 100644 --- a/src/choosetimersequencedialog.cpp +++ b/src/choosetimersequencedialog.cpp @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/src/choosetimersequencedialog.h b/src/choosetimersequencedialog.h index d4f87eb..3af0152 100644 --- a/src/choosetimersequencedialog.h +++ b/src/choosetimersequencedialog.h @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -21,7 +23,6 @@ - #ifndef CHOOSETIMERSEQUENCEDIALOG_H #define CHOOSETIMERSEQUENCEDIALOG_H @@ -32,6 +33,17 @@ namespace Ui { class ChooseTimerSequenceDialog; } +/*! Class for the dialog for choosing timers' + + @author Heli Hyvättinen + @date 2010-06-26 + @version 0.09 + +Does nothing but show the dialog now, useless. + +*/ + + class ChooseTimerSequenceDialog : public QDialog { Q_OBJECT diff --git a/src/createtimersequencedialog.cpp b/src/createtimersequencedialog.cpp index 98ba30c..d7b696c 100644 --- a/src/createtimersequencedialog.cpp +++ b/src/createtimersequencedialog.cpp @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/src/createtimersequencedialog.h b/src/createtimersequencedialog.h index a84dbd6..3e93f36 100644 --- a/src/createtimersequencedialog.h +++ b/src/createtimersequencedialog.h @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -33,6 +35,18 @@ namespace Ui { class CreateTimerSequenceDialog; } + +/*! Class for the dialog for creating timers' + + @author Heli Hyvättinen + @date 2010-06-26 + @version 0.09 + +Class for the dialog for creating timers + +*/ + + class CreateTimerSequenceDialog : public QDialog { Q_OBJECT diff --git a/src/currentalertstablemodel.cpp b/src/currentalertstablemodel.cpp index 6587e01..b856739 100644 --- a/src/currentalertstablemodel.cpp +++ b/src/currentalertstablemodel.cpp @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.019 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/src/currentalertstablemodel.h b/src/currentalertstablemodel.h index 75c8a75..32cadc3 100644 --- a/src/currentalertstablemodel.h +++ b/src/currentalertstablemodel.h @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.019 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -28,6 +30,18 @@ #include #include "timer.h" + +/*! Class that contains the model that holds the timers' + + @author Heli Hyvättinen + @date 2010-06-26 + @version 0.09 + +Class that contains the model that holds the timers + +*/ + + class CurrentAlertsTableModel : public QAbstractTableModel { Q_OBJECT diff --git a/src/kitchenalertmainwindow.cpp b/src/kitchenalertmainwindow.cpp index 4b00556..36b1142 100644 --- a/src/kitchenalertmainwindow.cpp +++ b/src/kitchenalertmainwindow.cpp @@ -1,10 +1,12 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -33,9 +35,11 @@ #include "createtimersequencedialog.h" + #include #include -#include + + KitchenAlertMainWindow::KitchenAlertMainWindow(QWidget *parent) : QMainWindow(parent), @@ -167,9 +171,11 @@ void KitchenAlertMainWindow::alert(QModelIndex indexOfAlerter) //The alert sound is played - //TODO + //TODO + + alertSound_.play(); } @@ -186,6 +192,7 @@ void KitchenAlertMainWindow::snooze() model_.snoozeTimer(selectedRow()); ui->SnoozeButton->setDisabled(true); + alertSound_.stop(); } @@ -193,14 +200,16 @@ void KitchenAlertMainWindow::restart() { model_.startTimer(selectedRow()); - ui->SnoozeButton->setDisabled(true); + ui->SnoozeButton->setDisabled(true); + alertSound_.stop(); } void KitchenAlertMainWindow::stop() { model_.stopTimer(selectedRow()); - ui->SnoozeButton->setDisabled(true); + ui->SnoozeButton->setDisabled(true); + alertSound_.stop(); } QModelIndex KitchenAlertMainWindow::selectedRow() diff --git a/src/kitchenalertmainwindow.h b/src/kitchenalertmainwindow.h index 882d720..393875b 100644 --- a/src/kitchenalertmainwindow.h +++ b/src/kitchenalertmainwindow.h @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -27,12 +29,24 @@ #include "timer.h" #include "currentalertstablemodel.h" #include +#include "alertsound.h" namespace Ui { class KitchenAlertMainWindow; } + +/*! The main window class of KitchenAlert' + + @author Heli Hyvättinen + @date 2010-06-26 + @version 0.09 + +Operates the UI. + +*/ + class KitchenAlertMainWindow : public QMainWindow { Q_OBJECT @@ -67,6 +81,8 @@ private: CurrentAlertsTableModel model_; QModelIndex selectedRow(); + + AlertSound alertSound_; }; #endif // KITCHENALERTMAINWINDOW_H diff --git a/src/licence template b/src/licence template index bc10c42..7e56f68 100644 --- a/src/licence template +++ b/src/licence template @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.019 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen + + This file is part of KitchenAlert. - This program is free software: you can redistribute it and/or modify + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/src/main.cpp b/src/main.cpp index 9f83c01..5e157c4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/src/timer.cpp b/src/timer.cpp index 8fac364..9c5e75d 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/src/timer.h b/src/timer.h index e75d9e4..26c6f6a 100644 --- a/src/timer.h +++ b/src/timer.h @@ -1,9 +1,11 @@ /************************************************************************** - KitchenAlert v.0.01 + KitchenAlert Copyright (C) 2010 Heli Hyvättinen - This program is free software: you can redistribute it and/or modify + This file is part of KitchenAlert. + + Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -32,6 +34,18 @@ #include + + +/*! The timer class of KitchenAlert' + + @author Heli Hyvättinen + @date 2010-06-26 + @version 0.09 + +The timer class of KitchenAlert. + +*/ + class Timer : public QObject { Q_OBJECT diff --git a/src/timerschedule.cpp b/src/timerschedule.cpp new file mode 100644 index 0000000..ccf564e --- /dev/null +++ b/src/timerschedule.cpp @@ -0,0 +1,30 @@ +/************************************************************************** + KitchenAlert v.0.01 + + Copyright (C) 2010 Heli Hyvättinen + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +**************************************************************************/ + + + + + +#include "timerschedule.h" + +TimerSchedule::TimerSchedule(QObject *parent) : + QObject(parent) +{ +} diff --git a/src/timerschedule.h b/src/timerschedule.h new file mode 100644 index 0000000..86d0ec4 --- /dev/null +++ b/src/timerschedule.h @@ -0,0 +1,42 @@ +/************************************************************************** + KitchenAlert v.0.01 + + Copyright (C) 2010 Heli Hyvättinen + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +**************************************************************************/ + + + + + +#ifndef TIMERSCHEDULE_H +#define TIMERSCHEDULE_H + +#include + +class TimerSchedule : public QObject +{ + Q_OBJECT +public: + explicit TimerSchedule(QObject *parent = 0); + +signals: + +public slots: + +}; + +#endif // TIMERSCHEDULE_H -- 1.7.9.5