Skip to content

A hardened Linux desktop, rebuilt from scratch, with your Windows apps built in. Free and open source.

1001 B
Raw Blame
#pragma once

#include <QHash>
#include <QObject>
#include <QtQml/qqmlregistration.h>

// New mail notifications through the desktop's notification server, with
// Mark as read, Archive and a reply typed right in the notification
// (MailCalMsNotify). Choosing the notification itself opens the message.
class Notifier : public QObject
{
    Q_OBJECT
    QML_ELEMENT
    QML_SINGLETON

    Q_PROPERTY(bool enabled MEMBER m_enabled NOTIFY enabledChanged)

public:
    explicit Notifier(QObject *parent = nullptr);

Q_SIGNALS:
    void enabledChanged();
    void openRequested(const QString &key);

private Q_SLOTS:
    void onNewMail(const QString &key, const QString &from, const QString &subject, const QString &preview);
    void onAction(uint id, const QString &action);
    void onReplied(uint id, const QString &text);
    void onClosed(uint id, uint reason);

private:
    void quickReply(const QString &key, const QString &text);

    QHash<uint, QString> m_keys;
    bool m_enabled = true;
};