diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-03-04 13:59:25 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-03-04 13:59:25 +0100 |
commit | e26472693aac7fe5ef277889fd0136dd66159e94 (patch) | |
tree | 6873400c4679fd99823461f00f719b62db0f084f /src | |
parent | Fix merge (diff) | |
download | rekonq-e26472693aac7fe5ef277889fd0136dd66159e94.tar.xz |
WebPluginFactory. Cleaning code..
Diffstat (limited to 'src')
-rw-r--r-- | src/webpluginfactory.cpp | 60 | ||||
-rw-r--r-- | src/webpluginfactory.h | 5 |
2 files changed, 30 insertions, 35 deletions
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<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const -{ - QList<KWebPluginFactory::Plugin> 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<Plugin> 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 |