Commit 822a34b8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move plugin in subdirectory

parent 7cac939c
......@@ -1489,7 +1489,7 @@ void ViewerPrivate::createWidgets()
mViewerPluginToolManager = new MessageViewer::ViewerPluginToolManager(readerBox, this);
mViewerPluginToolManager->setActionCollection(mActionCollection);
mViewerPluginToolManager->setPluginName(QStringLiteral("messageviewer"));
mViewerPluginToolManager->setServiceTypeName(QStringLiteral("MessageViewer/ViewerPlugin"));
mViewerPluginToolManager->setPluginDirectory(QStringLiteral("messageviewer/viewerplugin"));
if (!mViewerPluginToolManager->initializePluginList()) {
qCWarning(MESSAGEVIEWER_LOG) << " Impossible to initialize plugins";
}
......
......@@ -51,7 +51,7 @@ ViewerPluginTest::ViewerPluginTest(QWidget *parent)
&ViewerPluginTest::slotActivatePlugin);
toolManager->setPluginName(QStringLiteral("messageviewer"));
toolManager->setServiceTypeName(QStringLiteral("MessageViewer/ViewerPlugin"));
toolManager->setPluginDirectory(QStringLiteral("messageviewer/viewerplugin"));
if (!toolManager->initializePluginList()) {
qDebug() << " Impossible to initialize plugins";
}
......
......@@ -57,8 +57,9 @@ public:
QVector<MessageViewer::ViewerPlugin *> pluginsList() const;
QVector<PimCommon::PluginUtilData> pluginDataList() const;
QString serviceTypeName;
QString pluginDirectory;
QString pluginName;
QString configGroupName() const;
QString configPrefixSettingKey() const;
ViewerPlugin *pluginFromIdentifier(const QString &id);
......@@ -90,15 +91,12 @@ bool ViewerPluginManagerPrivate::initializePluginList()
if (!mPluginList.isEmpty()) {
return true;
}
if (serviceTypeName.isEmpty() || pluginName.isEmpty()) {
if (pluginDirectory.isEmpty()) {
return false;
}
static const QString s_serviceTypeName = serviceTypeName;
QVector<KPluginMetaData> plugins
= KPluginLoader::findPlugins(pluginName, [](const KPluginMetaData &md) {
return md.serviceTypes().contains(s_serviceTypeName);
});
= KPluginLoader::findPlugins(pluginDirectory);
// We need common plugin to avoid to duplicate code between akregator/kmail
plugins
......@@ -213,24 +211,14 @@ QVector<MessageViewer::ViewerPlugin *> ViewerPluginManager::pluginsList() const
return d->pluginsList();
}
void ViewerPluginManager::setServiceTypeName(const QString &serviceName)
{
d->serviceTypeName = serviceName;
}
QString ViewerPluginManager::serviceTypeName() const
void ViewerPluginManager::setPluginDirectory(const QString &directory)
{
return d->serviceTypeName;
d->pluginDirectory = directory;
}
void ViewerPluginManager::setPluginName(const QString &pluginName)
QString ViewerPluginManager::pluginDirectory() const
{
d->pluginName = pluginName;
}
QString ViewerPluginManager::pluginName() const
{
return d->pluginName;
return d->pluginDirectory;
}
QVector<PimCommon::PluginUtilData> ViewerPluginManager::pluginsDataList() const
......@@ -252,3 +240,14 @@ MessageViewer::ViewerPlugin *ViewerPluginManager::pluginFromIdentifier(const QSt
{
return d->pluginFromIdentifier(id);
}
void ViewerPluginManager::setPluginName(const QString &pluginName)
{
d->pluginName = pluginName;
}
QString ViewerPluginManager::pluginName() const
{
return d->pluginName;
}
......@@ -42,17 +42,15 @@ public:
Q_REQUIRED_RESULT QVector<MessageViewer::ViewerPlugin *> pluginsList() const;
Q_REQUIRED_RESULT QVector<PimCommon::PluginUtilData> pluginsDataList() const;
void setServiceTypeName(const QString &serviceName);
Q_REQUIRED_RESULT QString serviceTypeName() const;
void setPluginName(const QString &pluginName);
Q_REQUIRED_RESULT QString pluginName() const;
Q_REQUIRED_RESULT bool initializePluginList();
Q_REQUIRED_RESULT QString configGroupName() const;
Q_REQUIRED_RESULT QString configPrefixSettingKey() const;
Q_REQUIRED_RESULT MessageViewer::ViewerPlugin *pluginFromIdentifier(const QString &id);
Q_REQUIRED_RESULT QString pluginDirectory() const;
void setPluginDirectory(const QString &directory);
Q_REQUIRED_RESULT void setPluginName(const QString &pluginName);
Q_REQUIRED_RESULT QString pluginName() const;
private:
Q_DISABLE_COPY(ViewerPluginManager)
ViewerPluginManagerPrivate *const d;
......
......@@ -35,10 +35,9 @@ public:
{
}
void setServiceTypeName(const QString &serviceName);
QString serviceTypeName() const;
void setPluginName(const QString &pluginName);
QString pluginName() const;
Q_REQUIRED_RESULT QString pluginDirectory() const;
Q_REQUIRED_RESULT QString pluginName() const;
void createView();
void refreshActionList();
void closeAllTools();
......@@ -49,16 +48,17 @@ public:
KActionCollection *mActionCollection = nullptr;
QWidget *mParentWidget = nullptr;
ViewerPluginToolManager *q = nullptr;
void setPluginDirectory(const QString &directory);
};
void ViewerPluginToolManagerPrivate::setServiceTypeName(const QString &serviceName)
void ViewerPluginToolManagerPrivate::setPluginDirectory(const QString &directory)
{
MessageViewer::ViewerPluginManager::self()->setServiceTypeName(serviceName);
MessageViewer::ViewerPluginManager::self()->setPluginDirectory(directory);
}
QString ViewerPluginToolManagerPrivate::serviceTypeName() const
QString ViewerPluginToolManagerPrivate::pluginDirectory() const
{
return MessageViewer::ViewerPluginManager::self()->serviceTypeName();
return MessageViewer::ViewerPluginManager::self()->pluginDirectory();
}
void ViewerPluginToolManagerPrivate::setPluginName(const QString &pluginName)
......@@ -161,14 +161,14 @@ void ViewerPluginToolManager::setActionCollection(KActionCollection *ac)
d->setActionCollection(ac);
}
void ViewerPluginToolManager::setServiceTypeName(const QString &serviceName)
void ViewerPluginToolManager::setPluginDirectory(const QString &directory)
{
d->setServiceTypeName(serviceName);
d->setPluginDirectory(directory);
}
QString ViewerPluginToolManager::serviceTypeName() const
QString ViewerPluginToolManager::pluginDirectory() const
{
return d->serviceTypeName();
return d->pluginDirectory();
}
void ViewerPluginToolManager::setPluginName(const QString &pluginName)
......
......@@ -45,9 +45,6 @@ public:
void createView();
void setActionCollection(KActionCollection *ac);
void setServiceTypeName(const QString &serviceName);
Q_REQUIRED_RESULT QString serviceTypeName() const;
void setPluginName(const QString &pluginName);
Q_REQUIRED_RESULT QString pluginName() const;
Q_REQUIRED_RESULT bool initializePluginList();
......@@ -59,6 +56,9 @@ public:
* @brief refreshActionList Refresh the list of action menu.
*/
void refreshActionList();
void setPluginDirectory(const QString &directory);
Q_REQUIRED_RESULT QString pluginDirectory() const;
Q_SIGNALS:
void activatePlugin(MessageViewer::ViewerPluginInterface *);
......
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