#ifndef STRAWBERRY_APP_NOTIFIER_HPP #define STRAWBERRY_APP_NOTIFIER_HPP #include #include #include class QSystemTrayIcon; namespace strawberry::app { /** * @brief Desktop notifications. Linux: org.freedesktop.Notifications (mako, * dunst, swaync, ...). Other platforms: tray icon messages * (notifier_tray.cpp). Clicking a finding notification emits activated(). */ class Notifier : public QObject { Q_OBJECT public: enum class Urgency : unsigned char { low = 0, normal = 1, critical = 2 }; explicit Notifier(QObject* parent = nullptr); /// `finding_id` may be empty for informational messages. void notify(const QString& summary, const QString& body, Urgency urgency, const QString& finding_id = {}); /// Tray icon used for messages where there is no notification bus. May be /// null (--no-tray); ignored on Linux. void attach_tray_icon(QSystemTrayIcon* icon); signals: void activated(const QString& finding_id); private slots: void on_action_invoked(uint id, const QString& action_key); void on_closed(uint id, uint reason); private: QHash finding_by_notification_; QSystemTrayIcon* tray_icon_ = nullptr; QString pending_finding_; // tray message: the last one shown wins }; } // namespace strawberry::app #endif // STRAWBERRY_APP_NOTIFIER_HPP