Commit 5cc4be3f authored by Laurent Montel's avatar Laurent Montel 😁

Start to implement plugin order

parent d431d97a
......@@ -19,13 +19,35 @@
using namespace MessageComposer;
class MessageComposer::PluginEditorPrivate
{
public:
PluginEditorPrivate()
: order(0)
{
}
int order;
};
PluginEditor::PluginEditor(QObject *parent)
: QObject(parent)
: QObject(parent),
d(new PluginEditorPrivate)
{
}
PluginEditor::~PluginEditor()
{
delete d;
}
void PluginEditor::setOrder(int order)
{
d->order = order;
}
int PluginEditor::order() const
{
return d->order;
}
......@@ -24,14 +24,19 @@ class KActionCollection;
namespace MessageComposer
{
class PluginEditorInterface;
class PluginEditorPrivate;
class MESSAGECOMPOSER_EXPORT PluginEditor : public QObject
{
Q_OBJECT
public:
explicit PluginEditor(QObject *parent = Q_NULLPTR);
~PluginEditor();
void setOrder(int order);
virtual PluginEditorInterface *createInterface(KActionCollection *ac, QObject *parent = Q_NULLPTR) = 0;
int order() const;
private:
PluginEditorPrivate *const d;
};
}
#endif // PLUGINEDITOR_H
......@@ -45,13 +45,15 @@ class PluginEditorInfo
{
public:
PluginEditorInfo()
: plugin(Q_NULLPTR)
: order(0),
plugin(Q_NULLPTR)
{
}
QString saveName() const;
KPluginMetaData metaData;
int order;
PluginEditor *plugin;
};
......@@ -92,6 +94,12 @@ bool PluginEditorManagerPrivate::initializePlugins()
while (i.hasPrevious()) {
PluginEditorInfo info;
info.metaData = i.previous();
const QVariant p = info.metaData.rawData().value(QStringLiteral("X-KDE-KMailEditor-Order")).toVariant();
int order = -1;
if (p.isValid()) {
order = p.toInt();
}
info.order = order;
if (pluginVersion() == info.metaData.version()) {
// only load plugins once, even if found multiple times!
if (unique.contains(info.saveName())) {
......@@ -112,6 +120,7 @@ bool PluginEditorManagerPrivate::initializePlugins()
void PluginEditorManagerPrivate::loadPlugin(PluginEditorInfo *item)
{
item->plugin = KPluginLoader(item->metaData.fileName()).factory()->create<PluginEditor>(q, QVariantList() << item->saveName());
item->plugin->setOrder(item->order);
}
QVector<PluginEditor *> PluginEditorManagerPrivate::pluginsList() const
......
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