Commit 11ba8dcf authored by Sandro Andrade's avatar Sandro Andrade

Initial plugincontroller implementation and sample plugin

parent 3c74566b
......@@ -31,6 +31,7 @@ ecm_setup_version(${KDE_APPLICATIONS_VERSION} VARIABLE_PREFIX MINUET
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets Quick)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
CoreAddons
I18n
XmlGui
KIO
......
add_subdirectory(interfaces)
add_subdirectory(shell)
add_subdirectory(plugins)
add_subdirectory(app)
......@@ -24,7 +24,7 @@
#include "midisequencer.h"
#include <KI18n/KLocalizedString>
#include <KLocalizedString>
#include <QDir>
#include <QDateTime>
......
......@@ -24,8 +24,8 @@
#include "minuet_version.h"
#include <KCrash/KCrash>
#include <KCoreAddons/KAboutData>
#include <KCrash>
#include <KAboutData>
#include <QCommandLineParser>
......
......@@ -25,8 +25,8 @@
#include "minuetsettings.h"
#include "midisequenceroutputthread.h"
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KMessageBox>
#include <KLocalizedString>
#include <KMessageBox>
#include <QtMath>
#include <QLoggingCategory>
......
......@@ -26,9 +26,9 @@
#include "midisequencer.h"
#include "exercisecontroller.h"
#include <KXmlGui/KActionCollection>
#include <KWidgetsAddons/KMessageBox>
#include <KConfigWidgets/KConfigDialog>
#include <KActionCollection>
#include <KMessageBox>
#include <KConfigDialog>
#include <QQmlEngine>
#include <QQmlContext>
......
......@@ -26,8 +26,8 @@
#include "ui_settingsmidi.h"
#include "minuetsettings.h"
#include <KCoreAddons/KProcess>
#include <KXmlGui/KXmlGuiWindow>
#include <KProcess>
#include <KXmlGuiWindow>
#include <QLoggingCategory>
......
......@@ -24,7 +24,7 @@
#include "minuetsettings.h"
#include <KI18n/KLocalizedString>
#include <KLocalizedString>
#include <QTimer>
#include <QDirIterator>
......
......@@ -35,7 +35,7 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject
Q_OBJECT
public:
IExerciseController(QObject *parent);
explicit IExerciseController(QObject *parent = 0);
~IExerciseController() override;
};
......
......@@ -35,10 +35,12 @@ class MINUETINTERFACES_EXPORT IPlugin : public QObject
Q_OBJECT
public:
IPlugin(QObject *parent);
explicit IPlugin(QObject *parent = 0);
~IPlugin() override;
};
}
Q_DECLARE_INTERFACE(Minuet::IPlugin, "org.kde.minuet.IPlugin")
#endif
......@@ -35,7 +35,7 @@ class MINUETINTERFACES_EXPORT IPluginController : public QObject
Q_OBJECT
public:
IPluginController(QObject *parent);
explicit IPluginController(QObject *parent = 0);
~IPluginController() override;
};
......
......@@ -35,7 +35,7 @@ class MINUETINTERFACES_EXPORT ISoundBackend : public QObject
Q_OBJECT
public:
ISoundBackend(QObject *parent);
explicit ISoundBackend(QObject *parent = 0);
~ISoundBackend() override;
};
......
add_subdirectory(fluidsynthsoundbackend)
set(fluidsynthsoundbackend_PLUGIN_SRCS
fluidsynthsoundbackend.cpp
)
add_library(minuetfluidsynthsoundbackend MODULE ${fluidsynthsoundbackend_PLUGIN_SRCS})
target_link_libraries(minuetfluidsynthsoundbackend
Minuet::Interfaces
)
install(TARGETS minuetfluidsynthsoundbackend DESTINATION ${PLUGIN_INSTALL_DIR}/minuet/)
/****************************************************************************
**
** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
**
** 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 2 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 14 of version 3 of the license.
**
** 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 <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "fluidsynthsoundbackend.h"
FluidSynthSoundBackend::FluidSynthSoundBackend(QObject *parent)
: Minuet::IPlugin(parent)
{
}
FluidSynthSoundBackend::~FluidSynthSoundBackend()
{
}
#include "moc_fluidsynthsoundbackend.cpp"
/****************************************************************************
**
** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
**
** 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 2 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 14 of version 3 of the license.
**
** 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 <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef MINUET_FLUIDSYNTHSOUNDBACKEND_H
#define MINUET_FLUIDSYNTHSOUNDBACKEND_H
#include <interfaces/iplugin.h>
class FluidSynthSoundBackend : public Minuet::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kde.minuet.IPlugin" FILE "fluidsynthsoundbackend.json")
Q_INTERFACES(Minuet::IPlugin)
public:
explicit FluidSynthSoundBackend(QObject *parent = 0);
~FluidSynthSoundBackend() override;
};
#endif
{
"KPlugin": {
"Category": "Sound Backends",
"Description": "This plugin provides Minuet with a FluidSynth-based implementation of sound backend.",
"Icon": "utilities-terminal",
"Id": "minuetfluidsynthsoundbackend",
"Name": "FluidSynth-based Audio Backend",
"ServiceTypes": [
"Minuet/Plugin"
]
}
}
......@@ -11,6 +11,7 @@ generate_export_header(minuetshell EXPORT_FILE_NAME minuetshellexport.h)
target_link_libraries(minuetshell
Minuet::Interfaces
KF5::CoreAddons
)
install(TARGETS
......
......@@ -38,6 +38,7 @@ bool Core::initialize()
return true;
m_self = new Core;
return true;
}
......@@ -62,6 +63,7 @@ Core::Core(QObject *parent)
m_exerciseController(new ExerciseController)
{
((PluginController *)m_pluginController.data())->initialize();
}
}
......
......@@ -22,17 +22,47 @@
#include "plugincontroller.h"
#include <KPluginLoader>
#include <interfaces/iplugin.h>
#include <QDebug>
namespace Minuet
{
PluginController::PluginController(QObject *parent)
: IPluginController(parent)
{
m_plugins = KPluginLoader::findPlugins(QStringLiteral("minuet"), [&](const KPluginMetaData &meta) {
if (!meta.serviceTypes().contains(QStringLiteral("Minuet/Plugin"))) {
qDebug() << "Plugin" << meta.fileName() << "is installed into the minuet plugin directory, but does not have"
" \"Minuet/Plugin\" set as the service type. This plugin will not be loaded.";
return false;
}
return true;
});
}
PluginController::~PluginController()
{
}
bool PluginController::initialize()
{
foreach (const KPluginMetaData &pluginMetaData, m_plugins)
{
if (m_loadedPlugins.value(pluginMetaData))
continue;
KPluginLoader loader(pluginMetaData.fileName());
IPlugin *plugin = qobject_cast<IPlugin *>(loader.instance());
if (plugin)
m_loadedPlugins.insert(pluginMetaData, plugin);
}
return true;
}
}
......@@ -25,11 +25,15 @@
#include <interfaces/iplugincontroller.h>
#include <KPluginMetaData>
#include "minuetshellexport.h"
namespace Minuet
{
class IPlugin;
class MINUETSHELL_EXPORT PluginController : public IPluginController
{
Q_OBJECT
......@@ -37,6 +41,14 @@ class MINUETSHELL_EXPORT PluginController : public IPluginController
public:
PluginController(QObject *parent = 0);
~PluginController() override;
bool initialize();
private:
QVector<KPluginMetaData> m_plugins;
typedef QHash<KPluginMetaData, IPlugin *> InfoToPluginMap;
InfoToPluginMap m_loadedPlugins;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment