From e26472693aac7fe5ef277889fd0136dd66159e94 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 4 Mar 2010 13:59:25 +0100 Subject: WebPluginFactory. Cleaning code.. --- src/webpluginfactory.cpp | 60 +++++++++++++++++++++++------------------------- src/webpluginfactory.h | 5 +--- 2 files changed, 30 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index 6265aeb3..c8060969 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -41,8 +41,8 @@ WebPluginFactory::WebPluginFactory(QObject *parent) : KWebPluginFactory(parent) + , _loadClickToFlash(false) { - loadClickToFlash = false; connect(this, SIGNAL(signalLoadClickToFlash(bool)), SLOT(setLoadClickToFlash(bool))); } @@ -55,7 +55,7 @@ WebPluginFactory::~WebPluginFactory() void WebPluginFactory::setLoadClickToFlash(bool load) { - loadClickToFlash = load; + _loadClickToFlash = load; } @@ -65,39 +65,37 @@ QObject *WebPluginFactory::create(const QString &mimeType, const QStringList &argumentValues) const { kDebug() << "loading mimeType: " << mimeType; - - if(ReKonfig::pluginsEnabled() == 0) // plugins are enabled + + switch( ReKonfig::pluginsEnabled() ) { + case 0: kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; + return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + + case 1: + if( mimeType != QString("application/x-shockwave-flash") ) + break; + + if( _loadClickToFlash ) + { + emit signalLoadClickToFlash(false); + return 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; + + default: + kDebug() << "oh oh.. this should NEVER happen.."; + break; } - 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); } - - -QList WebPluginFactory::plugins() const -{ - QList plugins = KWebPluginFactory::plugins(); - - KWebPluginFactory::Plugin p; - - p.name = "application/x-shockwave-flash"; - p.description = "Plugin for flash animations"; - plugins.append(p); - - - return plugins; -} diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h index 74bca043..9e5028b2 100644 --- a/src/webpluginfactory.h +++ b/src/webpluginfactory.h @@ -53,10 +53,7 @@ public: const QStringList &argumentNames, const QStringList &argumentValues) const; - virtual QList plugins() const; - signals: - void signalLoadClickToFlash(bool) const; public slots: @@ -67,7 +64,7 @@ private: When true, force loading of next flash animation (don't show clicktoflash) We use signals/slots to set this property because QWebPluginFactory::create is const */ - bool loadClickToFlash; + bool _loadClickToFlash; }; #endif // WEB_PLUGIN_FACTORY_H -- cgit v1.2.1