diff options
Diffstat (limited to 'src/webpluginfactory.cpp')
-rw-r--r-- | src/webpluginfactory.cpp | 104 |
1 files changed, 35 insertions, 69 deletions
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index aec4e18d..fe2f965b 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -2,7 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com> +* Copyright (C) 2009-2010 by Andrea Diamantini <adjam7 at gmail dot com> +* Copyright (C) 2010 by Matthieu Gicquel <matgic78 at gmail dot com> * * * This program is free software; you can redistribute it and/or @@ -10,9 +11,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -32,30 +33,20 @@ #include "rekonq.h" #include "application.h" #include "mainwindow.h" -#include "previewimage.h" #include "clicktoflash.h" -// KDE Includes -#include <KDebug> - WebPluginFactory::WebPluginFactory(QObject *parent) - : KWebPluginFactory(parent) + : KWebPluginFactory(parent) + , _loadClickToFlash(false) { - loadClickToFlash = false; connect(this, SIGNAL(signalLoadClickToFlash(bool)), SLOT(setLoadClickToFlash(bool))); } -WebPluginFactory::~WebPluginFactory() -{ -} - - - void WebPluginFactory::setLoadClickToFlash(bool load) { - loadClickToFlash = load; + _loadClickToFlash = load; } @@ -65,62 +56,37 @@ QObject *WebPluginFactory::create(const QString &mimeType, const QStringList &argumentValues) const { kDebug() << "loading mimeType: " << mimeType; - - if(mimeType == QString("application/image-preview") ) - { - QString title; - int number = -1; - bool isFavorite = false; - int i; - i = argumentNames.indexOf( QString("title") ); - if(i > -1) - title = argumentValues.at(i); - i = argumentNames.indexOf( QString("isFavorite") ); - if(i > -1) - isFavorite = true; - i = argumentNames.indexOf( QString("index") ); - if(i > -1) - number = argumentValues.at(i).toInt(); - - return new PreviewImage(url, title, number, isFavorite); - } - - if(ReKonfig::pluginsEnabled() == 0) // plugins are enabled + switch (ReKonfig::pluginsEnabled()) { - kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; + case 0: + kDebug() << "No plugins found for" << mimeType << ". Falling back to KDEWebKit ones..."; + return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + + case 1: + if (mimeType != QString("application/x-shockwave-flash")) + break; + + if (_loadClickToFlash) + { + emit signalLoadClickToFlash(false); + return 0; //KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + } + else + { + ClickToFlash* ctf = new ClickToFlash(url); + connect(ctf, SIGNAL(signalLoadClickToFlash(bool)), this, SLOT(setLoadClickToFlash(bool))); + return ctf; + } + break; + + case 2: return 0; - } - - if(mimeType == QString("application/x-shockwave-flash") - && !loadClickToFlash) - { - ClickToFlash* ctf = new ClickToFlash(url); - connect(ctf, SIGNAL(signalLoadClickToFlash(bool)), this, SLOT(setLoadClickToFlash(bool))); - return ctf; - } - - // this let QtWebKit using builtin plugins - // to load in example flash contents and so on.. - kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; - emit signalLoadClickToFlash(false); - return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); -} + default: + kDebug() << "oh oh.. this should NEVER happen.."; + break; + } -QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const -{ - QList<KWebPluginFactory::Plugin> plugins = KWebPluginFactory::plugins(); - - QWebPluginFactory::Plugin p; - p.name = "application/image-preview"; - p.description = "plugin for embedding Web snapped images"; - plugins.append(p); - - p.name = "application/x-shockwave-flash"; - p.description = "Plugin for flash animations"; - plugins.append(p); - - - return plugins; + return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); } |