From 9cb66878ff8c01c7e378156364965a2189fb9fb3 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 5 Oct 2015 17:20:53 +0200 Subject: [PATCH] Port to Qt 5.6 --- src/lib/app/mainapplication.cpp | 9 ++------- src/lib/network/networkmanager.cpp | 5 +++++ .../network/schemehandlers/qupzillaschemehandler.cpp | 4 ++-- .../network/schemehandlers/qupzillaschemehandler.h | 2 +- src/lib/webengine/webview.cpp | 12 ------------ 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index d0ab9ed5d..aa09cd1a1 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -46,7 +46,6 @@ #include "searchenginesmanager.h" #include "desktopnotificationsfactory.h" #include "html5permissions/html5permissionsmanager.h" -#include "network/schemehandlers/qupzillaschemehandler.h" #include "scripts.h" #include @@ -247,6 +246,8 @@ MainApplication::MainApplication(int &argc, char** argv) m_webProfile = isPrivate() ? new QWebEngineProfile(this) : QWebEngineProfile::defaultProfile(); connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested); + m_networkManager = new NetworkManager(this); + // Setup QWebChannel userscript QWebEngineScript script; script.setName(QSL("_qupzilla_webchannel")); @@ -278,9 +279,6 @@ MainApplication::MainApplication(int &argc, char** argv) if (!noAddons) m_plugins->loadPlugins(); - // Create scheme handlers - new QupZillaSchemeHandler(this); - BrowserWindow* window = createWindow(Qz::BW_FirstAppWindow, startUrl); connect(window, SIGNAL(startingCompleted()), this, SLOT(restoreOverrideCursor())); @@ -545,9 +543,6 @@ BrowsingLibrary* MainApplication::browsingLibrary() NetworkManager *MainApplication::networkManager() { - if (!m_networkManager) { - m_networkManager = new NetworkManager(this); - } return m_networkManager; } diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index b5b65e8cf..aae82e077 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -21,6 +21,7 @@ #include "mainapplication.h" #include "passwordmanager.h" #include "sslerrordialog.h" +#include "network/schemehandlers/qupzillaschemehandler.h" #include #include @@ -31,11 +32,15 @@ #include #include #include +#include #include NetworkManager::NetworkManager(QObject *parent) : QNetworkAccessManager(parent) { + // Create scheme handlers + mApp->webProfile()->installUrlSchemeHandler(new QupZillaSchemeHandler(this)); + connect(this, &QNetworkAccessManager::authenticationRequired, this, [this](QNetworkReply *reply, QAuthenticator *auth) { authentication(reply->url(), auth); }); diff --git a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp index 077b53a81..afe84ea60 100644 --- a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp +++ b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include static QString authorString(const char* name, const QString &mail) { @@ -38,7 +38,7 @@ static QString authorString(const char* name, const QString &mail) } QupZillaSchemeHandler::QupZillaSchemeHandler(QObject *parent) - : QWebEngineUrlSchemeHandler(QByteArrayLiteral("qupzilla"), mApp->webProfile(), parent) + : QWebEngineUrlSchemeHandler(QByteArrayLiteral("qupzilla"), parent) { } diff --git a/src/lib/network/schemehandlers/qupzillaschemehandler.h b/src/lib/network/schemehandlers/qupzillaschemehandler.h index d536c4092..2592d42d2 100644 --- a/src/lib/network/schemehandlers/qupzillaschemehandler.h +++ b/src/lib/network/schemehandlers/qupzillaschemehandler.h @@ -18,7 +18,7 @@ #ifndef QUPZILLASCHEMEHANDLER_H #define QUPZILLASCHEMEHANDLER_H -#include +#include #include #include diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 8bc01b930..0871f38aa 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -435,23 +435,17 @@ 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) @@ -715,9 +709,7 @@ void WebView::createLinkContextMenu(QMenu* menu, const WebHitTestResult &hitTest bData << hitTest.linkUrl() << hitTest.linkTitle(); menu->addAction(QIcon::fromTheme("bookmark-new"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(bData); -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) menu->addAction(QIcon::fromTheme("document-save"), tr("&Save link as..."), this, SLOT(downloadLinkToDisk())); -#endif 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->addSeparator(); @@ -738,9 +730,7 @@ void WebView::createImageContextMenu(QMenu* menu, const WebHitTestResult &hitTes menu->addAction(act); menu->addAction(QIcon::fromTheme("edit-copy"), tr("Copy image ad&dress"), this, SLOT(copyLinkToClipboard()))->setData(hitTest.imageUrl()); menu->addSeparator(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) menu->addAction(QIcon::fromTheme("document-save"), tr("&Save image as..."), this, SLOT(downloadImageToDisk())); -#endif menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send image..."), this, SLOT(sendLinkByMail()))->setData(hitTest.imageUrl()); menu->addSeparator(); @@ -833,9 +823,7 @@ void WebView::createMediaContextMenu(QMenu *menu, const WebHitTestResult &hitTes menu->addSeparator(); 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()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) menu->addAction(QIcon::fromTheme("document-save"), tr("Save Media To &Disk"), this, SLOT(downloadMediaToDisk())); -#endif } void WebView::checkForForm(QAction *action, const QPoint &pos)