summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-23 05:29:14 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-23 05:29:14 (GMT)
commit3bc1cccc689756e94a449c176a34067e918224b9 (patch)
treef7b2438e0fbdd19ae64b8adecb8c6f15e8637874
parent3887f1b38a8ed20801545f64fbcebc20e54a9ae8 (diff)
Show or not networkpluginurlinterceptor
-rw-r--r--webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.cpp13
-rw-r--r--webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.h6
-rw-r--r--webengineviewer/src/urlinterceptor/networkurlinterceptormanager.cpp10
-rw-r--r--webengineviewer/src/urlinterceptor/networkurlinterceptorpluginmanager.cpp57
4 files changed, 53 insertions, 33 deletions
diff --git a/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.cpp b/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.cpp
index 5b02c5c..72074f0 100644
--- a/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.cpp
+++ b/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.cpp
@@ -22,7 +22,8 @@
using namespace WebEngineViewer;
NetworkPluginUrlInterceptor::NetworkPluginUrlInterceptor(QObject *parent)
- : QObject(parent)
+ : QObject(parent),
+ mIsEnabled(false)
{
}
@@ -42,3 +43,13 @@ NetworkPluginUrlInterceptorConfigureWidgetSetting NetworkPluginUrlInterceptor::c
Q_UNUSED(parent);
return {};
}
+
+void NetworkPluginUrlInterceptor::setIsEnabled(bool enabled)
+{
+ mIsEnabled = enabled;
+}
+
+bool NetworkPluginUrlInterceptor::isEnabled() const
+{
+ return mIsEnabled;
+}
diff --git a/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.h b/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.h
index 2e709dd..a97e970 100644
--- a/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.h
+++ b/webengineviewer/src/urlinterceptor/networkpluginurlinterceptor.h
@@ -55,6 +55,12 @@ public:
virtual bool hasConfigureDialog() const;
virtual NetworkPluginUrlInterceptorConfigureWidgetSetting createConfigureWidget(QWidget *parent = Q_NULLPTR);
+
+ void setIsEnabled(bool enabled);
+ bool isEnabled() const;
+
+private:
+ bool mIsEnabled;
};
}
diff --git a/webengineviewer/src/urlinterceptor/networkurlinterceptormanager.cpp b/webengineviewer/src/urlinterceptor/networkurlinterceptormanager.cpp
index 923df9d..ed6db5c 100644
--- a/webengineviewer/src/urlinterceptor/networkurlinterceptormanager.cpp
+++ b/webengineviewer/src/urlinterceptor/networkurlinterceptormanager.cpp
@@ -55,7 +55,7 @@ QVector<NetworkPluginUrlInterceptorConfigureWidgetSetting> NetworkUrlInterceptor
{
QVector<NetworkPluginUrlInterceptorConfigureWidgetSetting> lstConfigureWidget;
Q_FOREACH (NetworkPluginUrlInterceptor *plugin, NetworkUrlInterceptorPluginManager::self()->pluginsList()) {
- if (plugin->hasConfigureDialog()) {
+ if (plugin->hasConfigureDialog() && plugin->isEnabled()) {
lstConfigureWidget.append(plugin->createConfigureWidget(parent));
}
}
@@ -65,9 +65,11 @@ QVector<NetworkPluginUrlInterceptorConfigureWidgetSetting> NetworkUrlInterceptor
void NetworkUrlInterceptorManagerPrivate::createInterfaces(QWebEngineView *webEngine, KActionCollection *ac)
{
Q_FOREACH (NetworkPluginUrlInterceptor *plugin, NetworkUrlInterceptorPluginManager::self()->pluginsList()) {
- WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface = plugin->createInterface(webEngine, q);
- interface->createActions(ac);
- mListInterface.append(interface);
+ if (plugin->isEnabled()) {
+ WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface = plugin->createInterface(webEngine, q);
+ interface->createActions(ac);
+ mListInterface.append(interface);
+ }
}
}
diff --git a/webengineviewer/src/urlinterceptor/networkurlinterceptorpluginmanager.cpp b/webengineviewer/src/urlinterceptor/networkurlinterceptorpluginmanager.cpp
index 8bb5368..3321967 100644
--- a/webengineviewer/src/urlinterceptor/networkurlinterceptorpluginmanager.cpp
+++ b/webengineviewer/src/urlinterceptor/networkurlinterceptorpluginmanager.cpp
@@ -56,17 +56,14 @@ public:
{
}
- QString saveName() const;
- KPluginMetaData metaData;
+ QString metaDataFileNameBaseName;
+ QString metaDataFileName;
+ PimCommon::PluginUtilData pluginData;
WebEngineViewer::NetworkPluginUrlInterceptor *plugin;
+ bool isEnabled;
};
-QString MailNetworkUrlInterceptorPluginInfo::saveName() const
-{
- return QFileInfo(metaData.fileName()).baseName();
-}
-
namespace
{
QString pluginVersion()
@@ -124,26 +121,27 @@ void NetworkUrlInterceptorPluginManagerPrivate::initializePluginList()
while (i.hasPrevious()) {
MailNetworkUrlInterceptorPluginInfo info;
- info.metaData = i.previous();
-
- 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) {
- const QString version = info.metaData.version();
- if (pluginVersion() == version) {
-
- // only load plugins once, even if found multiple times!
- if (unique.contains(info.saveName())) {
- continue;
- }
- info.plugin = Q_NULLPTR;
- mPluginList.append(info);
- unique.insert(info.saveName());
- } else {
- qCWarning(WEBENGINEVIEWER_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(WEBENGINEVIEWER_LOG) << "Plugin " << data.name() << " doesn't have correction plugin version. It will not be loaded.";
}
}
QVector<MailNetworkUrlInterceptorPluginInfo>::iterator end(mPluginList.end());
@@ -166,9 +164,12 @@ QVector<WebEngineViewer::NetworkPluginUrlInterceptor *> NetworkUrlInterceptorPlu
void NetworkUrlInterceptorPluginManagerPrivate::loadPlugin(MailNetworkUrlInterceptorPluginInfo *item)
{
- KPluginLoader pluginLoader(item->metaData.fileName());
+ KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
- item->plugin = pluginLoader.factory()->create<WebEngineViewer::NetworkPluginUrlInterceptor>(q, QVariantList() << item->saveName());
+ item->plugin = pluginLoader.factory()->create<WebEngineViewer::NetworkPluginUrlInterceptor>(q, QVariantList() << item->metaDataFileNameBaseName);
+ item->plugin->setIsEnabled(item->isEnabled);
+ item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
+ mPluginDataList.append(item->pluginData);
}
}