diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02158a9..0c6268b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,16 +1,17 @@ add_subdirectory(core) +add_subdirectory(imports) add_subdirectory(plugins) add_subdirectory(widgets) install( EXPORT AtCoreTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE AtCoreTargets.cmake NAMESPACE AtCore:: COMPONENT Devel ) diff --git a/src/imports/CMakeLists.txt b/src/imports/CMakeLists.txt new file mode 100644 index 0000000..c95100b --- /dev/null +++ b/src/imports/CMakeLists.txt @@ -0,0 +1,26 @@ +project(atcore-imports) +include_directories ( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set ( + atcore_qml_bridge_LIB_SRCS + atcoreextensionplugin.cpp +) + +find_package(Qt5 REQUIRED COMPONENTS + Qml +) + +add_library(atcoreextensionplugin SHARED ${atcore_qml_bridge_LIB_SRCS}) + +target_link_libraries ( + atcoreextensionplugin + AtCore + Qt5::Core + Qt5::Qml +) + +install(TARGETS atcoreextensionplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/atcore) +install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/atcore) diff --git a/src/imports/atcoreextensionplugin.cpp b/src/imports/atcoreextensionplugin.cpp new file mode 100644 index 0000000..22c91ec --- /dev/null +++ b/src/imports/atcoreextensionplugin.cpp @@ -0,0 +1,35 @@ +/* AtCore Imports + Copyright (C) <2019> + + Authors: + Lays Rodrigues + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 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 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 "atcoreextensionplugin.h" +#include +#include +#include +#include + +void AtCoreExtensionPlugin::registerTypes(const char *uri) +{ + Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.atcore")); + qmlRegisterType("org.kde.atcore", 1, 0, "AtCore"); + qmlRegisterType("org.kde.atcore", 1, 0, "Temperature"); + qmlRegisterSingletonType("org.kde.atcore", 1, 0, "MachineInfo", [](QQmlEngine *engine, QJSEngine *jsEngine) -> QObject * { + return MachineInfo::instance()->qmlSingletonRegister(engine, jsEngine); + }); +} diff --git a/src/imports/atcoreextensionplugin.h b/src/imports/atcoreextensionplugin.h new file mode 100644 index 0000000..37d5936 --- /dev/null +++ b/src/imports/atcoreextensionplugin.h @@ -0,0 +1,30 @@ +/* AtCore Imports + Copyright (C) <2019> + + Authors: + Lays Rodrigues + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 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 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 . +*/ + +#pragma once +#include + +class AtCoreExtensionPlugin : public QQmlExtensionPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.kde.atcore") + +public: + void registerTypes(const char *uri) override; +}; diff --git a/src/imports/qmldir b/src/imports/qmldir new file mode 100644 index 0000000..0d1b990 --- /dev/null +++ b/src/imports/qmldir @@ -0,0 +1,2 @@ +module org.kde.atcore +plugin atcoreextensionplugin