diff options
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 48 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 6 | ||||
-rw-r--r-- | src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc | 22 |
3 files changed, 55 insertions, 21 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 184b17095..326f1b08d 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -44,6 +44,7 @@ #include "browser_context_adapter.h" #include "certificate_error_controller.h" #include "color_chooser_controller.h" +#include "favicon_manager.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" #include "qwebenginefullscreenrequest.h" @@ -150,6 +151,7 @@ void QWebEnginePagePrivate::iconChanged(const QUrl &url) return; iconUrl = url; Q_EMIT q->iconUrlChanged(iconUrl); + Q_EMIT q->iconChanged(adapter->faviconManager()->getIcon(iconUrl)); } void QWebEnginePagePrivate::loadProgressChanged(int progress) @@ -576,6 +578,25 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! + \fn void QWebEnginePage::iconUrlChanged(const QUrl &url) + + This signal is emitted when the URL of the icon ("favicon") associated with the + page is changed. The new URL is specified by \a url. + + \sa iconUrl(), icon(), iconChanged() +*/ + +/*! + \fn void QWebEnginePage::iconChanged(const QIcon &icon) + \since 5.7 + + This signal is emitted when the icon ("favicon") associated with the + page is changed. The new icon is specified by \a icon. + + \sa icon(), iconUrl(), iconUrlChanged() +*/ + +/*! Constructs an empty web engine page in the web engine profile \a profile with the parent \a parent. @@ -1480,12 +1501,39 @@ QUrl QWebEnginePage::requestedUrl() const return d->adapter->requestedUrl(); } +/*! + \property QWebEnginePage::iconUrl + \brief the URL of the icon associated with the page currently viewed + + By default, this property contains an empty URL. + + \sa iconUrlChanged(), icon(), iconChanged() +*/ QUrl QWebEnginePage::iconUrl() const { Q_D(const QWebEnginePage); return d->iconUrl; } +/*! + \property QWebEnginePage::icon + \brief the icon associated with the page currently viewed + \since 5.7 + + By default, this property contains a null icon. + + \sa iconChanged(), iconUrl(), iconUrlChanged() +*/ +QIcon QWebEnginePage::icon() const +{ + Q_D(const QWebEnginePage); + + if (d->iconUrl.isEmpty()) + return QIcon(); + + return d->adapter->faviconManager()->getIcon(d->iconUrl); +} + qreal QWebEnginePage::zoomFactor() const { Q_D(const QWebEnginePage); diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 12e7532cc..0faa385da 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -73,7 +73,8 @@ class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject { Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) Q_PROPERTY(QString title READ title) Q_PROPERTY(QUrl url READ url WRITE setUrl) - Q_PROPERTY(QUrl iconUrl READ iconUrl) + Q_PROPERTY(QUrl iconUrl READ iconUrl NOTIFY iconUrlChanged) + Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) Q_PROPERTY(QSizeF contentsSize READ contentsSize NOTIFY contentsSizeChanged) Q_PROPERTY(QPointF scrollPosition READ scrollPosition NOTIFY scrollPositionChanged) @@ -240,6 +241,7 @@ public: QUrl url() const; QUrl requestedUrl() const; QUrl iconUrl() const; + QIcon icon() const; qreal zoomFactor() const; void setZoomFactor(qreal factor); @@ -300,8 +302,8 @@ Q_SIGNALS: // Ex-QWebFrame signals void titleChanged(const QString &title); void urlChanged(const QUrl &url); - // Was iconChanged() in QWebFrame void iconUrlChanged(const QUrl &url); + void iconChanged(const QIcon &icon); void scrollPositionChanged(const QPointF &position); void contentsSizeChanged(const QSizeF &size); diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 2171d680a..f1c678dea 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -50,8 +50,9 @@ The title of an HTML page can be accessed with the title() property. Additionally, a page may also specify an icon, which can be accessed - using the iconUrl() property. If the title or the icon changes, the - corresponding titleChanged() and iconUrlChanged() signals will be emitted. + using the icon() or its URL using the iconUrl() property. + If the title or the icon changes, the corresponding titleChanged(), iconChanged() + and iconUrlChanged() signals will be emitted. The zoomFactor() property can be used to change the overall size of the content displayed in the page. @@ -572,13 +573,6 @@ */ /*! - \property QWebEnginePage::iconUrl - \brief the URL of the icon associated with the page currently viewed. - - \sa iconUrlChanged() -*/ - -/*! \property QWebEnginePage::requestedUrl \brief the URL that was originally requested to be loaded by the page that is currently viewed @@ -750,13 +744,3 @@ \sa url() */ - -/*! - \fn void QWebEnginePage::iconUrlChanged(const QUrl &url) - - This signal is emitted when the icon ("favicon") associated with the page is - found or changed. The new URL is specified by \a url. - - - \sa iconUrl() -*/ |