summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2009-11-22 14:53:33 +0100
committermatgic78 <matgic78@gmail.com>2009-11-27 16:11:57 +0100
commit19d7611101253c27a841480fca55f1bc5cd767b6 (patch)
tree0ae960f684382824291b474afa3e2c0bfb8d55ee /src
parentClickToFlash : first step (diff)
downloadrekonq-19d7611101253c27a841480fca55f1bc5cd767b6.tar.xz
clicktoflash : step 2 make it work when there are more than one plugin in the same page
Diffstat (limited to 'src')
-rw-r--r--src/clicktoflash.cpp33
-rw-r--r--src/clicktoflash.h8
-rw-r--r--src/webpluginfactory.cpp2
3 files changed, 34 insertions, 9 deletions
diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp
index d89c1ec5..39d55e5a 100644
--- a/src/clicktoflash.cpp
+++ b/src/clicktoflash.cpp
@@ -39,9 +39,9 @@
#include <KDebug>
-ClickToFlash::ClickToFlash(const WebPluginFactory *factory, QWidget *parent)
+ClickToFlash::ClickToFlash(const WebPluginFactory *factory, QUrl pluginUrl, QWidget *parent)
: QWidget(parent)
- , m_factory(factory)
+ , m_url(pluginUrl)
{
kDebug() << "creating clicktoflash";
@@ -96,6 +96,7 @@ void ClickToFlash::loadAll()
*/
void ClickToFlash::load(bool loadAll)
{
+ kDebug() << "called";
QWidget *parent = parentWidget();
QWebView *view = 0;
while (parent)
@@ -126,17 +127,37 @@ void ClickToFlash::load(bool loadAll)
elements.append(docElement.findAll(selector.arg(QLatin1String("embed"))));
QWebElement element;
+ kDebug() << m_url;
+ bool isRightElement = false;
foreach (element, elements)
{
- QWebElement substitute = element.clone();
- emit signalLoadClickToFlash(true);
- element.replace(substitute);
+ // TODO : find a proper solution to compare a QWebElement with a plugin
+ if(QUrl(element.attribute("data")) == m_url
+ || QUrl(element.attribute("src")) == m_url)
+ isRightElement = true;
+
+ QWebElementCollection collec = element.findAll("param");
+ int i = 0;
+ while(i < collec.count() && isRightElement == false)
+ {
+ if(QUrl(collec.at(i).attribute("value")) == m_url)
+ isRightElement = true;
+ i++;
+ }
+
+ if(isRightElement)
+ {
+ QWebElement substitute = element.clone();
+ emit signalLoadClickToFlash(true);
+ element.replace(substitute);
+ return;
+ }
}
frames += frame->childFrames();
}
- deleteLater();
+ //deleteLater();
}
diff --git a/src/clicktoflash.h b/src/clicktoflash.h
index 382c6001..3660a1f9 100644
--- a/src/clicktoflash.h
+++ b/src/clicktoflash.h
@@ -31,6 +31,7 @@
#include <QWidget>
#include <QToolButton>
+#include <QUrl>
class WebPluginFactory;
@@ -38,7 +39,10 @@ class ClickToFlash : public QWidget
{
Q_OBJECT
public:
- ClickToFlash(const WebPluginFactory *factory, QWidget *parent = 0);
+ /**
+ pluginUrl : used to find the right QWebElement between the ones of the different plugins
+ */
+ ClickToFlash(const WebPluginFactory *factory, QUrl pluginUrl, QWidget *parent = 0);
signals:
void signalLoadClickToFlash(bool);
@@ -52,7 +56,7 @@ private slots:
void load(bool loadAll = false);
private:
- const WebPluginFactory *m_factory;
+ const QUrl m_url;
};
#endif // CLICKTOFLASH_H
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp
index 2c8ed181..1478339b 100644
--- a/src/webpluginfactory.cpp
+++ b/src/webpluginfactory.cpp
@@ -88,7 +88,7 @@ QObject *WebPluginFactory::create(const QString &mimeType,
if(mimeType == QString("application/x-shockwave-flash")
&& !loadClickToFlash) // the button wasn't clicked
{
- ClickToFlash* ctf = new ClickToFlash(this);
+ ClickToFlash* ctf = new ClickToFlash(this, url);
connect(ctf, SIGNAL(signalLoadClickToFlash(bool)), this, SLOT(setLoadClickToFlash(bool)));
return ctf;
}