diff options
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 26 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p_p.h | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginehistory.cpp | 14 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginehistory_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginetestsupport.cpp | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 113 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 7 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 5 |
10 files changed, 129 insertions, 43 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 878dddadb..767ada58f 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -112,6 +112,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb , downloadPaused(false) , view(nullptr) , downloadUrl(url) + , isCustomFileName(false) { } @@ -511,25 +512,31 @@ void QQuickWebEngineDownloadItem::setDownloadDirectory(const QString &directory) return; } + bool isPathChanged = false; QString changeDirectory = d->downloadDirectory; if (!directory.isEmpty() && changeDirectory != directory) { changeDirectory = directory; if (d->downloadDirectory != changeDirectory) { d->downloadDirectory = changeDirectory; - Q_EMIT pathChanged(); Q_EMIT downloadDirectoryChanged(); + isPathChanged = true; } - QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->updateDownloadPath(d->downloadId, - d->downloadDirectory, - d->suggestedFileName)).fileName(); - if (d->downloadFileName != newFileName) { - d->downloadFileName = newFileName; - Q_EMIT pathChanged(); - Q_EMIT downloadFileNameChanged(); + if (!d->isCustomFileName) { + QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->determineDownloadPath(d->downloadDirectory, + d->suggestedFileName, + d->startTime)).fileName(); + if (d->downloadFileName != newFileName) { + d->downloadFileName = newFileName; + Q_EMIT downloadFileNameChanged(); + isPathChanged = true; + } } } + + if (isPathChanged) + Q_EMIT pathChanged(); } /*! @@ -561,8 +568,9 @@ void QQuickWebEngineDownloadItem::setDownloadFileName(const QString &fileName) if (d->downloadFileName != fileName && !fileName.isEmpty()) { d->downloadFileName = fileName; - Q_EMIT pathChanged(); + d->isCustomFileName = true; Q_EMIT downloadFileNameChanged(); + Q_EMIT pathChanged(); } } diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index beb359622..e1b1b9040 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -169,6 +169,7 @@ public: void setDownloadDirectory(const QString &directory); QString downloadFileName() const; void setDownloadFileName(const QString &fileName); + bool isCustomFileName; Q_SIGNALS: void stateChanged(); diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 51deee18b..acd7fe806 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -71,6 +71,7 @@ public: ~QQuickWebEngineDownloadItemPrivate(); quint32 downloadId; + qint64 startTime; QQuickWebEngineDownloadItem::DownloadState downloadState; QQuickWebEngineDownloadItem::SavePageFormat savePageFormat; QQuickWebEngineDownloadItem::DownloadType type; @@ -86,6 +87,7 @@ public: QString suggestedFileName; QString downloadDirectory; QString downloadFileName; + bool isCustomFileName; void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info); void updateState(QQuickWebEngineDownloadItem::DownloadState newState); diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index d3c4a0026..e77974a0f 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -327,6 +327,20 @@ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::forwardItems() const return d->m_forwardNavigationModel.data(); } +/*! + \qmlmethod void WebEngineHistory::clear() + \since QtWebEngine 1.11 + + Clears the history. +*/ +void QQuickWebEngineHistory::clear() +{ + Q_D(QQuickWebEngineHistory); + d->m_view->adapter->clearNavigationHistory(); + d->m_view->updateNavigationActions(); + reset(); +} + void QQuickWebEngineHistory::reset() { Q_D(QQuickWebEngineHistory); diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webengine/api/qquickwebenginehistory_p.h index bf049b2a6..5d4783e96 100644 --- a/src/webengine/api/qquickwebenginehistory_p.h +++ b/src/webengine/api/qquickwebenginehistory_p.h @@ -107,6 +107,7 @@ public: QQuickWebEngineHistoryListModel *items() const; QQuickWebEngineHistoryListModel *backItems() const; QQuickWebEngineHistoryListModel *forwardItems() const; + Q_REVISION(1) Q_INVOKABLE void clear(); void reset(); diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index edad7ec44..834bb6a05 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -245,6 +245,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url); itemPrivate->downloadId = info.id; itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested; + itemPrivate->startTime = info.startTime; itemPrivate->totalBytes = info.totalBytes; itemPrivate->mimeType = info.mimeType; itemPrivate->downloadDirectory = QFileInfo(info.path).path(); diff --git a/src/webengine/api/qquickwebenginetestsupport.cpp b/src/webengine/api/qquickwebenginetestsupport.cpp index b7b863125..bef87160e 100644 --- a/src/webengine/api/qquickwebenginetestsupport.cpp +++ b/src/webengine/api/qquickwebenginetestsupport.cpp @@ -157,7 +157,7 @@ void QQuickWebEngineTestEvent::mouseEvent(QEvent::Type type, QWindow *window, QO if (sgitem) pos = sgitem->mapToScene(_pos).toPoint(); - QMouseEvent me(type, pos, window->mapFromGlobal(pos), Qt::LeftButton, Qt::LeftButton, 0); + QMouseEvent me(type, pos, window->mapFromGlobal(pos), Qt::LeftButton, Qt::LeftButton, {}); me.setTimestamp(++QTest::lastMouseTimestamp); QSpontaneKeyEvent::setSpontaneous(&me); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 8a1a3c516..bcbf95569 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -369,11 +369,14 @@ void QQuickWebEngineViewPrivate::titleChanged(const QString &title) Q_EMIT q->titleChanged(); } -void QQuickWebEngineViewPrivate::urlChanged(const QUrl &url) +void QQuickWebEngineViewPrivate::urlChanged() { Q_Q(QQuickWebEngineView); - Q_UNUSED(url); - Q_EMIT q->urlChanged(); + QUrl url = adapter->activeUrl(); + if (m_url != url) { + m_url = url; + Q_EMIT q->urlChanged(); + } } void QQuickWebEngineViewPrivate::iconChanged(const QUrl &url) @@ -425,6 +428,12 @@ void QQuickWebEngineViewPrivate::recentlyAudibleChanged(bool recentlyAudible) Q_EMIT q->recentlyAudibleChanged(recentlyAudible); } +void QQuickWebEngineViewPrivate::renderProcessPidChanged(qint64 pid) +{ + Q_Q(QQuickWebEngineView); + Q_EMIT q->renderProcessPidChanged(pid); +} + QRectF QQuickWebEngineViewPrivate::viewportRect() const { Q_Q(const QQuickWebEngineView); @@ -741,29 +750,48 @@ QQuickWebEngineViewAccessible::QQuickWebEngineViewAccessible(QQuickWebEngineView : QAccessibleObject(o) {} +bool QQuickWebEngineViewAccessible::isValid() const +{ + if (!QAccessibleObject::isValid()) + return false; + + if (!engineView() || !engineView()->d_func()) + return false; + + return true; +} + QAccessibleInterface *QQuickWebEngineViewAccessible::parent() const { QQuickItem *parent = engineView()->parentItem(); - return QAccessible::queryAccessibleInterface(parent); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parent); + if (!iface) + return QAccessible::queryAccessibleInterface(engineView()->window()); + return iface; +} + +QAccessibleInterface *QQuickWebEngineViewAccessible::focusChild() const +{ + if (child(0) && child(0)->focusChild()) + return child(0)->focusChild(); + return const_cast<QQuickWebEngineViewAccessible *>(this); } int QQuickWebEngineViewAccessible::childCount() const { - if (engineView() && child(0)) - return 1; - return 0; + return child(0) ? 1 : 0; } QAccessibleInterface *QQuickWebEngineViewAccessible::child(int index) const { - if (index == 0) + if (index == 0 && isValid()) return engineView()->d_func()->adapter->browserAccessible(); - return 0; + return nullptr; } int QQuickWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const { - if (c == child(0)) + if (child(0) && c == child(0)) return 0; return -1; } @@ -775,7 +803,7 @@ QString QQuickWebEngineViewAccessible::text(QAccessible::Text) const QAccessible::Role QQuickWebEngineViewAccessible::role() const { - return QAccessible::Document; + return QAccessible::Client; } QAccessible::State QQuickWebEngineViewAccessible::state() const @@ -885,7 +913,7 @@ void QQuickWebEngineViewPrivate::initializationFinished() emit q->titleChanged(); emit q->urlChanged(); emit q->iconChanged(); - QQuickWebEngineLoadRequest loadRequest(adapter->activeUrl(), QQuickWebEngineView::LoadSucceededStatus); + QQuickWebEngineLoadRequest loadRequest(m_url, QQuickWebEngineView::LoadSucceededStatus); emit q->loadingChanged(&loadRequest); emit q->loadProgressChanged(); @@ -936,10 +964,17 @@ void QQuickWebEngineViewPrivate::widgetChanged(RenderWidgetHostViewQtDelegateQui { Q_Q(QQuickWebEngineView); - if (oldWidget) + if (oldWidget) { oldWidget->setParentItem(nullptr); +#if QT_CONFIG(accessibility) + QAccessible::deleteAccessibleInterface(QAccessible::uniqueId(QAccessible::queryAccessibleInterface(oldWidget))); +#endif + } if (newWidget) { +#if QT_CONFIG(accessibility) + QAccessible::registerAccessibleInterface(new QtWebEngineCore::RenderWidgetHostViewQtDelegateQuickAccessible(newWidget, q)); +#endif newWidget->setParentItem(q); newWidget->setSize(q->boundingRect().size()); // Focus on creation if the view accepts it @@ -1017,9 +1052,6 @@ void QQuickWebEngineViewPrivate::updateEditActions() QUrl QQuickWebEngineView::url() const { Q_D(const QQuickWebEngineView); - if (d->adapter->isInitialized()) - return d->adapter->activeUrl(); - else return d->m_url; } @@ -1029,13 +1061,15 @@ void QQuickWebEngineView::setUrl(const QUrl& url) if (url.isEmpty()) return; + if (d->m_url != url) { + d->m_url = url; + d->m_html.clear(); + emit urlChanged(); + } + if (d->adapter->isInitialized()) { d->adapter->load(url); - return; } - - d->m_url = url; - d->m_html.clear(); } QUrl QQuickWebEngineView::icon() const @@ -1147,14 +1181,13 @@ void QQuickWebEngineViewPrivate::updateAdapter() { // When the profile changes we need to create a new WebContentAdapter and reload the active URL. bool wasInitialized = adapter->isInitialized(); - QUrl activeUrl = adapter->activeUrl(); adapter = QSharedPointer<WebContentsAdapter>::create(); adapter->setClient(this); if (wasInitialized) { if (!m_html.isEmpty()) - adapter->setContent(m_html.toUtf8(), defaultMimeType, activeUrl); - else if (activeUrl.isValid()) - adapter->load(activeUrl); + adapter->setContent(m_html.toUtf8(), defaultMimeType, m_url); + else if (m_url.isValid()) + adapter->load(m_url); else adapter->loadDefault(); } @@ -1402,6 +1435,12 @@ bool QQuickWebEngineView::recentlyAudible() const return d->adapter->recentlyAudible(); } +qint64 QQuickWebEngineView::renderProcessPid() const +{ + const Q_D(QQuickWebEngineView); + return d->adapter->renderProcessPid(); +} + void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) { #if QT_CONFIG(webengine_printing_and_pdf) @@ -1766,10 +1805,14 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) case CopyLinkToClipboard: if (!d->m_contextMenuData.unfilteredLinkUrl().isEmpty()) { QString urlString = d->m_contextMenuData.unfilteredLinkUrl().toString(QUrl::FullyEncoded); - QString title = d->m_contextMenuData.linkText().toHtmlEscaped(); + QString linkText = d->m_contextMenuData.linkText().toHtmlEscaped(); + QString title = d->m_contextMenuData.titleText(); + if (!title.isEmpty()) + title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped()); QMimeData *data = new QMimeData(); data->setText(urlString); - QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\">") + title + QStringLiteral("</a>"); + QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral(">") + + linkText + QStringLiteral("</a>"); data->setHtml(html); data->setUrls(QList<QUrl>() << d->m_contextMenuData.unfilteredLinkUrl()); qApp->clipboard()->setMimeData(data); @@ -1791,12 +1834,15 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) case CopyImageUrlToClipboard: if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeImage) { QString urlString = d->m_contextMenuData.mediaUrl().toString(QUrl::FullyEncoded); - QString title = d->m_contextMenuData.linkText(); + QString alt = d->m_contextMenuData.altText(); + if (!alt.isEmpty()) + alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped()); + QString title = d->m_contextMenuData.titleText(); if (!title.isEmpty()) - title = QStringLiteral(" alt=\"%1\"").arg(title.toHtmlEscaped()); + title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped()); QMimeData *data = new QMimeData(); data->setText(urlString); - QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral("></img>"); + QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + alt + QStringLiteral("></img>"); data->setHtml(html); data->setUrls(QList<QUrl>() << d->m_contextMenuData.mediaUrl()); qApp->clipboard()->setMimeData(data); @@ -1814,12 +1860,17 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo)) { QString urlString = d->m_contextMenuData.mediaUrl().toString(QUrl::FullyEncoded); + QString title = d->m_contextMenuData.titleText(); + if (!title.isEmpty()) + title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped()); QMimeData *data = new QMimeData(); data->setText(urlString); if (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio) - data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"></audio>")); + data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"") + title + + QStringLiteral("></audio>")); else - data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"></video>")); + data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"") + title + + QStringLiteral("></video>")); data->setUrls(QList<QUrl>() << d->m_contextMenuData.mediaUrl()); qApp->clipboard()->setMimeData(data); } diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 618f9407e..ab84b2600 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -142,6 +142,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION 10 FINAL) Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION 10 FINAL) + Q_PROPERTY(qint64 renderProcessPid READ renderProcessPid NOTIFY renderProcessPidChanged FINAL REVISION 11) + public: QQuickWebEngineView(QQuickItem *parent = 0); ~QQuickWebEngineView(); @@ -493,6 +495,8 @@ public: void setAudioMuted(bool muted); bool recentlyAudible() const; + qint64 renderProcessPid() const; + #if QT_CONFIG(webengine_testsupport) QQuickWebEngineTestSupport *testSupport() const; void setTestSupport(QQuickWebEngineTestSupport *testSupport); @@ -520,7 +524,7 @@ public Q_SLOTS: void reload(); Q_REVISION(1) void reloadAndBypassCache(); void stop(); - Q_REVISION(1) void findText(const QString &subString, FindFlags options = 0, const QJSValue &callback = QJSValue()); + Q_REVISION(1) void findText(const QString &subString, FindFlags options = { }, const QJSValue &callback = QJSValue()); Q_REVISION(1) void fullScreenCancelled(); Q_REVISION(1) void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted); Q_REVISION(2) void setActiveFocusOnPress(bool arg); @@ -576,6 +580,7 @@ Q_SIGNALS: Q_REVISION(10) void lifecycleStateChanged(LifecycleState state); Q_REVISION(10) void recommendedStateChanged(LifecycleState state); Q_REVISION(10) void findTextFinished(const QWebEngineFindTextResult &result); + Q_REVISION(11) void renderProcessPidChanged(qint64 pid); #if QT_CONFIG(webengine_testsupport) void testSupportChanged(); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index df6843ac3..6f9b552ec 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -106,12 +106,13 @@ public: void recommendedStateChanged(LifecycleState state) override; void visibleChanged(bool visible) override; void titleChanged(const QString&) override; - void urlChanged(const QUrl&) override; + void urlChanged() override; void iconChanged(const QUrl&) override; void loadProgressChanged(int progress) override; void didUpdateTargetURL(const QUrl&) override; void selectionChanged() override; void recentlyAudibleChanged(bool recentlyAudible) override; + void renderProcessPidChanged(qint64 pid) override; QRectF viewportRect() const override; QColor backgroundColor() const override; void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override; @@ -234,7 +235,9 @@ class QQuickWebEngineViewAccessible : public QAccessibleObject { public: QQuickWebEngineViewAccessible(QQuickWebEngineView *o); + bool isValid() const override; QAccessibleInterface *parent() const override; + QAccessibleInterface *focusChild() const override; int childCount() const override; QAccessibleInterface *child(int index) const override; int indexOfChild(const QAccessibleInterface*) const override; |