diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(qmlplugin) + set(kpublictransport_srcs departurereply.cpp departurerequest.cpp diff --git a/src/qmlplugin/CMakeLists.txt b/src/qmlplugin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/qmlplugin/CMakeLists.txt @@ -0,0 +1,12 @@ +set(kpublictransportqmlplugin_SRC + kpublictransportqmlplugin.cpp +) + +add_library(kpublictransportqmlplugin SHARED ${kpublictransportqmlplugin_SRC}) +target_link_libraries(kpublictransportqmlplugin + Qt5::Qml + KPublicTransport +) +install(TARGETS kpublictransportqmlplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kpublictransport) +install(FILES qmldir ${qml_SRC} DESTINATION ${QML_INSTALL_DIR}/org/kde/kpublictransport) + diff --git a/src/qmlplugin/kpublictransportqmlplugin.h b/src/qmlplugin/kpublictransportqmlplugin.h new file mode 100644 --- /dev/null +++ b/src/qmlplugin/kpublictransportqmlplugin.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2019 Nicolas Fella + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program 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 Library General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef KPUBLICTRANSPORTQMLPLUGIN_H +#define KPUBLICTRANSPORTQMLPLUGIN_H + +#include + +class KPublicTransportQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + + void registerTypes(const char* uri) override; +}; + +#endif // KPUBLICTRANSPORTQMLPLUGIN_H + diff --git a/src/qmlplugin/kpublictransportqmlplugin.cpp b/src/qmlplugin/kpublictransportqmlplugin.cpp new file mode 100644 --- /dev/null +++ b/src/qmlplugin/kpublictransportqmlplugin.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2019 Nicolas Fella + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program 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 Library General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#include "kpublictransportqmlplugin.h" + +#include +#include + +#include +#include + +void KPublicTransportQmlPlugin::registerTypes(const char*) +{ + qmlRegisterUncreatableType("org.kde.kpublictransport", 1, 0, "Line", {}); + qmlRegisterUncreatableType("org.kde.kpublictransport", 1, 0, "JourneySection", {}); +} diff --git a/src/qmlplugin/qmldir b/src/qmlplugin/qmldir new file mode 100644 --- /dev/null +++ b/src/qmlplugin/qmldir @@ -0,0 +1,2 @@ +module org.kde.kpublictransport +plugin kpublictransportqmlplugin