File indexing completed on 2024-04-28 15:29:12

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2014 Martin Klapetek <mklapetek@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef NOTIFYBYAUDIO_H
0009 #define NOTIFYBYAUDIO_H
0010 
0011 #include "knotificationplugin.h"
0012 
0013 #include <phonon/MediaObject>
0014 
0015 namespace Phonon
0016 {
0017 // class MediaObject;
0018 class MediaSource;
0019 class AudioOutput;
0020 }
0021 
0022 class KNotification;
0023 
0024 class NotifyByAudio : public KNotificationPlugin
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     explicit NotifyByAudio(QObject *parent = nullptr);
0030     ~NotifyByAudio() override;
0031 
0032     QString optionName() override
0033     {
0034         return QStringLiteral("Sound");
0035     }
0036     void notify(KNotification *notification, KNotifyConfig *config) override;
0037     void close(KNotification *notification) override;
0038 
0039 private Q_SLOTS:
0040     void onAudioFinished();
0041     void onAudioSourceChanged(const Phonon::MediaSource &source);
0042     void stateChanged(Phonon::State newState, Phonon::State oldState);
0043 
0044 private:
0045     void finishNotification(KNotification *notification, Phonon::MediaObject *m);
0046 
0047     QList<Phonon::MediaObject *> m_reusablePhonons;
0048     QHash<Phonon::MediaObject *, KNotification *> m_notifications;
0049     Phonon::AudioOutput *m_audioOutput;
0050 };
0051 
0052 #endif