Plugins in WebView

2010-02-25 Thread Mathieu Ducharme
Hi,

I would like to propose allowing plasmoids to enable plugins (ie.
Flash) in the WebView widget.
I can tell that I personally expected the current Web Browser to be
able to play flash videos when I tried it...

Anyway, I'm not sure if it is currently possible in C++ (does not seem
so), but the scripting API does not have access to WebView settings so
I added the following functions to Plasma::WebView

- bool pluginsEnabled()
- void setPluginsEnabled(bool)

[Attached is a .diff to apply in trunk/KDE/kdelibs/plasma/widgets]

It works fine for me I could see youtube videos in a test javascript plasmoid:

var layout = new LinearLayout();
var web = new WebView();
web.pluginsEnabled = true; // Yay!
web.url('http://www.youtube.com');
layout.addItems(web);

There was a few issues with video position in the page which would
have to be found & fixed but are obviously unrelated to this patch,
which only enables the plugin.
(BTW Could those be the same issues that the VideoWidget have?)
Those issues could also only be local, as flash is already unstable on
my development VBox image... [that is, more than its usual
instability]

I was wondering if this was appropriate or if it opens the gates to
too many such helper functions, as there are other settings that might
be interesting to have access to:
http://doc.trolltech.com/4.6/qwebsettings.html

I guess the alternative could be to allow access the the
QWebView::settings() object.

So I would like to open the discussion on this feature, I know a few
participants in the javascript jam would love to have this ;)

Mathieu
Index: webview.h
===
--- webview.h	(revision 1096015)
+++ webview.h	(working copy)
@@ -54,6 +54,7 @@
 Q_PROPERTY(QSizeF contentsSize READ contentsSize)
 Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry)
 Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
+Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled)
 
 public:
 explicit WebView(QGraphicsItem *parent = 0);
@@ -138,6 +139,20 @@
 void setZoomFactor(const qreal zoom);
 
 /**
+ * The enabled state of the plugins
+ *
+ * @param page the page to set in this view
+ */
+Q_INVOKABLE bool pluginsEnabled();
+
+/**
+ * Enables or disables plugins
+ *
+ * @param page the page to set in this view
+ */
+Q_INVOKABLE bool setPluginsEnabled(bool enabled);
+
+/**
  * Sets the page to use in this item. The owner of the webpage remains,
  * however if this WebView object is the owner of the current page,
  * then the current page is deleted
Index: webview.cpp
===
--- webview.cpp	(revision 1096015)
+++ webview.cpp	(working copy)
@@ -152,6 +152,16 @@
 d->webView->setZoomFactor(zoom);
 }
 
+bool WebView::pluginsEnabled()
+{
+return d->webView->settings()->testAttribute(QWebSettings::PluginsEnabled);
+}
+
+void WebView::setPluginsEnabled(bool enabled)
+{
+d->webView->settings()->setAttribute(QWebSettings::PluginsEnabled, enabled);
+}
+
 void WebView::setPage(QWebPage *page)
 {
 d->webView->setPage(page);
___
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


Re: Plugins in WebView

2010-02-26 Thread Richard Moore
On Thu, Feb 25, 2010 at 10:10 PM, Mathieu Ducharme
 wrote:
> I would like to propose allowing plasmoids to enable plugins (ie.
> Flash) in the WebView widget.
> I can tell that I personally expected the current Web Browser to be
> able to play flash videos when I tried it...
>
> Anyway, I'm not sure if it is currently possible in C++ (does not seem
> so), but the scripting API does not have access to WebView settings so
> I added the following functions to Plasma::WebView
>
> - bool pluginsEnabled()
> - void setPluginsEnabled(bool)
>

One thing to watch with this is whether the plugins paint correctly
when an applet is rotated. I know ariya did some work on this, but I
don't know if it works in the current Qt release.

Cheers

Rich.
___
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


Re: Plugins in WebView

2010-02-26 Thread Aaron J. Seigo
On February 25, 2010, Mathieu Ducharme wrote:
> - bool pluginsEnabled()
> - void setPluginsEnabled(bool)

i don't know if we need to / want to offer full access to QWebSettings, but 
would a simple(r) setAttribute(QWebSettings::Attribute, bool) do the trick? 
the rest of the things in QWebSettings don't look overly useful for the use 
cases we have in plasma?

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks
___
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


Re: Plugins in WebView

2010-02-27 Thread Gábor Lehel
are qtwebkit plugins in-process or out of process? IANAPD, but having
a flash plugin in a webpage crash all of plasma does not sound like
fun times...

On Sat, Feb 27, 2010 at 12:55 AM, Aaron J. Seigo  wrote:
> On February 25, 2010, Mathieu Ducharme wrote:
>> - bool pluginsEnabled()
>> - void setPluginsEnabled(bool)
>
> i don't know if we need to / want to offer full access to QWebSettings, but
> would a simple(r) setAttribute(QWebSettings::Attribute, bool) do the trick?
> the rest of the things in QWebSettings don't look overly useful for the use
> cases we have in plasma?
>
> --
> Aaron J. Seigo
> humru othro a kohnu se
> GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43
>
> KDE core developer sponsored by Qt Development Frameworks
> ___
> Plasma-devel mailing list
> Plasma-devel@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>



-- 
Work is punishment for failing to procrastinate effectively.
___
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


Re: Plugins in WebView

2010-02-27 Thread Aaron J. Seigo
On February 27, 2010, Gábor Lehel wrote:
> are qtwebkit plugins in-process or out of process? IANAPD, but having

https://trac.webkit.org/wiki/QtWebKitPlugins

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks
___
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel