Changeset 3a09de6 in confclerk_git


Ignore:
Timestamp:
04/16/13 22:52:25 (9 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
e619be9
Parents:
097e1f4
Message:

Alarms are reported via QSystemTray now (see ticket #46).

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/alarm/alarm.h

    r097e1f4 r3a09de6  
    3030
    3131#define APPID "confclerk-alarm"
    32 const int PRE_EVENT_ALARM_SEC = -15*60; // alarm goes off 15 minutes before start of event
    3332
    3433class Alarm : public QObject
  • src/app/appsettings.h

    r097e1f4 r3a09de6  
    4141        static void setProxyPort(const quint16 aPort);
    4242        static void setDirectConnection(bool aDirectConnection);
     43        static int preEventAlarmSec() {return 60*15;} ///< seconds that alarm should ring before an event starts
    4344};
    4445
  • src/gui/eventdialog.cpp

    r097e1f4 r3a09de6  
    113113        // add alarm to the 'alarmd'
    114114        Alarm alarm;
    115         alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(PRE_EVENT_ALARM_SEC));
     115        alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(-AppSettings::preEventAlarmSec()));
    116116#endif /* MAEMO */
    117117    }
  • src/gui/mainwindow.cpp

    r097e1f4 r3a09de6  
    3131#include "eventmodel.h"
    3232#include "delegate.h"
     33#include "room.h"
    3334
    3435#include "conference.h"
     
    107108    // systm tray icon
    108109    connect(systemTrayIcon, SIGNAL(messageClicked()), SLOT(onSystemTrayMessageClicked()));
     110    connect(systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(onSystemTrayMessageClicked()));
    109111
    110112    // timer
     
    218220
    219221void MainWindow::onSystemTrayMessageClicked() {
    220     // TODO: Hide icon
    221     // systemTrayIcon->hide();
     222    systemTrayIcon->hide();
    222223}
    223224
    224225
    225226void MainWindow::onAlarmTimerTimeout() {
    226     // TODO: Show Message if an alarm is set on an event that's starting soon and delete the corresponding alarm.
    227     /*
     227    // determine if an alarm is set on an event that's starting soon
     228    QList<Event> events = Event::getImminentAlarmEvents(AppSettings::preEventAlarmSec(), Conference::activeConference());
     229    if (events.empty()) return;
     230
     231    // build a message string
     232    Event event;
     233    QString title;
     234    QString message;
     235    if (events.size() == 1) {
     236        event = events.first();
     237        title = tr("Next event at %1").arg(event.start().toString());
     238        message = tr("Title: %1\nRoom: %2").arg(event.title()).arg(event.room()->name());
     239    } else {
     240        title = tr("%1 upcoming events").arg(events.size());
     241        QStringList messages;
     242        foreach (event, events) {
     243            messages += tr("Start: %1; Title: %2; Room: %3").arg(event.start().toString()).arg(event.title()).arg(event.room()->name());
     244        }
     245        message = messages.join("\n");
     246    }
     247
     248    // and delete the corresponding alarm
     249    foreach (event, events) {
     250        event.setHasAlarm(false);
     251        event.update("alarm");
     252        onEventChanged(event.id(), false);
     253    }
     254
     255    // show message
    228256    systemTrayIcon->show();
    229     qDebug() << systemTrayIcon->geometry(); // gets moved to the correct location only at second usage. at least under X11/awesome, not on Win32/XP
    230     systemTrayIcon->showMessage("title", "message", QSystemTrayIcon::Information, 1000);
     257    // The next two lines are to prevent a very strange position of the message box the first time at X11/aweseome (not Win32/XP)
     258    systemTrayIcon->showMessage("ConfClerk", "Your upcoming events", QSystemTrayIcon::Information);
     259    qApp->processEvents();
     260    systemTrayIcon->showMessage(title, message, QSystemTrayIcon::Information, 60*60*24*1000);
    231261    QApplication::alert(this);
    232262    QApplication::beep();
    233     */
    234263}
    235264
  • src/mvc/event.cpp

    r097e1f4 r3a09de6  
    9595
    9696
     97QList<Event> Event::getImminentAlarmEvents(int maxSecToAlarm, int conferenceId) {
     98    QSqlQuery query;
     99    query.prepare(selectQuery() + "WHERE xid_conference = :conf AND (start < :start AND alarm = 1) ORDER BY start, duration");
     100    query.bindValue(":conf", conferenceId);
     101    query.bindValue(":start", convertToDb(QDateTime::currentDateTime().addSecs(maxSecToAlarm), QVariant::DateTime));
     102    return load(query);
     103}
     104
     105
    97106QList<Event> Event::getFavByDate(const QDate& date, int conferenceId)
    98107{
  • src/mvc/event.h

    r097e1f4 r3a09de6  
    5050    static QList<Event> getByDateAndRoom(const QDate& date, int conferenceId);
    5151    static QList<Event> conflictEvents(int aEventId, int conferenceId);
     52    static QList<Event> getImminentAlarmEvents(int maxSecToAlarm, int conferenceId);
    5253public:
    5354    int id() const { return value("id").toInt(); }
  • src/mvc/treeview.cpp

    r097e1f4 r3a09de6  
    111111                    // add alarm to the 'alarmd'
    112112                    Alarm alarm;
    113                     alarm.addAlarm(event.conferenceId(), event.id(), event.title(),event.start().addSecs(PRE_EVENT_ALARM_SEC));
     113                    alarm.addAlarm(event.conferenceId(), event.id(), event.title(),event.start().addSecs(-AppSettings::preEventAlarmSec()));
    114114#endif /* MAEMO */
    115115                }
Note: See TracChangeset for help on using the changeset viewer.