[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [messagelib] messagecomposer/src/plugineditorcheckbeforesend: Allow to define if plugin is enable or
From: Montel Laurent <montel () kde ! org>
Date: 2016-09-23 5:57:18
Message-ID: E1bnJU6-0001CE-OT () code ! kde ! org
[Download RAW message or body]
Git commit 3887f1b38a8ed20801545f64fbcebc20e54a9ae8 by Montel Laurent.
Committed on 23/09/2016 at 05:13.
Pushed by mlaurent into branch 'master'.
Allow to define if plugin is enable or not
M +12 -0 messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.cpp
M +4 -0 messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.h
M +29 -29 messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
http://commits.kde.org/messagelib/3887f1b38a8ed20801545f64fbcebc20e54a9ae8
diff --git a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.cpp \
b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.cpp \
index 8b0c2a4..8a120d3 100644
--- a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.cpp
+++ b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.cpp
@@ -25,9 +25,11 @@ class MessageComposer::PluginEditorCheckBeforeSendPrivate
{
public:
PluginEditorCheckBeforeSendPrivate()
+ : mIsEnabled(false)
{
}
+ bool mIsEnabled;
};
PluginEditorCheckBeforeSend::PluginEditorCheckBeforeSend(QObject *parent)
@@ -63,3 +65,13 @@ QString PluginEditorCheckBeforeSend::description() const
{
return {};
}
+
+void PluginEditorCheckBeforeSend::setIsEnabled(bool enabled)
+{
+ d->mIsEnabled = enabled;
+}
+
+bool PluginEditorCheckBeforeSend::isEnabled() const
+{
+ return d->mIsEnabled;
+}
diff --git a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.h \
b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.h index \
5285efe..f164c6a 100644
--- a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.h
+++ b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesend.h
@@ -68,6 +68,10 @@ public:
virtual QString description() const;
+ void setIsEnabled(bool enabled);
+ bool isEnabled() const;
+
+
Q_SIGNALS:
void configChanged();
diff --git a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp \
b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
index 15b388b..a6ee029 100644
--- a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
+++ b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
@@ -47,14 +47,16 @@ class PluginEditorCheckBeforeSendInfo
{
public:
PluginEditorCheckBeforeSendInfo()
- : plugin(Q_NULLPTR)
+ : plugin(Q_NULLPTR),
+ isEnabled(true)
{
}
- QString saveName() const;
-
- KPluginMetaData metaData;
+ QString metaDataFileNameBaseName;
+ QString metaDataFileName;
+ PimCommon::PluginUtilData pluginData;
PluginEditorCheckBeforeSend *plugin;
+ bool isEnabled;
};
Q_GLOBAL_STATIC(PluginEditorCheckBeforeSendManagerInstancePrivate, sInstance)
@@ -115,25 +117,25 @@ bool \
PluginEditorCheckBeforeSendManagerPrivate::initializePlugins() QSet<QString> unique;
while (i.hasPrevious()) {
PluginEditorCheckBeforeSendInfo info;
- info.metaData = i.previous();
-
- //Store plugin info
- PimCommon::PluginUtilData pluginData = \
PimCommon::PluginUtil::createPluginMetaData(info.metaData);
- mPluginDataList.append(pluginData);
-
- const bool isPluginActivated = \
PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, \
pluginData.mEnableByDefault, pluginData.mIdentifier);
- if (isPluginActivated) {
- if (pluginVersion() == info.metaData.version()) {
- // only load plugins once, even if found multiple times!
- if (unique.contains(info.saveName())) {
- continue;
- }
- info.plugin = Q_NULLPTR;
- mPluginList.push_back(info);
- unique.insert(info.saveName());
- } else {
- qCWarning(MESSAGECOMPOSER_LOG) << "Plugin " << info.metaData.name() \
<< " doesn't have correction plugin version. It will not be loaded."; + const \
KPluginMetaData data = i.previous(); +
+ //1) get plugin data => name/description etc.
+ info.pluginData = PimCommon::PluginUtil::createPluginMetaData(data);
+ //2) look at if plugin is activated
+ const bool isPluginActivated = \
PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, \
info.pluginData.mEnableByDefault, info.pluginData.mIdentifier); + \
info.isEnabled = isPluginActivated; + info.metaDataFileNameBaseName = \
QFileInfo(data.fileName()).baseName(); + info.metaDataFileName = \
data.fileName(); + if (pluginVersion() == data.version()) {
+ // only load plugins once, even if found multiple times!
+ if (unique.contains(info.metaDataFileNameBaseName)) {
+ continue;
}
+ info.plugin = Q_NULLPTR;
+ mPluginList.push_back(info);
+ unique.insert(info.metaDataFileNameBaseName);
+ } else {
+ qCWarning(MESSAGECOMPOSER_LOG) << "Plugin " << data.name() << " doesn't \
have correction plugin version. It will not be loaded."; }
}
QVector<PluginEditorCheckBeforeSendInfo>::iterator end(mPluginList.end());
@@ -145,9 +147,12 @@ bool \
PluginEditorCheckBeforeSendManagerPrivate::initializePlugins()
void PluginEditorCheckBeforeSendManagerPrivate::loadPlugin(PluginEditorCheckBeforeSendInfo \
*item) {
- KPluginLoader pluginLoader(item->metaData.fileName());
+ KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
- item->plugin = \
pluginLoader.factory()->create<PluginEditorCheckBeforeSend>(q, QVariantList() << \
item->saveName()); + item->plugin = \
pluginLoader.factory()->create<PluginEditorCheckBeforeSend>(q, QVariantList() << \
item->metaDataFileNameBaseName); + \
item->plugin->setIsEnabled(item->isEnabled); + \
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog(); + \
mPluginDataList.append(item->pluginData); }
}
@@ -179,11 +184,6 @@ PluginEditorCheckBeforeSendManager \
*PluginEditorCheckBeforeSendManager::self() return sInstance->pluginManager;
}
-QString PluginEditorCheckBeforeSendInfo::saveName() const
-{
- return QFileInfo(metaData.fileName()).baseName();
-}
-
QVector<PluginEditorCheckBeforeSend *> \
PluginEditorCheckBeforeSendManager::pluginsList() const {
return d->pluginsList();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic