+++ /dev/null
-/*
- * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
- *
- * This file is part of ConfClerk.
- *
- * ConfClerk 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 2 of the License, or (at your option)
- * any later version.
- *
- * ConfClerk 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
- * ConfClerk. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "alarmdialog.h"
-#include <conference.h>
-
-#include <QApplication>
-#include <alarm.h>
-#include <event.h>
-
-#include <QDir>
-#include <QProcess>
-
-const int SNOOZE_TIME = 5; // in minutes
-
-AlarmDialog::AlarmDialog(int argc, char *argv[], QWidget *aParent)
- : QDialog(aParent)
- , mEventId(0)
- , mAlarmId(0)
-{
- setupUi(this);
-
- if(argc<3)
- {
- // not enough arguments passed to the dialog
- // Usage: $ ./dialog eventId alarmId
- // Example: $ ./dialog 521 13
- //
- // TODO: handle this case
- }
- else
- {
- mEventId = QString(argv[1]).toInt();
- mAlarmId = QString(argv[2]).toInt();
- }
-
- connect(stopPB, SIGNAL(clicked()), SLOT(closeDialog()));
- connect(appPB, SIGNAL(clicked()), SLOT(runApp()));
- connect(snoozePB, SIGNAL(clicked()), SLOT(snooze()));
-
- qString databaseFileName;
- databaseFileName = QDesktopServices::storageLocation(QDesktopServices::DataLocation + "/ConfClerk.sqlite"
- // TODO: check existence
- QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
- database.setDatabaseName(databaseFileName);
- database.open();
-
- QString titleStr;
- QString messageStr;
- QString timeStr;
- QString personsStr;
- QString roomStr;
- try
- {
- Event event = Event::getById(mEventId,Conference::activeConference());
- titleStr = "Event alarm";
- messageStr = event.title();
- timeStr = event.start().toString("hh:mm") + "-" + event.start().addSecs(event.duration()).toString("hh:mm");
- personsStr = event.persons().join(" and ");
- roomStr = event.room();
- }
- catch(OrmNoObjectException&)
- {
- titleStr = QString("ERROR");
- messageStr = QString("No such event in the DB: %1").arg(QString::number(mEventId));
- }
- catch(...) {} // TODO: implement
- message->setText(messageStr);
- setWindowTitle(titleStr);
- time->setText(timeStr);
- persons->setText(personsStr);
- room->setText(roomStr);
-}
-
-void AlarmDialog::runApp()
-{
- QString program = QDir::currentPath() + "/" + *qApp->argv();
- QProcess::startDetached(program,QStringList()<<QString::number(mEventId));
- closeDialog();
-}
-
-void AlarmDialog::snooze()
-{
- if(mEventId==0) // not valid event ID
- return;
-
- Alarm alarm;
- alarm.addAlarm(mEventId,QDateTime::currentDateTime().addSecs(60*SNOOZE_TIME));
- qApp->quit();
-}
-
-void AlarmDialog::closeDialog()
-{
- // before closing the dialog, it is necessary to remove alarm flag from the DB
- try
- {
- Event event = Event::getById(mEventId,Conference::activeConference());
- event.setHasAlarm(false);
- event.update("alarm");
- }
- catch(OrmNoObjectException &) {} // TODO: implement
- catch(...) {} // just close dialog
- qApp->quit();
-}
-
+++ /dev/null
-/*
- * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
- *
- * This file is part of ConfClerk.
- *
- * ConfClerk 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 2 of the License, or (at your option)
- * any later version.
- *
- * ConfClerk 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
- * ConfClerk. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef ALARMDIALOG_H
-#define ALARMDIALOG_H
-
-#include <QDialog>
-#include "ui_alarmdialog.h"
-
-class AlarmDialog : public QDialog, Ui::AlarmDialog
-{
- Q_OBJECT
- public:
- AlarmDialog(int argc, char *argv[], QWidget *aParent = NULL);
- ~AlarmDialog() {}
- private slots:
- void runApp();
- void snooze();
- void closeDialog();
- private:
- int mEventId; // event ID obtained from 'schedule'
- int mAlarmId; // cookie assigned by alarmd
-};
-
-#endif /* ALARMDIALOG_H */
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AlarmDialog</class>
- <widget class="QDialog" name="AlarmDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>406</width>
- <height>176</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="2" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="message">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Alarm message goes here</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="../../data/data.qrc">:/confclerk.svg</pixmap>
- </property>
- <property name="scaledContents">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="1">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Time:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Presenter(s):</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Room:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QLabel" name="persons">
- <property name="text">
- <string>PRESETNER(S)</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QLabel" name="time">
- <property name="text">
- <string>TIME</string>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="QLabel" name="room">
- <property name="text">
- <string>ROOM</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="appPB">
- <property name="text">
- <string>App</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="snoozePB">
- <property name="text">
- <string>Snooze</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="stopPB">
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="../icons.qrc"/>
- <include location="../../data/data.qrc"/>
- </resources>
- <connections/>
-</ui>