diff options
Diffstat (limited to 'src/core/api')
-rw-r--r-- | src/core/api/qwebenginepage.cpp | 9 | ||||
-rw-r--r-- | src/core/api/qwebengineprofile.cpp | 66 | ||||
-rw-r--r-- | src/core/api/qwebengineprofile.h | 3 |
3 files changed, 74 insertions, 4 deletions
diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp index 3028c38f5..12dcc867b 100644 --- a/src/core/api/qwebenginepage.cpp +++ b/src/core/api/qwebenginepage.cpp @@ -1987,11 +1987,12 @@ QUrl QWebEnginePage::iconUrl() const \brief The icon associated with the page currently viewed. \since 5.7 - By default, this property contains a null icon. If the web page specifies more than one icon, - the \c{icon} property encapsulates the available candidate icons in a single, - scalable \c{QIcon}. + By default, this property contains a null icon. If touch icons are disabled + (see \c QWebEngineSettings::TouchIconsEnabled), the favicon is provided in two sizes + (16x16 and 32x32 pixels) encapsulated in \c{QIcon}. Otherwise, single icon is provided + with the largest available size. - \sa iconChanged(), iconUrl(), iconUrlChanged() + \sa iconChanged(), iconUrl(), iconUrlChanged(), QWebEngineSettings::TouchIconsEnabled */ QIcon QWebEnginePage::icon() const { diff --git a/src/core/api/qwebengineprofile.cpp b/src/core/api/qwebengineprofile.cpp index 4074a4c31..13ad0f992 100644 --- a/src/core/api/qwebengineprofile.cpp +++ b/src/core/api/qwebengineprofile.cpp @@ -873,4 +873,70 @@ QWebEngineClientCertificateStore *QWebEngineProfile::clientCertificateStore() #endif } +/*! + * Requests an icon for a previously loaded page with this profile from the database. Each profile + * has its own icon database and it is stored in the persistent storage thus the stored icons + * can be accessed without network connection too. The icon must be previously loaded to be + * stored in the database. + * + * \a url specifies the URL of the page what the icon is requested for. In case of more than one + * available icons the one with the size closest to \a desiredSizeInPixel will be returned. + * The result icon is resized to \a desiredSizeInPixel. If desiredSizeInPixel is 0 the largest + * available icon is returned. + * + * This function is asynchronous and the result is returned by \a iconAvailableCallback. + * The callback is called if a request for an icon is performed. If the requested icon is + * available, the first parameter (with type QIcon) is the result. Otherwise, it is null. + * + * The second parameter stores the URL of the requested icon. It is empty if the icon can't be + * fetched. + * + * The third parameter stores the URL of the page which the icon is assigned. + * + * \note Icons can't be requested with an off-the-record profile. + * + * \since 6.2 + * \sa requestIconForIconURL() + */ +void QWebEngineProfile::requestIconForPageURL(const QUrl &url, int desiredSizeInPixel, + std::function<void(const QIcon &, const QUrl &, const QUrl &)> iconAvailableCallback) const +{ + Q_D(const QWebEngineProfile); + d->profileAdapter()->requestIconForPageURL(url, desiredSizeInPixel, + settings()->testAttribute(QWebEngineSettings::TouchIconsEnabled), + iconAvailableCallback); +} + +/*! + * Requests an icon with the specified \a url from the database. Each profile has its + * own icon database and it is stored in the persistent storage thus the stored icons + * can be accessed without network connection too. The icon must be previously loaded to be + * stored in the database. + * + * \a url specifies the URL of the icon. In case of more than one + * available icons the one with the size closest to \a desiredSizeInPixel will be returned. + * The result icon is resized to \a desiredSizeInPixel. If desiredSizeInPixel is 0 the largest + * available icon is returned. + * + * This function is asynchronous and the result is returned by \a iconAvailableCallback. + * The callback is called if a request for an icon is performed. If the requested icon is + * available, the first parameter (with type QIcon) is the result. Otherwise, it is null. + * + * The second parameter stores the URL of the requested icon. It is empty if the icon can't be + * fetched. + * + * \note Icons can't be requested with an off-the-record profile. + * + * \since 6.2 + * \sa requestIconForPageURL() + */ +void QWebEngineProfile::requestIconForIconURL(const QUrl &url, int desiredSizeInPixel, + std::function<void(const QIcon &, const QUrl &)> iconAvailableCallback) const +{ + Q_D(const QWebEngineProfile); + d->profileAdapter()->requestIconForIconURL(url, desiredSizeInPixel, + settings()->testAttribute(QWebEngineSettings::TouchIconsEnabled), + iconAvailableCallback); +} + QT_END_NAMESPACE diff --git a/src/core/api/qwebengineprofile.h b/src/core/api/qwebengineprofile.h index 63ac3a9b9..618576664 100644 --- a/src/core/api/qwebengineprofile.h +++ b/src/core/api/qwebengineprofile.h @@ -142,6 +142,9 @@ public: QWebEngineClientCertificateStore *clientCertificateStore(); + void requestIconForPageURL(const QUrl &url, int desiredSizeInPixel, std::function<void(const QIcon &, const QUrl &, const QUrl &)> iconAvailableCallback) const; + void requestIconForIconURL(const QUrl &url, int desiredSizeInPixel, std::function<void(const QIcon &, const QUrl &)> iconAvailableCallback) const; + static QWebEngineProfile *defaultProfile(); Q_SIGNALS: |