Added saving of alerts - unstable!!!
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sun, 22 Aug 2010 19:48:18 +0000 (22:48 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sun, 22 Aug 2010 19:48:18 +0000 (22:48 +0300)
Added the new logo to web pages

21 files changed:
src/KitchenAlert.pro.user.1.3 [deleted file]
src/alertsound.cpp
src/createtimersequencedialog.cpp
src/currentalertstablemodel.cpp
src/currentalertstablemodel.h
src/icon26.png [deleted file]
src/kitchenalert.qrc
src/kitchenalertmainwindow.cpp
src/kitchenalertmainwindow.h
src/kitchenalertmainwindow.ui
src/licence template~ [deleted file]
src/main.cpp
src/savedtimers.cpp [new file with mode: 0644]
src/savedtimers.h [new file with mode: 0644]
src/selectsounddialog.cpp
src/selectsounddialog.h
src/selectsounddialog.ui
src/timer.cpp
src/timer.h
www/index.html
www/kitchenalert_48x48.png [new file with mode: 0644]

diff --git a/src/KitchenAlert.pro.user.1.3 b/src/KitchenAlert.pro.user.1.3
deleted file mode 100644 (file)
index 8009944..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-<!DOCTYPE QtCreatorProject>
-<qtcreator>
- <data>
-  <variable>RunConfiguration0-BaseEnvironmentBase</variable>
-  <value type="int">2</value>
- </data>
- <data>
-  <variable>RunConfiguration0-CommandLineArguments</variable>
-  <valuelist type="QVariantList"/>
- </data>
- <data>
-  <variable>RunConfiguration0-ProFile</variable>
-  <value type="QString">KitchenAlert.pro</value>
- </data>
- <data>
-  <variable>RunConfiguration0-RunConfiguration.name</variable>
-  <value type="QString">KitchenAlert</value>
- </data>
- <data>
-  <variable>RunConfiguration0-UseDyldImageSuffix</variable>
-  <value type="bool">false</value>
- </data>
- <data>
-  <variable>RunConfiguration0-UseTerminal</variable>
-  <value type="bool">false</value>
- </data>
- <data>
-  <variable>RunConfiguration0-UserEnvironmentChanges</variable>
-  <valuelist type="QVariantList"/>
- </data>
- <data>
-  <variable>RunConfiguration0-UserSetName</variable>
-  <value type="bool">false</value>
- </data>
- <data>
-  <variable>RunConfiguration0-UserSetWorkingDirectory</variable>
-  <value type="bool">false</value>
- </data>
- <data>
-  <variable>RunConfiguration0-UserWorkingDirectory</variable>
-  <value type="QString"></value>
- </data>
- <data>
-  <variable>RunConfiguration0-type</variable>
-  <value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
- </data>
- <data>
-  <variable>activeRunConfiguration</variable>
-  <value type="int">0</value>
- </data>
- <data>
-  <variable>activebuildconfiguration</variable>
-  <value type="QString">Debug</value>
- </data>
- <data>
-  <variable>buildConfiguration-Debug</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
-   <value key="QtVersionId" type="int">0</value>
-   <value key="ToolChain" type="int">0</value>
-   <value key="buildConfiguration" type="int">2</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildConfiguration-Release</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
-   <value key="QtVersionId" type="int">0</value>
-   <value key="buildConfiguration" type="int">0</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfiguration-Debug-buildstep0</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfiguration-Debug-buildstep1</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfiguration-Debug-cleanstep0</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
-   <value key="cleanConfig" type="bool">true</value>
-   <valuelist key="makeargs" type="QVariantList">
-    <value type="QString">clean</value>
-   </valuelist>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfiguration-Release-buildstep0</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfiguration-Release-buildstep1</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfiguration-Release-cleanstep0</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildconfigurations</variable>
-  <valuelist type="QVariantList">
-   <value type="QString">Debug</value>
-   <value type="QString">Release</value>
-  </valuelist>
- </data>
- <data>
-  <variable>buildstep0</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
-   <value key="mkspec" type="QString"></value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildstep1</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
-  </valuemap>
- </data>
- <data>
-  <variable>buildsteps</variable>
-  <valuelist type="QVariantList">
-   <value type="QString">trolltech.qt4projectmanager.qmake</value>
-   <value type="QString">trolltech.qt4projectmanager.make</value>
-  </valuelist>
- </data>
- <data>
-  <variable>cleanstep0</variable>
-  <valuemap type="QVariantMap">
-   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
-   <value key="clean" type="bool">true</value>
-  </valuemap>
- </data>
- <data>
-  <variable>cleansteps</variable>
-  <valuelist type="QVariantList">
-   <value type="QString">trolltech.qt4projectmanager.make</value>
-  </valuelist>
- </data>
- <data>
-  <variable>defaultFileEncoding</variable>
-  <value type="QByteArray">System</value>
- </data>
- <data>
-  <variable>project</variable>
-  <valuemap type="QVariantMap"/>
- </data>
-</qtcreator>
index 94470b0..b11f538 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <QDebug>
 #include <QSettings>
+#include <QList>
+
 
 
 
@@ -51,11 +53,32 @@ AlertSound::AlertSound(QObject *parent) :
         filename = settings.value("soundfile",defaultsound_).toString();
     }
     pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(filename));
+
+
+    //TESTCODE!!!
+
+    QList<Phonon::AudioOutputDevice> 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";
 }
index a2ae8ce..b7c360f 100644 (file)
@@ -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()
index ca4b463..755a109 100644 (file)
@@ -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);
+}
index d147c38..52f3f5c 100644 (file)
@@ -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 (file)
index 17413e5..0000000
Binary files a/src/icon26.png and /dev/null differ
index 4d8ed66..a3f703b 100644 (file)
@@ -1,3 +1,5 @@
 <RCC>
-    <qresource prefix="/"/>
+    <qresource prefix="/">
+        <file>icon64.png</file>
+    </qresource>
 </RCC>
index ff4c78a..18c4e2f 100644 (file)
@@ -44,6 +44,7 @@
 #include <QMessageBox>
 #include <QFileDialog>
 #include <QFile>
+#include <QIcon>
 
 
 
@@ -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("<p>Version 0.1.1"
+    QMessageBox::about(this,tr("About KitchenAlert"),tr("<p>Version %1"
                                                         "<p>Copyright &copy; Heli Hyv&auml;ttinen 2010"
                                                          "<p>License: General Public License v3"
-                                                         "<p>Bugtracker and project page: https://garage.maemo.org/projects/kitchenalert/"));
+                                                         "<p>Bugtracker and project page: https://garage.maemo.org/projects/kitchenalert/").arg(QApplication::applicationVersion()));
 }
 
 bool KitchenAlertMainWindow::event(QEvent *event)
index 9ae6a8d..30711ea 100644 (file)
@@ -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);
+
 
 };
 
index 5aa6b80..3303d88 100644 (file)
           </widget>
          </item>
          <item>
+          <widget class="QPushButton" name="SaveButton">
+           <property name="text">
+            <string>Save</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="loadButton">
+           <property name="text">
+            <string>Load</string>
+           </property>
+          </widget>
+         </item>
+         <item>
           <spacer name="horizontalSpacer_2">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
diff --git a/src/licence template~ b/src/licence template~
deleted file mode 100644 (file)
index 43ab975..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-
-**************************************************************************/
-
-
-
-
index 349ea26..7a30501 100644 (file)
@@ -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 (file)
index 0000000..0de87cf
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+**************************************************************************/
+
+
+
+
+
+#include "savedtimers.h"
+
+SavedTimers::SavedTimers(QObject *parent) :
+    QObject(parent)
+{
+}
diff --git a/src/savedtimers.h b/src/savedtimers.h
new file mode 100644 (file)
index 0000000..79ae9e6
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+**************************************************************************/
+
+
+
+
+
+#ifndef SAVEDTIMERS_H
+#define SAVEDTIMERS_H
+
+#include <QObject>
+
+class SavedTimers : public QObject
+{
+    Q_OBJECT
+public:
+    explicit SavedTimers(QObject *parent = 0);
+
+signals:
+
+public slots:
+
+};
+
+#endif // SAVEDTIMERS_H
index 539796e..210fb90 100644 (file)
@@ -29,6 +29,7 @@
 #include <QFileDialog>
 #include <QSettings>
 #include <QDebug>
+#include <Phonon>
 
 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();
+}
index 818d3e5..24bbc9c 100644 (file)
@@ -28,6 +28,7 @@
 #define SELECTSOUNDDIALOG_H
 
 #include <QDialog>
+#include <Phonon>
 
 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
index 0104637..6a34a08 100644 (file)
@@ -101,6 +101,13 @@ p, li { white-space: pre-wrap; }
        </spacer>
       </item>
       <item>
+       <widget class="QPushButton" name="testButton">
+        <property name="text">
+         <string>Test sound</string>
+        </property>
+       </widget>
+      </item>
+      <item>
        <widget class="QPushButton" name="OKButton">
         <property name="text">
          <string>Done</string>
index e1dba54..1b3eed6 100644 (file)
@@ -27,6 +27,9 @@
 #include "timer.h"
 #include "currentalertstablemodel.h"
 #include <qdebug.h>
+#include <QFile>
+#include <QXmlStreamWriter>
+#include <QXmlStreamReader>
 
 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;
+
+
+
+
+}
+
index 543e956..81b64cd 100644 (file)
@@ -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!
index 6c8ef4f..8b7498c 100644 (file)
@@ -2,13 +2,14 @@
 <html><head>
 
 
+
   
   <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>KitchenAlert</title></head><body>
 <table style="text-align: left; width: 640px; margin-left: auto; margin-right: auto;" border="0" cellpadding="2" cellspacing="2">
 
   <tbody>
     <tr align="center">
-      <td style="vertical-align: middle; width: 484px; background-color: rgb(204, 204, 255); text-align: center;"><span style="font-family: Helvetica,Arial,sans-serif;"></span>&nbsp; <big><span style="font-family: Helvetica,Arial,sans-serif;">KitchenAlert for Maemo</span></big>
+      <td style="vertical-align: middle; width: 484px; background-color: rgb(204, 204, 255); text-align: center;"><span style="font-family: Helvetica,Arial,sans-serif;"></span><img style="width: 48px; height: 48px;" alt="" src="kitchenalert_48x48.png" align="middle">&nbsp; <big><span style="font-family: Helvetica,Arial,sans-serif;">KitchenAlert for Maemo</span></big>
       <br>
       </td>
     </tr>
@@ -76,7 +77,7 @@ usual for&nbsp;
 this repositories, it's not necessarily safe: </span><span style="font-family: Helvetica,Arial,sans-serif;">keep&nbsp; in mind the above cautions on volume settings, losing alert sound and battery drain.</span><span style="font-family: Helvetica,Arial,sans-serif;"> Remember to close the repository after installing to
 avoid unwanted updating of your applications to development versions.<br>
       <br>
-Bug reports and feature request are welcome on the application's <a href="https://garage.maemo.org/projects/kitchenalert/">garage project
+Bug reports and feature requests are welcome on the application's <a href="https://garage.maemo.org/projects/kitchenalert/">garage project
 page</a>.</span><br>
       <br>
       </td>
diff --git a/www/kitchenalert_48x48.png b/www/kitchenalert_48x48.png
new file mode 100644 (file)
index 0000000..303f8fc
Binary files /dev/null and b/www/kitchenalert_48x48.png differ