timer.cpp \
currentalertstablemodel.cpp \
alertsound.cpp \
- selectsounddialog.cpp
+ selectsounddialog.cpp \
+ stickydialog.cpp
HEADERS += kitchenalertmainwindow.h \
createtimersequencedialog.h \
timer.h \
currentalertstablemodel.h \
alertsound.h \
- selectsounddialog.h
+ selectsounddialog.h \
+ stickydialog.h
FORMS += kitchenalertmainwindow.ui \
createtimersequencedialog.ui \
desktopfile.path = /usr/share/applications/hildon
INSTALLS += desktopfile
}
+
+OTHER_FILES += \
+ qtc_packaging/debian_fremantle/rules \
+ qtc_packaging/debian_fremantle/README \
+ qtc_packaging/debian_fremantle/copyright \
+ qtc_packaging/debian_fremantle/control \
+ qtc_packaging/debian_fremantle/compat \
+ qtc_packaging/debian_fremantle/changelog
#include "createtimersequencedialog.h"
#include "selectsounddialog.h"
-
-
#include <QDebug>
#include <QAction>
#include <QSettings>
#include <QFileDialog>
-
+#include <QStringListModel>
+#include <QListView>
+#include "stickydialog.h"
KitchenAlertMainWindow::KitchenAlertMainWindow(QWidget *parent) :
QAction * p_AboutAction = new QAction(tr("About"),this);
connect(p_AboutAction,SIGNAL(triggered()),this,SLOT(openAbout()));
menuBar()->addAction(p_AboutAction);
+
+ QAction * p_StickyAction = new QAction(tr("Edit sticky timers"),this);
+ connect(p_StickyAction, SIGNAL(triggered()),this,SLOT(openStickyDialog()));
+ menuBar()->addAction(p_StickyAction);
+
+ loadStickies();
+
}
KitchenAlertMainWindow::~KitchenAlertMainWindow()
// filename.append(".kitchenalert");
// }
- QString errorTitle(tr("Failed to load file "));
- errorTitle.append(filename);
-
- Timer * p_timer = new Timer();
- if (!p_timer->load(filename))
- {
- QMessageBox::critical(this,errorTitle,tr("Unable to open file or not a valid KitchenAlert timer file."));
- delete p_timer;
- return;
- }
+ loadTimer(filename,true); //timer gets started
- initializeTimer(p_timer);
}
}
-void KitchenAlertMainWindow::initializeTimer(Timer *p_timer)
+void KitchenAlertMainWindow::initializeTimer(Timer *p_timer, bool startImmediately)
{
//connect alert
QList<Timer *> timerList;
timerList.append(p_timer);
-model_.addTimers(timerList,true); //timer gets started in the model
+model_.addTimers(timerList,startImmediately); //timer gets started in the model if startImmediately is true (default)
+
+}
+
+void KitchenAlertMainWindow::openStickyDialog()
+{
+ StickyDialog stickyDialog(defaultSaveDirectory_);
+
+
+ if (stickyDialog.exec()== QDialog::Accepted)
+ {
+ QSettings settings;
+ settings.setValue("sticky",stickyDialog.getStickyList());
+ }
+}
+
+bool KitchenAlertMainWindow::loadStickies()
+{
+ bool allSuccess = true;
+
+ QSettings settings;
+
+ QStringList stickies = settings.value("sticky").toStringList();
+
+ foreach (QString stickyFileName, stickies)
+ {
+ if (!loadTimer(stickyFileName,false)) //initializes the timer without starting it
+ allSuccess = false;
+ }
+
+ return allSuccess;
}
+bool KitchenAlertMainWindow::loadTimer(QString filename, bool startImmediately)
+{
+ QString errorTitle(tr("Failed to load file "));
+ errorTitle.append(filename);
+ Timer * p_timer = new Timer();
+ if (!p_timer->load(filename))
+ {
+ QMessageBox::critical(this,errorTitle,tr("Unable to open file or not a valid KitchenAlert timer file."));
+ delete p_timer;
+ return false;
+ }
+ initializeTimer(p_timer,startImmediately);
+ return true;
+}
*/
void loadTimer();
+ /*! Opens a dialog for choosing which timers to preload at start */
+ void openStickyDialog();
signals:
*/
void disableSelectionDependentButtons();
+ bool loadStickies();
+
+
+
private:
Ui::KitchenAlertMainWindow *ui;
*/
void initializeAlertSound();
- void initializeTimer(Timer * p_timer);
-
+ void initializeTimer(Timer * p_timer, bool startImmediately = true);
+ //Adds the timer to the model and optionally starts it on success, gives an error message on failure
+ bool loadTimer(QString filename, bool startImmediately);
};
#endif // KITCHENALERTMAINWINDOW_H
--- /dev/null
+#include "stickydialog.h"
+#include <QVBoxLayout>
+#include <QSettings>
+#include <QPushButton>
+#include <QFileDialog>
+#include <QDebug>
+
+StickyDialog::StickyDialog(QString defaultDirectory, QWidget *parent) :
+ QDialog(parent)
+{
+ defaultDirectory_ = defaultDirectory;
+
+
+ QVBoxLayout* pMainLayout = new QVBoxLayout(this);
+
+ QSettings settings;
+ QStringList stickies = settings.value("sticky").toStringList();
+
+// stickies.append("Test String");
+
+ pStickiesModel_ = new QStringListModel;
+ pStickiesModel_->setStringList(stickies);
+
+ pStickiesView_ = new QListView;
+ pStickiesView_->setModel(pStickiesModel_);
+ pStickiesView_->setSelectionMode(QAbstractItemView::SingleSelection);
+ pMainLayout->addWidget(pStickiesView_);
+
+ QHBoxLayout * pButtonLayout = new QHBoxLayout;
+ pMainLayout->addLayout(pButtonLayout);
+
+ QPushButton * pAddButton = new QPushButton (tr("Add"));
+ connect(pAddButton,SIGNAL(clicked()),this,SLOT(add()));
+ pButtonLayout->addWidget(pAddButton);
+
+ QPushButton * pRemoveButton = new QPushButton(tr("Remove"));
+ connect(pRemoveButton,SIGNAL(clicked()),this,SLOT(remove()));
+ pButtonLayout->addWidget(pRemoveButton);
+
+ QPushButton * pOkButton = new QPushButton(tr("OK"));
+ connect (pOkButton,SIGNAL(clicked()),this,SLOT(accept()));
+ pButtonLayout->addWidget(pOkButton);
+}
+
+void StickyDialog::add()
+{
+ QString startDirectory;
+
+ if (QFile(defaultDirectory_).exists())
+ {
+ startDirectory = defaultDirectory_;
+ }
+ else
+ {
+ startDirectory = "/home/user/";
+ qDebug () << "default save directory not found";
+ }
+
+
+ QString filename = QFileDialog::getOpenFileName(this,tr("KitchenAlert - Choose a timer to add to stickied"),startDirectory,tr("KitchenAlert timer files (*.kitchenalert)"));
+
+ if (filename.isEmpty()) // user cancelled the dialog
+ return;
+
+
+ QStringList tempList = pStickiesModel_->stringList();
+ tempList.append(filename);
+ pStickiesModel_->setStringList(tempList);
+
+}
+
+void StickyDialog::remove()
+{
+ QItemSelectionModel* pSelected = pStickiesView_->selectionModel();
+ QModelIndex index = pSelected->currentIndex(); //Only single selection allowed, so we only need to care about current item
+
+
+ if (!index.isValid())
+ return; //Nothing selected, nothing to remove...
+
+ pStickiesModel_->removeRows(index.row(),1);
+
+}
+
+QStringList StickyDialog::getStickyList()
+{
+ return pStickiesModel_->stringList();
+}
--- /dev/null
+#ifndef STICKYDIALOG_H
+#define STICKYDIALOG_H
+
+#include <QDialog>
+#include <QListView>
+#include <QStringListModel>
+
+class StickyDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit StickyDialog(QString defaultDirectory, QWidget *parent = 0);
+
+ QStringList getStickyList();
+
+
+signals:
+
+public slots:
+
+ void add();
+ void remove();
+
+protected:
+
+ QListView * pStickiesView_;
+ QStringListModel * pStickiesModel_;
+
+ QString defaultDirectory_;
+
+
+
+};
+
+#endif // STICKYDIALOG_H
connect(&_actualTimer, SIGNAL(timeout()), this, SLOT(secondPassed()));
alerting_ = false;
+
+ _remainingTime = 0; //Same as when stopped
}
return true;
}
-QString Timer::getFilename()
-{
- return filenameWithPath_;
-}
+//QString Timer::getFilename()
+//{
+// return filenameWithPath_;
+//}