diff --git a/.vscode/settings.json b/.vscode/settings.json index 85c440e0..0cdd263b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "conventionalCommits.scopes": ["kcm", "kwinscript"] + "conventionalCommits.scopes": ["kcm", "kwinscript", "core"] } diff --git a/.vscode/settings.json.license b/.vscode/settings.json.license deleted file mode 100644 index 872cb50c..00000000 --- a/.vscode/settings.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: none - -SPDX-License-Identifier: MIT \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d470308..5af8d290 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ # SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin # SPDX-License-Identifier: MIT +add_subdirectory(core) add_subdirectory(kcm) add_subdirectory(kwinscript) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 00000000..74960422 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +# SPDX-License-Identifier: MIT + +project(bismuth-core) + +add_library(bismuth_core SHARED) + +target_sources( + bismuth_core + PRIVATE + qml-plugin.cpp + qmldir +) + +target_link_libraries( + bismuth_core + PRIVATE + Qt5::Core + Qt5::Quick + Qt5::Qml +) + +install( + FILES "qmldir" + DESTINATION "${KDE_INSTALL_QMLDIR}/org/kde/bismuth/core" +) + +install( + TARGETS bismuth_core + DESTINATION "${KDE_INSTALL_QMLDIR}/org/kde/bismuth/core" +) + diff --git a/src/core/config.hpp b/src/core/config.hpp new file mode 100644 index 00000000..46a7ad5a --- /dev/null +++ b/src/core/config.hpp @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// SPDX-License-Identifier: MIT + +namespace Bismuth +{ +struct Config { +}; +} diff --git a/src/core/qml-plugin.cpp b/src/core/qml-plugin.cpp new file mode 100644 index 00000000..0e4069ac --- /dev/null +++ b/src/core/qml-plugin.cpp @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// SPDX-License-Identifier: MIT + +#include "qml-plugin.hpp" + +void CorePlugin::registerTypes(const char *uri) +{ + Q_ASSERT(uri == QLatin1String("org.kde.bismuth.core")); + qmlRegisterModule(uri, 1, 0); + + qmlRegisterType(uri, 1, 0, "Core"); +} + +Core::Core(QQuickItem *parent) + : QQuickItem(parent) + , m_kwinApi() + , m_qmlElements() + , m_config() +{ +} + +void Core::start() +{ +} + +QJSValue Core::kwinApi() +{ + return m_kwinApi; +}; + +void Core::setKwinApi(const QJSValue &kwinApi) +{ + m_kwinApi = kwinApi; +}; + +QJSValue Core::qmlElements() +{ + return m_kwinApi; +} + +void Core::setQmlElements(const QJSValue &qmlElements) +{ + m_qmlElements = qmlElements; +}; diff --git a/src/core/qml-plugin.hpp b/src/core/qml-plugin.hpp new file mode 100644 index 00000000..193f6814 --- /dev/null +++ b/src/core/qml-plugin.hpp @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// SPDX-License-Identifier: MIT + +#include +#include +#include +#include +#include + +#include + +#include "config.hpp" + +class CorePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) + +public: + void registerTypes(const char *uri) override; +}; + +class Core : public QQuickItem +{ + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(QJSValue kwinApi READ kwinApi WRITE setKwinApi) + Q_PROPERTY(QJSValue qmlElements READ qmlElements WRITE setQmlElements) + +public: + Core(QQuickItem *parent = nullptr); + + Q_INVOKABLE void start(); + + QJSValue kwinApi(); + void setKwinApi(const QJSValue &); + + QJSValue qmlElements(); + void setQmlElements(const QJSValue &); + +private: + QJSValue m_kwinApi; + QJSValue m_qmlElements; + + std::unique_ptr m_config; +}; diff --git a/src/core/qmldir b/src/core/qmldir new file mode 100644 index 00000000..b4e411e7 --- /dev/null +++ b/src/core/qmldir @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +# SPDX-License-Identifier: MIT + +module org.kde.bismuth.core + +# Plugin name is the name of the library in the CMakeLists.txt +plugin bismuth_core +classname CorePlugin diff --git a/src/kwinscript/ui/main.qml b/src/kwinscript/ui/main.qml index 28ea40b8..254e12f4 100644 --- a/src/kwinscript/ui/main.qml +++ b/src/kwinscript/ui/main.qml @@ -4,6 +4,7 @@ import "../code/index.mjs" as Bismuth import QtQuick 2.0 +import org.kde.bismuth.core 1.0 as BiCore import org.kde.kwin 2.0 import org.kde.taskmanager 0.1 as TaskManager @@ -26,12 +27,20 @@ Item { "KWin": KWin }; scriptRoot.controller = Bismuth.init(qmlObjects, kwinScriptingAPI); + // Init core + core.kwinApi = kwinScriptingAPI; + core.qmlElements = qmlObjects; + core.start(); } Component.onDestruction: { console.log("[Bismuth] Everybody is dead"); scriptRoot.controller.drop(); } + BiCore.Core { + id: core + } + TrayItem { id: trayItem }