Changeset 3a09de6 in confclerk_git for src/gui/mainwindow.cpp


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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.