Changeset View
Changeset View
Standalone View
Standalone View
src/qml/microphoneindicator.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2019 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include <QObject> | ||||
24 | #include <QPersistentModelIndex> | ||||
25 | #include <QPointer> | ||||
26 | #include <QVector> | ||||
27 | | ||||
28 | class QAction; | ||||
29 | class QTimer; | ||||
30 | | ||||
31 | class KStatusNotifierItem; | ||||
32 | | ||||
33 | class VolumeOSD; | ||||
34 | | ||||
35 | namespace QPulseAudio | ||||
36 | { | ||||
37 | class Source; | ||||
38 | class SourceModel; | ||||
39 | class SourceOutputModel; | ||||
40 | } | ||||
41 | | ||||
42 | class MicrophoneIndicator : public QObject | ||||
43 | { | ||||
44 | Q_OBJECT | ||||
45 | | ||||
46 | public: | ||||
47 | explicit MicrophoneIndicator(QObject *parent = nullptr); | ||||
48 | ~MicrophoneIndicator() override; | ||||
49 | | ||||
50 | Q_INVOKABLE void init(); | ||||
51 | | ||||
52 | Q_SIGNALS: | ||||
53 | void enabledChanged(); | ||||
54 | | ||||
55 | private: | ||||
56 | void scheduleUpdate(); | ||||
57 | void update(); | ||||
58 | | ||||
59 | bool muted() const; | ||||
60 | void setMuted(bool muted); | ||||
61 | void toggleMuted(); | ||||
62 | | ||||
63 | void adjustVolume(int direction); | ||||
64 | | ||||
65 | static int volumePercent(QPulseAudio::Source *source); | ||||
66 | void showOsd(); | ||||
67 | | ||||
68 | QStringList appNames() const; | ||||
69 | | ||||
70 | QPulseAudio::SourceModel *m_sourceModel = nullptr; // microphone devices | ||||
71 | QPulseAudio::SourceOutputModel *m_sourceOutputModel = nullptr; // recording streams | ||||
72 | | ||||
73 | KStatusNotifierItem *m_sni = nullptr; | ||||
74 | QPointer<QAction> m_muteAction; | ||||
75 | QPointer<QAction> m_dontAgainAction; | ||||
76 | | ||||
77 | QVector<QPersistentModelIndex> m_mutedIndices; | ||||
78 | | ||||
79 | VolumeOSD *m_osd = nullptr; | ||||
80 | bool m_showOsdOnUpdate = false; | ||||
81 | | ||||
82 | int m_wheelDelta = 0; | ||||
83 | | ||||
84 | QTimer *m_updateTimer; | ||||
85 | | ||||
86 | }; |