summaryrefslogtreecommitdiffstats
path: root/src/PulseAudioQt/profile_p.h
blob: 7fa1f9d90184cd356d6a482d688c7779b8a1d536 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
    SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#pragma once

#include "profile.h"
#include "pulseobject_p.h"

namespace PulseAudioQt
{
class ProfilePrivate
{
public:
    explicit ProfilePrivate(Profile *q);
    virtual ~ProfilePrivate();

    Profile *q;

    QString m_description;
    quint32 m_priority = 0;
    quint32 m_sources = 0;
    quint32 m_sinks = 0;
    Profile::Availability m_availability = Profile::Unknown;

    template<typename PAInfo>
    void setInfo(const PAInfo *info)
    {
        setCommonInfo(info, info->available ? Profile::Available : Profile::Unavailable);
        m_sources = info->n_sources;
        m_sinks = info->n_sinks;
    }

    template<typename PAInfo>
    void setCommonInfo(const PAInfo *info, Profile::Availability newAvailability)
    {
        if (info->description) {
            QString infoDescription = QString::fromUtf8(info->description);
            if (m_description != infoDescription) {
                m_description = infoDescription;
                Q_EMIT q->descriptionChanged();
            }
        }
        if (m_priority != info->priority) {
            m_priority = info->priority;
            Q_EMIT q->priorityChanged();
        }

        if (m_availability != newAvailability) {
            m_availability = newAvailability;
            Q_EMIT q->availabilityChanged();
        }

        q->PulseObject::d->updatePulseObject(info);
    }
};
}