diff --git a/src/qml/plugin.cpp b/src/qml/plugin.cpp index 7806f64..d718c82 100644 --- a/src/qml/plugin.cpp +++ b/src/qml/plugin.cpp @@ -1,77 +1,82 @@ /* Copyright 2014-2015 Harald Sitter 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 . */ #include "plugin.h" #include #include "pulseaudio.h" #include "client.h" #include "sink.h" #include "source.h" #include "context.h" #include "modulemanager.h" #include "profile.h" #include "port.h" #include "globalactioncollection.h" #include "microphoneindicator.h" #include "volumeosd.h" #include "volumefeedback.h" 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; } void Plugin::registerTypes(const char* uri) { qmlRegisterType(uri, 0, 1, "CardModel"); qmlRegisterType(uri, 0, 1, "SinkModel"); qmlRegisterType(uri, 0, 1, "SinkInputModel"); qmlRegisterType(uri, 0, 1, "SourceModel"); qmlRegisterType(uri, 0, 1, "ModuleManager"); qmlRegisterType(uri, 0, 1, "SourceOutputModel"); qmlRegisterType(uri, 0, 1, "StreamRestoreModel"); qmlRegisterType(uri, 0, 1, "ModuleModel"); qmlRegisterUncreatableType(uri, 0, 1, "Profile", QString()); qmlRegisterUncreatableType(uri, 0, 1, "Port", QString()); qmlRegisterType(uri, 0, 1, "GlobalAction"); qmlRegisterType(uri, 0, 1, "GlobalActionCollection"); qmlRegisterType(uri, 0, 1, "VolumeOSD"); qmlRegisterType(uri, 0, 1, "VolumeFeedback"); qmlRegisterSingletonType(uri, 0, 1, "PulseAudio", pulseaudio_singleton); qmlRegisterSingletonType(uri, 0, 1, "MicrophoneIndicator", [](QQmlEngine *engine, QJSEngine *jsEngine) -> QObject* { Q_UNUSED(engine); Q_UNUSED(jsEngine); return new MicrophoneIndicator(); }); - +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) qmlRegisterType(); qmlRegisterType(); qmlRegisterType(); +#else + qmlRegisterAnonymousType(uri, 1); + qmlRegisterAnonymousType(uri, 1); + qmlRegisterAnonymousType(uri, 1); +#endif }