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

Start to implement plugin order

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