mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
WebView: Enable download link/image/media actions with Qt 5.6
This commit is contained in:
parent
e60daf072b
commit
102ee62d3d
@ -433,6 +433,27 @@ void WebView::copyLinkToClipboard()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebView::downloadLinkToDisk()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
triggerPageAction(QWebEnginePage::DownloadLinkToDisk);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::downloadImageToDisk()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
triggerPageAction(QWebEnginePage::DownloadImageToDisk);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::downloadMediaToDisk()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
triggerPageAction(QWebEnginePage::DownloadMediaToDisk);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position)
|
void WebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position)
|
||||||
{
|
{
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
@ -441,24 +462,6 @@ void WebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position)
|
|||||||
loadInNewTab(request, position);
|
loadInNewTab(request, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::downloadUrlToDisk()
|
|
||||||
{
|
|
||||||
#if QTWEBENGINE_DISABLED
|
|
||||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
|
||||||
QNetworkRequest request(action->data().toUrl());
|
|
||||||
|
|
||||||
DownloadManager::DownloadInfo info;
|
|
||||||
info.page = page();
|
|
||||||
info.suggestedFileName = QString();
|
|
||||||
info.askWhatToDo = false;
|
|
||||||
info.forceChoosingPath = true;
|
|
||||||
|
|
||||||
DownloadManager* dManager = mApp->downloadManager();
|
|
||||||
dManager->download(request, info);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebView::openActionUrl()
|
void WebView::openActionUrl()
|
||||||
{
|
{
|
||||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
||||||
@ -712,8 +715,8 @@ void WebView::createLinkContextMenu(QMenu* menu, const WebHitTestResult &hitTest
|
|||||||
bData << hitTest.linkUrl() << hitTest.linkTitle();
|
bData << hitTest.linkUrl() << hitTest.linkTitle();
|
||||||
menu->addAction(QIcon::fromTheme("bookmark-new"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(bData);
|
menu->addAction(QIcon::fromTheme("bookmark-new"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(bData);
|
||||||
|
|
||||||
#if QTWEBENGINE_DISABLED
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save link as..."), this, SLOT(downloadUrlToDisk()))->setData(hitTest.linkUrl());
|
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save link as..."), this, SLOT(downloadLinkToDisk()));
|
||||||
#endif
|
#endif
|
||||||
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send link..."), this, SLOT(sendLinkByMail()))->setData(hitTest.linkUrl());
|
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send link..."), this, SLOT(sendLinkByMail()))->setData(hitTest.linkUrl());
|
||||||
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy link address"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.linkUrl());
|
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy link address"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.linkUrl());
|
||||||
@ -735,8 +738,8 @@ void WebView::createImageContextMenu(QMenu* menu, const WebHitTestResult &hitTes
|
|||||||
menu->addAction(act);
|
menu->addAction(act);
|
||||||
menu->addAction(QIcon::fromTheme("edit-copy"), tr("Copy image ad&dress"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.imageUrl());
|
menu->addAction(QIcon::fromTheme("edit-copy"), tr("Copy image ad&dress"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.imageUrl());
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
#if QTWEBENGINE_DISABLED
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save image as..."), this, SLOT(downloadUrlToDisk()))->setData(hitTest.imageUrl());
|
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save image as..."), this, SLOT(downloadImageToDisk()));
|
||||||
#endif
|
#endif
|
||||||
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send image..."), this, SLOT(sendLinkByMail()))->setData(hitTest.imageUrl());
|
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send image..."), this, SLOT(sendLinkByMail()))->setData(hitTest.imageUrl());
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
@ -830,8 +833,8 @@ void WebView::createMediaContextMenu(QMenu *menu, const WebHitTestResult &hitTes
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy Media Address"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.mediaUrl());
|
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy Media Address"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.mediaUrl());
|
||||||
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("&Send Media Address"), this, SLOT(sendLinkByMail()))->setData(hitTest.mediaUrl());
|
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("&Send Media Address"), this, SLOT(sendLinkByMail()))->setData(hitTest.mediaUrl());
|
||||||
#if QTWEBENGINE_DISABLED
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
menu->addAction(QIcon::fromTheme("document-save"), tr("Save Media To &Disk"), this, SLOT(downloadUrlToDisk()))->setData(hitTest.mediaUrl());
|
menu->addAction(QIcon::fromTheme("document-save"), tr("Save Media To &Disk"), this, SLOT(downloadMediaToDisk()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,9 @@ protected slots:
|
|||||||
void openUrlInNewWindow();
|
void openUrlInNewWindow();
|
||||||
void sendLinkByMail();
|
void sendLinkByMail();
|
||||||
void copyLinkToClipboard();
|
void copyLinkToClipboard();
|
||||||
void downloadUrlToDisk();
|
void downloadLinkToDisk();
|
||||||
|
void downloadImageToDisk();
|
||||||
|
void downloadMediaToDisk();
|
||||||
void openActionUrl();
|
void openActionUrl();
|
||||||
void showSiteInfo();
|
void showSiteInfo();
|
||||||
void searchSelectedText();
|
void searchSelectedText();
|
||||||
|
Loading…
Reference in New Issue
Block a user