diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(declarativeplugin) + include_directories(${PULSEAUDIO_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR}) set(cpp_SRCS diff --git a/src/declarativeplugin/CMakeLists.txt b/src/declarativeplugin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/declarativeplugin/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories(${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/..) + +set(pulseaudioqt-declarative_SRC declarativeplugin.cpp) +add_library(pulseaudioqt-declarative SHARED ${pulseaudioqt-declarative_SRC}) +target_link_libraries(pulseaudioqt-declarative Qt5::Qml KF5PulseAudioQt) +install(TARGETS pulseaudioqt-declarative DESTINATION ${QML_INSTALL_DIR}/org/kde/pulseaudioqt) +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/pulseaudioqt) diff --git a/src/declarativeplugin/declarativeplugin.h b/src/declarativeplugin/declarativeplugin.h new file mode 100644 --- /dev/null +++ b/src/declarativeplugin/declarativeplugin.h @@ -0,0 +1,35 @@ +/* + Copyright 2018 Nicolas Fella + + 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 . +*/ + +#ifndef DECLARATIVEPLUGIN_H +#define DECLARATIVEPLUGIN_H + +#include + +class PulseAudioQtDeclarativePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") +public: + void registerTypes(const char * uri) override; +}; + +#endif // DECLARATIVEPLUGIN_H + diff --git a/src/declarativeplugin/declarativeplugin.cpp b/src/declarativeplugin/declarativeplugin.cpp new file mode 100644 --- /dev/null +++ b/src/declarativeplugin/declarativeplugin.cpp @@ -0,0 +1,48 @@ +/* + Copyright 2018 Nicolas Fella + + 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 "declarativeplugin.h" + +#include + +#include "../client.h" +#include "../sink.h" +#include "../source.h" +#include "../context.h" +#include "../profile.h" +#include "../port.h" +#include "../models.h" + +void PulseAudioQtDeclarativePlugin::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, "SourceOutputModel"); + qmlRegisterType(uri, 0, 1, "StreamRestoreModel"); + qmlRegisterType(uri, 0, 1, "ModuleModel"); + qmlRegisterUncreatableType(uri, 0, 1, "Profile", QString()); + qmlRegisterUncreatableType(uri, 0, 1, "Port", QString()); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); +} + diff --git a/src/declarativeplugin/qmldir b/src/declarativeplugin/qmldir new file mode 100644 --- /dev/null +++ b/src/declarativeplugin/qmldir @@ -0,0 +1,2 @@ +module org.kde.pulseaudioqt +plugin pulseaudioqt-declarative