Changeset View
Changeset View
Standalone View
Standalone View
plugins/systemvolume/profile.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | ||||
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 | #ifndef PROFILE_H | ||||
22 | #define PROFILE_H | ||||
23 | | ||||
24 | #include <QObject> | ||||
25 | #include <QString> | ||||
26 | | ||||
27 | namespace QPulseAudio | ||||
28 | { | ||||
29 | | ||||
30 | class Profile : public QObject | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) | ||||
34 | Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) | ||||
35 | Q_PROPERTY(quint32 priority READ priority NOTIFY priorityChanged) | ||||
36 | public: | ||||
37 | Profile(QObject *parent); | ||||
38 | virtual ~Profile(); | ||||
39 | | ||||
40 | template<typename PAInfo> | ||||
41 | void setInfo(const PAInfo *info) | ||||
42 | { | ||||
43 | // Description is optional. Name not so much as we need some ID. | ||||
44 | Q_ASSERT(info->name); | ||||
45 | QString infoName = QString::fromUtf8(info->name); | ||||
46 | if (m_name != infoName) { | ||||
47 | m_name = infoName; | ||||
48 | emit nameChanged(); | ||||
49 | } | ||||
50 | if (info->description) { | ||||
51 | QString infoDescription = QString::fromUtf8(info->description); | ||||
52 | if (m_description != infoDescription) { | ||||
53 | m_description = infoDescription; | ||||
54 | emit descriptionChanged(); | ||||
55 | } | ||||
56 | } | ||||
57 | if (m_priority != info->priority) { | ||||
58 | m_priority = info->priority; | ||||
59 | emit priorityChanged(); | ||||
60 | } | ||||
61 | } | ||||
62 | | ||||
63 | QString name() const; | ||||
64 | QString description() const; | ||||
65 | quint32 priority() const; | ||||
66 | | ||||
67 | signals: | ||||
68 | void nameChanged(); | ||||
69 | void descriptionChanged(); | ||||
70 | void priorityChanged(); | ||||
71 | | ||||
72 | private: | ||||
73 | QString m_name; | ||||
74 | QString m_description; | ||||
75 | quint32 m_priority; | ||||
76 | }; | ||||
77 | | ||||
78 | } // QPulseAudio | ||||
79 | | ||||
80 | #endif // PROFILE_H |