From bfaf510408a95d95e1540be1a1f522a0ebfe0eff Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 29 Apr 2009 13:09:39 +1000 Subject: Fix plugin delayed loading. Allows settings from QML. --- src/declarative/fx/qfxwebview.cpp | 83 +++++++++++++++++++++++++++++++++++++-- src/declarative/fx/qfxwebview.h | 3 ++ 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 293c72b..8af4158 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -75,6 +75,73 @@ QML_DEFINE_TYPE(QFxWebView,WebView); static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system +class QFxWebSettings : public QObject { + Q_OBJECT + /* + StandardFont, + FixedFont, + SerifFont, + SansSerifFont, + CursiveFont, + FantasyFont + + MinimumFontSize, + MinimumLogicalFontSize, + DefaultFontSize, + DefaultFixedFontSize + */ + + Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) + Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) + Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) + Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) + Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) + Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) + Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) + Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) + Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) + Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) + Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) + Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) + Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) + Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) + +public: + QFxWebSettings() {} + + bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } + void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } + bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } + void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } + bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } + void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } + bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } + void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } + bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } + void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } + bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } + void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } + bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } + void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } + bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } + void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } + bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } + void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } + bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } + void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } + bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } + void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } + bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } + void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } + bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } + void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } + bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } + void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } + + QWebSettings *s; +}; + + class QFxWebViewPrivate : public QFxItemPrivate { Q_DECLARE_PUBLIC(QFxWebView) @@ -131,6 +198,7 @@ public: QUrl pending_url; QString pending_string; QByteArray pending_data; + mutable QFxWebSettings settings; }; @@ -866,9 +934,6 @@ QWebPage *QFxWebView::page() const wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); - // XXX settable from QML? - wp->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - self->setPage(wp); return wp; @@ -877,6 +942,13 @@ QWebPage *QFxWebView::page() const return d->page; } +// The QObject interface to settings(). +QObject *QFxWebView::settingsObject() const +{ + Q_D(const QFxWebView); + d->settings.s = page()->settings(); + return &d->settings; +} void QFxWebView::setPage(QWebPage *page) { @@ -1031,7 +1103,10 @@ public: QmlEngine *engine = qmlEngine(webview); component = new QmlComponent(engine, url, this); item = 0; - connect(engine, SIGNAL(statusChanged(Status)), this, SLOT(qmlLoaded())); + if (component->isReady()) + qmlLoaded(); + else + connect(component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(qmlLoaded())); } public Q_SLOTS: diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index 1eede52..6ba4601 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -103,6 +103,8 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem Q_PROPERTY(QObject* forward READ forwardAction) Q_PROPERTY(QObject* stop READ stopAction) + Q_PROPERTY(QObject* settings READ settingsObject) + public: QFxWebView(QFxItem *parent=0); ~QFxWebView(); @@ -164,6 +166,7 @@ public: QWebHistory *history() const; QWebSettings *settings() const; + QObject *settingsObject() const; QString status() const; -- cgit v0.12 From e50b584c8ca90eb7bbee69b92f47827d3d56df3e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 29 Apr 2009 13:52:12 +1000 Subject: Phones info media, not movie info media. --- .../mediabrowser/content/MovieInfoContainer.qml | 60 ---------------- .../mediabrowser/content/MoviesPathView.qml | 74 ------------------- .../mediabrowser/content/PhoneInfoContainer.qml | 66 +++++++++++++++++ .../mediabrowser/content/PhonesPathView.qml | 82 ++++++++++++++++++++++ .../mediabrowser/dummydata/MoviesModel.qml | 38 ---------- demos/declarative/mediabrowser/mediabrowser.qml | 10 +-- 6 files changed, 153 insertions(+), 177 deletions(-) delete mode 100644 demos/declarative/mediabrowser/content/MovieInfoContainer.qml delete mode 100644 demos/declarative/mediabrowser/content/MoviesPathView.qml create mode 100644 demos/declarative/mediabrowser/content/PhoneInfoContainer.qml create mode 100644 demos/declarative/mediabrowser/content/PhonesPathView.qml delete mode 100644 demos/declarative/mediabrowser/dummydata/MoviesModel.qml diff --git a/demos/declarative/mediabrowser/content/MovieInfoContainer.qml b/demos/declarative/mediabrowser/content/MovieInfoContainer.qml deleted file mode 100644 index c53fab6..0000000 --- a/demos/declarative/mediabrowser/content/MovieInfoContainer.qml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demos/declarative/mediabrowser/content/MoviesPathView.qml b/demos/declarative/mediabrowser/content/MoviesPathView.qml deleted file mode 100644 index a13437a..0000000 --- a/demos/declarative/mediabrowser/content/MoviesPathView.qml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demos/declarative/mediabrowser/content/PhoneInfoContainer.qml b/demos/declarative/mediabrowser/content/PhoneInfoContainer.qml new file mode 100644 index 0000000..dbf25f5 --- /dev/null +++ b/demos/declarative/mediabrowser/content/PhoneInfoContainer.qml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/mediabrowser/content/PhonesPathView.qml b/demos/declarative/mediabrowser/content/PhonesPathView.qml new file mode 100644 index 0000000..e08e13f --- /dev/null +++ b/demos/declarative/mediabrowser/content/PhonesPathView.qml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/mediabrowser/dummydata/MoviesModel.qml b/demos/declarative/mediabrowser/dummydata/MoviesModel.qml deleted file mode 100644 index 87bca37..0000000 --- a/demos/declarative/mediabrowser/dummydata/MoviesModel.qml +++ /dev/null @@ -1,38 +0,0 @@ - - - Repoman - http://www.impawards.com/1984/posters/repo_man.jpg - Cult classic. Car repossession. Radiation. Plate O' Shrimp. - 2 - - - Monsters vs Aliens - http://www.impawards.com/2009/posters/monsters_vs_aliens_ver6.jpg - Love Monsters? Love Aliens? You're in luck. - 1 - - - Cruel Intentions - http://impawards.com/1999/posters/cruel_intentions_ver1.jpg - Modern-day update of Les Liaisons Dangereuses. Better because it has nothing to do with the French. - 3 - - - Lord of War - http://www.impawards.com/2005/posters/lord_of_war_ver2.jpg - There are over 500 million fire arms in worldwide circulation. That is one fire arm for every twelve people on the planet. The only question is how do we arm the other eleven? - 4 - - - The Devil's Advocate - http://impawards.com/1997/posters/devils_advocate_ver1.jpg - An ambitious your district attorney joins a powerful New York law firm headed by the devil. - 4 - - - Team America: World Police - http://impawards.com/2004/posters/team_america_world_police.jpg - Hey terrorist, terrorize this. - 1 - - diff --git a/demos/declarative/mediabrowser/mediabrowser.qml b/demos/declarative/mediabrowser/mediabrowser.qml index df7baa9..338aed2 100644 --- a/demos/declarative/mediabrowser/mediabrowser.qml +++ b/demos/declarative/mediabrowser/mediabrowser.qml @@ -8,12 +8,12 @@ - + - - + + @@ -29,8 +29,8 @@ - - + + -- cgit v0.12 From 14a5c8be6900c10dc6bc593e472b6a879db4dd2d Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 29 Apr 2009 14:21:27 +1000 Subject: Nicer order. Nicer order, but not perfect (no global Z) --- demos/declarative/mediabrowser/content/PhonesPathView.qml | 5 +---- demos/declarative/mediabrowser/mediabrowser.qml | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/demos/declarative/mediabrowser/content/PhonesPathView.qml b/demos/declarative/mediabrowser/content/PhonesPathView.qml index e08e13f..8ec1938 100644 --- a/demos/declarative/mediabrowser/content/PhonesPathView.qml +++ b/demos/declarative/mediabrowser/content/PhonesPathView.qml @@ -3,20 +3,17 @@ - - - - +