plugin.cpp 2.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
    Copyright 2014-2015 Harald Sitter <sitter@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) version 3, or any
    later version accepted by the membership of KDE e.V. (or its
    successor approved by the membership of KDE e.V.), which shall
    act as a proxy defined in Section 6 of version 3 of the license.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/

Harald Sitter's avatar
Harald Sitter committed
21
22
#include "plugin.h"

23
#include <QQmlEngine>
Harald Sitter's avatar
Harald Sitter committed
24
25

#include "pulseaudio.h"
26
#include "client.h"
27
28
#include "sink.h"
#include "source.h"
David Rosca's avatar
David Rosca committed
29
#include "context.h"
30
#include "modulemanager.h"
31
#include "profile.h"
Nicolas Fella's avatar
Nicolas Fella committed
32
#include "port.h"
33
34

#include "globalactioncollection.h"
35
#include "volumeosd.h"
36
#include "volumefeedback.h"
37

David Rosca's avatar
David Rosca committed
38
39
40
41
42
43
44
45
46
47
48
static QJSValue pulseaudio_singleton(QQmlEngine *engine, QJSEngine *scriptEngine)
{
    Q_UNUSED(engine)

    QJSValue object = scriptEngine->newObject();
    object.setProperty(QStringLiteral("NormalVolume"), (double) QPulseAudio::Context::NormalVolume);
    object.setProperty(QStringLiteral("MinimalVolume"), (double) QPulseAudio::Context::MinimalVolume);
    object.setProperty(QStringLiteral("MaximalVolume"), (double) QPulseAudio::Context::MaximalVolume);
    return object;
}

Harald Sitter's avatar
Harald Sitter committed
49
50
void Plugin::registerTypes(const char* uri)
{
51
52
53
54
    qmlRegisterType<QPulseAudio::CardModel>(uri, 0, 1, "CardModel");
    qmlRegisterType<QPulseAudio::SinkModel>(uri, 0, 1, "SinkModel");
    qmlRegisterType<QPulseAudio::SinkInputModel>(uri, 0, 1, "SinkInputModel");
    qmlRegisterType<QPulseAudio::SourceModel>(uri, 0, 1, "SourceModel");
55
    qmlRegisterType<QPulseAudio::ModuleManager>(uri, 0, 1, "ModuleManager");
56
    qmlRegisterType<QPulseAudio::SourceOutputModel>(uri, 0, 1, "SourceOutputModel");
57
    qmlRegisterType<QPulseAudio::StreamRestoreModel>(uri, 0, 1, "StreamRestoreModel");
58
    qmlRegisterType<QPulseAudio::ModuleModel>(uri, 0, 1, "ModuleModel");
59
    qmlRegisterUncreatableType<QPulseAudio::Profile>(uri, 0, 1, "Profile", QString());
Nicolas Fella's avatar
Nicolas Fella committed
60
    qmlRegisterUncreatableType<QPulseAudio::Port>(uri, 0, 1, "Port", QString());
61
62
    qmlRegisterType<GlobalAction>(uri, 0, 1, "GlobalAction");
    qmlRegisterType<GlobalActionCollection>(uri, 0, 1, "GlobalActionCollection");
63
    qmlRegisterType<VolumeOSD>(uri, 0, 1, "VolumeOSD");
64
    qmlRegisterType<VolumeFeedback>(uri, 0, 1, "VolumeFeedback");
David Rosca's avatar
David Rosca committed
65
    qmlRegisterSingletonType(uri, 0, 1, "PulseAudio", pulseaudio_singleton);
66

67
    qmlRegisterType<QPulseAudio::Client>();
68
69
    qmlRegisterType<QPulseAudio::Sink>();
    qmlRegisterType<QPulseAudio::Source>();
Harald Sitter's avatar
Harald Sitter committed
70
}