From: Heli Hyvättinen Date: Sun, 22 Aug 2010 19:48:18 +0000 (+0300) Subject: Added saving of alerts - unstable!!! X-Git-Tag: v0.4.0~36 X-Git-Url: http://vcs.maemo.org/git/?p=kitchenalert;a=commitdiff_plain;h=7fc4c44cca1259b70545aab60cead8cd3ff884ff Added saving of alerts - unstable!!! Added the new logo to web pages --- diff --git a/src/KitchenAlert.pro.user.1.3 b/src/KitchenAlert.pro.user.1.3 deleted file mode 100644 index 8009944..0000000 --- a/src/KitchenAlert.pro.user.1.3 +++ /dev/null @@ -1,160 +0,0 @@ - - - - RunConfiguration0-BaseEnvironmentBase - 2 - - - RunConfiguration0-CommandLineArguments - - - - RunConfiguration0-ProFile - KitchenAlert.pro - - - RunConfiguration0-RunConfiguration.name - KitchenAlert - - - RunConfiguration0-UseDyldImageSuffix - false - - - RunConfiguration0-UseTerminal - false - - - RunConfiguration0-UserEnvironmentChanges - - - - RunConfiguration0-UserSetName - false - - - RunConfiguration0-UserSetWorkingDirectory - false - - - RunConfiguration0-UserWorkingDirectory - - - - RunConfiguration0-type - Qt4ProjectManager.Qt4RunConfiguration - - - activeRunConfiguration - 0 - - - activebuildconfiguration - Debug - - - buildConfiguration-Debug - - Debug - 0 - 0 - 2 - - - - buildConfiguration-Release - - Release - 0 - 0 - - - - buildconfiguration-Debug-buildstep0 - - Debug - - - - buildconfiguration-Debug-buildstep1 - - Debug - - - - buildconfiguration-Debug-cleanstep0 - - Debug - true - - clean - - - - - buildconfiguration-Release-buildstep0 - - Release - - - - buildconfiguration-Release-buildstep1 - - Release - - - - buildconfiguration-Release-cleanstep0 - - Release - - - - buildconfigurations - - Debug - Release - - - - buildstep0 - - - - - - - buildstep1 - - - - - - buildsteps - - trolltech.qt4projectmanager.qmake - trolltech.qt4projectmanager.make - - - - cleanstep0 - - - true - - - - cleansteps - - trolltech.qt4projectmanager.make - - - - defaultFileEncoding - System - - - project - - - diff --git a/src/alertsound.cpp b/src/alertsound.cpp index 94470b0..b11f538 100644 --- a/src/alertsound.cpp +++ b/src/alertsound.cpp @@ -26,6 +26,8 @@ #include #include +#include + @@ -51,11 +53,32 @@ AlertSound::AlertSound(QObject *parent) : filename = settings.value("soundfile",defaultsound_).toString(); } pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(filename)); + + + //TESTCODE!!! + + QList audioOutputDevices = + Phonon::BackendCapabilities::availableAudioOutputDevices(); + + foreach (Phonon::AudioOutputDevice device, audioOutputDevices) + { + qDebug() << device.name() << device.description(); + } } void AlertSound::play() { + //TESTCODE + + Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); + + Phonon::Path path = Phonon::createPath(pSound_, audioOutput); + + audioOutput->setVolumeDecibel(0); + + //TESTCODE ENDS + pSound_->play(); qDebug() << "Sound should be played now"; } diff --git a/src/createtimersequencedialog.cpp b/src/createtimersequencedialog.cpp index a2ae8ce..b7c360f 100644 --- a/src/createtimersequencedialog.cpp +++ b/src/createtimersequencedialog.cpp @@ -32,7 +32,7 @@ CreateTimerSequenceDialog::CreateTimerSequenceDialog(QWidget *parent) : ui(new Ui::CreateTimerSequenceDialog) { ui->setupUi(this); - ui->timer1AlertText->setMaxLength(40); + // ui->timer1AlertText->setMaxLength(40); //needed only with fixed cell height } CreateTimerSequenceDialog::~CreateTimerSequenceDialog() diff --git a/src/currentalertstablemodel.cpp b/src/currentalertstablemodel.cpp index ca4b463..755a109 100644 --- a/src/currentalertstablemodel.cpp +++ b/src/currentalertstablemodel.cpp @@ -308,3 +308,8 @@ void CurrentAlertsTableModel::removeTimer(QModelIndex index) delete p_timer; } } + +bool CurrentAlertsTableModel::saveTimer(QModelIndex index, QString filename) +{ + return currentTimers_.at(index.row())->save(filename); +} diff --git a/src/currentalertstablemodel.h b/src/currentalertstablemodel.h index d147c38..52f3f5c 100644 --- a/src/currentalertstablemodel.h +++ b/src/currentalertstablemodel.h @@ -61,6 +61,8 @@ public: bool isThisTimerAlerting(QModelIndex index); + bool saveTimer(QModelIndex index,QString filename); + signals: public slots: diff --git a/src/icon26.png b/src/icon26.png deleted file mode 100644 index 17413e5..0000000 Binary files a/src/icon26.png and /dev/null differ diff --git a/src/kitchenalert.qrc b/src/kitchenalert.qrc index 4d8ed66..a3f703b 100644 --- a/src/kitchenalert.qrc +++ b/src/kitchenalert.qrc @@ -1,3 +1,5 @@ - + + icon64.png + diff --git a/src/kitchenalertmainwindow.cpp b/src/kitchenalertmainwindow.cpp index ff4c78a..18c4e2f 100644 --- a/src/kitchenalertmainwindow.cpp +++ b/src/kitchenalertmainwindow.cpp @@ -44,6 +44,7 @@ #include #include #include +#include @@ -53,6 +54,11 @@ KitchenAlertMainWindow::KitchenAlertMainWindow(QWidget *parent) : { ui->setupUi(this); + setWindowIcon(QIcon(":/icon64.png")); + + //load sticky alerts to the model here... + + //alerts' tableview setup @@ -60,13 +66,21 @@ KitchenAlertMainWindow::KitchenAlertMainWindow(QWidget *parent) : ui->ComingAlertsTableView->setModel(&model_); ui->ComingAlertsTableView->setSelectionMode(QAbstractItemView::SingleSelection); ui->ComingAlertsTableView->setSelectionBehavior(QAbstractItemView::SelectRows); - ui->ComingAlertsTableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed); - ui->ComingAlertsTableView->horizontalHeader()->resizeSection(0,460); - ui->ComingAlertsTableView->horizontalHeader()->resizeSection(1,140); - ui->ComingAlertsTableView->horizontalHeader()->resizeSection(2,100); - ui->ComingAlertsTableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); -// ui->ComingAlertsTableView->verticalHeader()->setDefaultSectionSize(40); //Needed with fixed cell heght only + + //Commented out for testing their potebtial effect for slowdown: + + // ui->ComingAlertsTableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed); +// ui->ComingAlertsTableView->horizontalHeader()->resizeSection(0,460); +// ui->ComingAlertsTableView->horizontalHeader()->resizeSection(1,140); +// ui->ComingAlertsTableView->horizontalHeader()->resizeSection(2,100); + +// ui->ComingAlertsTableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); + + + + +// ui->ComingAlertsTableView->verticalHeader()->setDefaultSectionSize(40); //Needed with fixed cell height only @@ -286,10 +300,10 @@ void KitchenAlertMainWindow::openSelectSoundDialog() void KitchenAlertMainWindow::openAbout() { - QMessageBox::about(this,tr("About KitchenAlert"),tr("

Version 0.1.1" + QMessageBox::about(this,tr("About KitchenAlert"),tr("

Version %1" "

Copyright © Heli Hyvättinen 2010" "

License: General Public License v3" - "

Bugtracker and project page: https://garage.maemo.org/projects/kitchenalert/")); + "

Bugtracker and project page: https://garage.maemo.org/projects/kitchenalert/").arg(QApplication::applicationVersion())); } bool KitchenAlertMainWindow::event(QEvent *event) diff --git a/src/kitchenalertmainwindow.h b/src/kitchenalertmainwindow.h index 9ae6a8d..30711ea 100644 --- a/src/kitchenalertmainwindow.h +++ b/src/kitchenalertmainwindow.h @@ -71,6 +71,9 @@ public slots: void restart(); void stop(); void remove(); + void saveTimer(); + void loadTimer(); + protected: @@ -91,6 +94,8 @@ private: AlertSound alertSound_; + void initializeTimer(Timer * p_timer); + }; diff --git a/src/kitchenalertmainwindow.ui b/src/kitchenalertmainwindow.ui index 5aa6b80..3303d88 100644 --- a/src/kitchenalertmainwindow.ui +++ b/src/kitchenalertmainwindow.ui @@ -103,6 +103,20 @@ + + + Save + + + + + + + Load + + + + Qt::Horizontal diff --git a/src/licence template~ b/src/licence template~ deleted file mode 100644 index 43ab975..0000000 --- a/src/licence template~ +++ /dev/null @@ -1,23 +0,0 @@ -/************************************************************************** - 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 . - -**************************************************************************/ - - - - diff --git a/src/main.cpp b/src/main.cpp index 349ea26..7a30501 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,8 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setApplicationName("KitchenAlert"); //a name required by phonon + a.setApplicationVersion("0.2"); + KitchenAlertMainWindow w; #if defined(Q_WS_S60) w.showMaximized(); diff --git a/src/savedtimers.cpp b/src/savedtimers.cpp new file mode 100644 index 0000000..0de87cf --- /dev/null +++ b/src/savedtimers.cpp @@ -0,0 +1,32 @@ +/************************************************************************** + 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 . + +**************************************************************************/ + + + + + +#include "savedtimers.h" + +SavedTimers::SavedTimers(QObject *parent) : + QObject(parent) +{ +} diff --git a/src/savedtimers.h b/src/savedtimers.h new file mode 100644 index 0000000..79ae9e6 --- /dev/null +++ b/src/savedtimers.h @@ -0,0 +1,44 @@ +/************************************************************************** + 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 SAVEDTIMERS_H +#define SAVEDTIMERS_H + +#include + +class SavedTimers : public QObject +{ + Q_OBJECT +public: + explicit SavedTimers(QObject *parent = 0); + +signals: + +public slots: + +}; + +#endif // SAVEDTIMERS_H diff --git a/src/selectsounddialog.cpp b/src/selectsounddialog.cpp index 539796e..210fb90 100644 --- a/src/selectsounddialog.cpp +++ b/src/selectsounddialog.cpp @@ -29,6 +29,7 @@ #include #include #include +#include SelectSoundDialog::SelectSoundDialog(QWidget *parent) : QDialog(parent), @@ -50,6 +51,11 @@ SelectSoundDialog::SelectSoundDialog(QWidget *parent) : } else ui->CustomSoundRadioButton->setChecked(true); qDebug() << "UseDefaultSoundfile is " << useDefaultSoundFile; + + connect(ui->testButton,SIGNAL(clicked()),this,SLOT(testSound())); + pSound_ = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource(ui->lineEdit->displayText())); + + } SelectSoundDialog::~SelectSoundDialog() @@ -77,3 +83,9 @@ bool SelectSoundDialog::isDefaultSoundChecked() { return ui->DefaultSoundRadioButton->isChecked(); } + +void SelectSoundDialog::testSound( ) +{ + pSound_->setCurrentSource(ui->lineEdit->displayText()); + pSound_->play(); +} diff --git a/src/selectsounddialog.h b/src/selectsounddialog.h index 818d3e5..24bbc9c 100644 --- a/src/selectsounddialog.h +++ b/src/selectsounddialog.h @@ -28,6 +28,7 @@ #define SELECTSOUNDDIALOG_H #include +#include namespace Ui { class SelectSoundDialog; @@ -55,9 +56,12 @@ public: public slots: void browse(); + void testSound(); private: Ui::SelectSoundDialog *ui; + Phonon::MediaObject* pSound_; + }; #endif // SELECTSOUNDDIALOG_H diff --git a/src/selectsounddialog.ui b/src/selectsounddialog.ui index 0104637..6a34a08 100644 --- a/src/selectsounddialog.ui +++ b/src/selectsounddialog.ui @@ -101,6 +101,13 @@ p, li { white-space: pre-wrap; } + + + Test sound + + + + Done diff --git a/src/timer.cpp b/src/timer.cpp index e1dba54..1b3eed6 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -27,6 +27,9 @@ #include "timer.h" #include "currentalertstablemodel.h" #include +#include +#include +#include Timer::Timer(QObject *parent) : QObject(parent) @@ -137,3 +140,54 @@ QModelIndex Timer::whereAmI() } +bool Timer::save(QString filename) +{ + QFile file(filename); + + if (!file.open(QFile::WriteOnly | QFile::Text)) + { + return false; + } + + QXmlStreamWriter xmlWriter(&file); + xmlWriter.setAutoFormatting(true); + xmlWriter.writeStartDocument(); + xmlWriter.writeStartElement("kitchenalert"); + xmlWriter.writeStartElement("timer"); + xmlWriter.writeAttribute("alert_text",_alertText); + xmlWriter.writeAttribute("time_in_seconds", QString().setNum(_originalTime)); + xmlWriter.writeEndDocument(); //this should close all open elements + + return true; +} + +bool Timer::load(QString filename) +{ + QFile file (filename); + if (!file.open(QFile::ReadOnly | QFile::Text)) + { + return false; + } + + QXmlStreamReader reader; + reader.setDevice(&file); + + reader.readNextStartElement(); + + if (reader.name() != "kitchenalert") + return false; + + reader.readNextStartElement(); + if (reader.name() != "timer") + return false; + + + _alertText = reader.attributes().value("alert_text").toString(); + _originalTime = reader.attributes().value("time_in_seconds").toString().toInt(); + return true; + + + + +} + diff --git a/src/timer.h b/src/timer.h index 543e956..81b64cd 100644 --- a/src/timer.h +++ b/src/timer.h @@ -52,6 +52,7 @@ class Timer : public QObject public: explicit Timer(QObject *parent = 0); + int getOriginalTimeInSeconds(); void setOriginalTimeInSeconds(int seconds); @@ -61,6 +62,8 @@ public: void setAlertText(QString text); bool isAlerting(); + bool save(QString filename); + bool load(QString filename); signals: @@ -76,6 +79,7 @@ public slots: + private: int _originalTime; //seconds! int _remainingTime; //seconds! diff --git a/www/index.html b/www/index.html index 6c8ef4f..8b7498c 100644 --- a/www/index.html +++ b/www/index.html @@ -2,13 +2,14 @@ + KitchenAlert - @@ -76,7 +77,7 @@ usual for  this repositories, it's not necessarily safe: keep  in mind the above cautions on volume settings, losing alert sound and battery drain. Remember to close the repository after installing to avoid unwanted updating of your applications to development versions.

-Bug reports and feature request are welcome on the application's garage project +Bug reports and feature requests are welcome on the application's garage project page.


diff --git a/www/kitchenalert_48x48.png b/www/kitchenalert_48x48.png new file mode 100644 index 0000000..303f8fc Binary files /dev/null and b/www/kitchenalert_48x48.png differ
  KitchenAlert for Maemo +   KitchenAlert for Maemo