File indexing completed on 2024-12-08 08:02:45
0001 /* 0002 SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de> 0003 SPDX-FileCopyrightText: 2020 MBition GmbH 0004 Author: Kai Uwe Broulik <kai_uwe.broulik@mbition.io> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #pragma once 0010 0011 #include <QList> 0012 #include <QObject> 0013 #include <QPersistentModelIndex> 0014 #include <QPointer> 0015 0016 class QAction; 0017 class QTimer; 0018 0019 class KStatusNotifierItem; 0020 0021 class VolumeOSD; 0022 0023 namespace QPulseAudio 0024 { 0025 class Source; 0026 class SourceModel; 0027 class SourceOutputModel; 0028 } 0029 0030 class MicrophoneIndicator : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 explicit MicrophoneIndicator(QObject *parent = nullptr); 0036 ~MicrophoneIndicator() override; 0037 0038 Q_INVOKABLE void init(); 0039 0040 Q_SIGNALS: 0041 void enabledChanged(); 0042 0043 private: 0044 void scheduleUpdate(); 0045 void update(); 0046 0047 bool muted() const; 0048 void setMuted(bool muted); 0049 void toggleMuted(); 0050 0051 void adjustVolume(int direction); 0052 0053 static int volumePercent(QPulseAudio::Source *source); 0054 void showOsd(); 0055 0056 QList<QModelIndex> recordingApplications() const; 0057 QString toolTipForApps(const QList<QModelIndex> &apps) const; 0058 QString sourceOutputDisplayName(const QModelIndex &idx) const; 0059 0060 QPulseAudio::SourceModel *const m_sourceModel = nullptr; // microphone devices 0061 QPulseAudio::SourceOutputModel *const m_sourceOutputModel = nullptr; // recording streams 0062 0063 KStatusNotifierItem *m_sni = nullptr; 0064 QPointer<QAction> m_muteAction; 0065 QPointer<QAction> m_dontAgainAction; 0066 0067 QList<QPersistentModelIndex> m_mutedIndices; 0068 0069 VolumeOSD *m_osd = nullptr; 0070 bool m_showOsdOnUpdate = false; 0071 0072 int m_wheelDelta = 0; 0073 0074 QTimer *const m_updateTimer; 0075 };