diff options
Diffstat (limited to 'examples')
80 files changed, 1819 insertions, 487 deletions
diff --git a/examples/webengine/quicknanobrowser/ApplicationRoot.qml b/examples/webengine/quicknanobrowser/ApplicationRoot.qml index 91d1551a7..6735be932 100644 --- a/examples/webengine/quicknanobrowser/ApplicationRoot.qml +++ b/examples/webengine/quicknanobrowser/ApplicationRoot.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webengine/quicknanobrowser/BrowserDialog.qml b/examples/webengine/quicknanobrowser/BrowserDialog.qml index 0577bf642..d060e2828 100644 --- a/examples/webengine/quicknanobrowser/BrowserDialog.qml +++ b/examples/webengine/quicknanobrowser/BrowserDialog.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index ed49040ca..c008425d9 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -74,6 +84,8 @@ ApplicationWindow { property alias errorPageEnabled: errorPageEnabled.checked; property alias pluginsEnabled: pluginsEnabled.checked; property alias fullScreenSupportEnabled: fullScreenSupportEnabled.checked; + property alias autoLoadIconsForPage: autoLoadIconsForPage.checked; + property alias touchIconsEnabled: touchIconsEnabled.checked; } Action { @@ -225,6 +237,7 @@ ApplicationWindow { z: 2 id: faviconImage width: 16; height: 16 + sourceSize: Qt.size(width, height) source: currentWebView && currentWebView.icon } style: TextFieldStyle { @@ -284,6 +297,19 @@ ApplicationWindow { checked: (currentWebView.profile.httpCacheType == WebEngineProfile.DiskHttpCache) onToggled: currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache } + MenuItem { + id: autoLoadIconsForPage + text: "Icons On" + checkable: true + checked: WebEngine.settings.autoLoadIconsForPage + } + MenuItem { + id: touchIconsEnabled + text: "Touch Icons On" + checkable: true + checked: WebEngine.settings.touchIconsEnabled + enabled: autoLoadIconsForPage.checked + } } } } @@ -355,6 +381,8 @@ ApplicationWindow { settings.errorPageEnabled: appSettings.errorPageEnabled settings.pluginsEnabled: appSettings.pluginsEnabled settings.fullScreenSupportEnabled: appSettings.fullScreenSupportEnabled + settings.autoLoadIconsForPage: appSettings.autoLoadIconsForPage + settings.touchIconsEnabled: appSettings.touchIconsEnabled onCertificateError: { error.defer() diff --git a/examples/webengine/quicknanobrowser/DownloadView.qml b/examples/webengine/quicknanobrowser/DownloadView.qml index c17a8bd60..13be4bd78 100644 --- a/examples/webengine/quicknanobrowser/DownloadView.qml +++ b/examples/webengine/quicknanobrowser/DownloadView.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webengine/quicknanobrowser/doc/src/quicknanobrowser.qdoc b/examples/webengine/quicknanobrowser/doc/src/quicknanobrowser.qdoc index 3643cfce7..75c2997e8 100644 --- a/examples/webengine/quicknanobrowser/doc/src/quicknanobrowser.qdoc +++ b/examples/webengine/quicknanobrowser/doc/src/quicknanobrowser.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/webengine/quicknanobrowser/main.cpp b/examples/webengine/quicknanobrowser/main.cpp index 31ab26f6f..94d6f8519 100644 --- a/examples/webengine/quicknanobrowser/main.cpp +++ b/examples/webengine/quicknanobrowser/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webengine/quicknanobrowser/utils.h b/examples/webengine/quicknanobrowser/utils.h index 84cac6363..79aa38cc7 100644 --- a/examples/webengine/quicknanobrowser/utils.h +++ b/examples/webengine/quicknanobrowser/utils.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,7 +47,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - #ifndef UTILS_H #define UTILS_H diff --git a/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc b/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc index f16634d0f..aa94b17da 100644 --- a/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc +++ b/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/webenginewidgets/contentmanipulation/main.cpp b/examples/webenginewidgets/contentmanipulation/main.cpp index 2c6f77c60..5645f9b9a 100644 --- a/examples/webenginewidgets/contentmanipulation/main.cpp +++ b/examples/webenginewidgets/contentmanipulation/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/contentmanipulation/mainwindow.cpp b/examples/webenginewidgets/contentmanipulation/mainwindow.cpp index d3552ac86..3198f0908 100644 --- a/examples/webenginewidgets/contentmanipulation/mainwindow.cpp +++ b/examples/webenginewidgets/contentmanipulation/mainwindow.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/contentmanipulation/mainwindow.h b/examples/webenginewidgets/contentmanipulation/mainwindow.h index 06b8aba03..66512f969 100644 --- a/examples/webenginewidgets/contentmanipulation/mainwindow.h +++ b/examples/webenginewidgets/contentmanipulation/mainwindow.h @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/autosaver.cpp b/examples/webenginewidgets/demobrowser/autosaver.cpp index 53e89b448..005e291bd 100644 --- a/examples/webenginewidgets/demobrowser/autosaver.cpp +++ b/examples/webenginewidgets/demobrowser/autosaver.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/autosaver.h b/examples/webenginewidgets/demobrowser/autosaver.h index a166e0c5e..be6eeeb4c 100644 --- a/examples/webenginewidgets/demobrowser/autosaver.h +++ b/examples/webenginewidgets/demobrowser/autosaver.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/bookmarks.cpp b/examples/webenginewidgets/demobrowser/bookmarks.cpp index dab6bba51..3d6d9c294 100644 --- a/examples/webenginewidgets/demobrowser/bookmarks.cpp +++ b/examples/webenginewidgets/demobrowser/bookmarks.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/bookmarks.h b/examples/webenginewidgets/demobrowser/bookmarks.h index f9d2e7ec3..922e7ce39 100644 --- a/examples/webenginewidgets/demobrowser/bookmarks.h +++ b/examples/webenginewidgets/demobrowser/bookmarks.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/browserapplication.cpp b/examples/webenginewidgets/demobrowser/browserapplication.cpp index dc071dabd..26764b93c 100644 --- a/examples/webenginewidgets/demobrowser/browserapplication.cpp +++ b/examples/webenginewidgets/demobrowser/browserapplication.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -62,7 +72,6 @@ #include <QtNetwork/QLocalServer> #include <QtNetwork/QLocalSocket> #include <QtNetwork/QNetworkProxy> -#include <QtNetwork/QNetworkReply> #include <QtNetwork/QSslSocket> #include <QWebEngineProfile> @@ -287,6 +296,21 @@ void BrowserApplication::loadSettings() defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString()); defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString()); + + switch (settings.value(QLatin1String("faviconDownloadMode"), 1).toInt()) { + case 0: + defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); + break; + case 1: + defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true); + defaultSettings->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); + break; + case 2: + defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true); + defaultSettings->setAttribute(QWebEngineSettings::TouchIconsEnabled, true); + break; + } + settings.endGroup(); settings.beginGroup(QLatin1String("cookies")); @@ -501,10 +525,6 @@ QNetworkAccessManager *BrowserApplication::networkAccessManager() { if (!s_networkAccessManager) { s_networkAccessManager = new QNetworkAccessManager(); - connect(s_networkAccessManager, &QNetworkAccessManager::authenticationRequired, - BrowserApplication::instance(), &BrowserApplication::authenticationRequired); - connect(s_networkAccessManager, &QNetworkAccessManager::proxyAuthenticationRequired, - BrowserApplication::instance(), &BrowserApplication::proxyAuthenticationRequired); } return s_networkAccessManager; } @@ -563,68 +583,3 @@ void BrowserApplication::setPrivateBrowsing(bool privateBrowsing) } emit privateBrowsingChanged(privateBrowsing); } - -void BrowserApplication::setLastAuthenticator(QAuthenticator *authenticator) -{ - m_lastAuthenticator = QAuthenticator(*authenticator); -} - -void BrowserApplication::setLastProxyAuthenticator(QAuthenticator *authenticator) -{ - m_lastProxyAuthenticator = QAuthenticator(*authenticator); -} - -void BrowserApplication::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) -{ - if (m_lastAuthenticator.isNull()) - return; - - - Q_ASSERT(m_lastAuthenticator.option("key").isValid()); - QByteArray lastKey = m_lastAuthenticator.option("key").toByteArray(); - QByteArray key = BrowserApplication::authenticationKey(reply->url(), authenticator->realm()); - - if (lastKey == key) - *authenticator = m_lastAuthenticator; -} - -void BrowserApplication::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) -{ - if (m_lastProxyAuthenticator.isNull()) - return; - - QNetworkProxy::ProxyType proxyType = proxy.type(); - if (proxyType != QNetworkProxy::HttpProxy || proxyType != QNetworkProxy::HttpCachingProxy) - return; - - Q_ASSERT(m_lastProxyAuthenticator.option("host").isValid()); - QByteArray lastKey = m_lastProxyAuthenticator.option("key").toByteArray(); - QByteArray key = BrowserApplication::proxyAuthenticationKey(proxy, authenticator->realm()); - - if (lastKey == key) - *authenticator = m_lastAuthenticator; -} - -// TODO: Remove these functions (QTBUG-47967) -QByteArray BrowserApplication::authenticationKey(const QUrl &url, const QString &realm) -{ - QUrl copy = url; - copy.setFragment(realm); - return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery); -} - -QByteArray BrowserApplication::proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm) -{ - QString host = QString("%1:%2").arg(proxy.hostName()).arg(proxy.port()); - return BrowserApplication::proxyAuthenticationKey(proxy.user(), host, realm); -} - -QByteArray BrowserApplication::proxyAuthenticationKey(const QString &user, const QString &host, const QString &realm) -{ - QUrl key; - key.setScheme(QLatin1String("proxy-http")); - key.setUserName(user); - key.setHost(host); - key.setFragment(realm); - return "auth:" + key.toEncoded(); -} diff --git a/examples/webenginewidgets/demobrowser/browserapplication.h b/examples/webenginewidgets/demobrowser/browserapplication.h index b9832531a..5c75d41b3 100644 --- a/examples/webenginewidgets/demobrowser/browserapplication.h +++ b/examples/webenginewidgets/demobrowser/browserapplication.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -53,8 +63,6 @@ QT_BEGIN_NAMESPACE class QLocalServer; class QNetworkAccessManager; -class QNetworkProxy; -class QNetworkReply; class QWebEngineProfile; QT_END_NAMESPACE @@ -83,14 +91,6 @@ public: bool canRestoreSession() const; bool privateBrowsing() const { return m_privateBrowsing; } - void setLastAuthenticator(QAuthenticator *); - void setLastProxyAuthenticator(QAuthenticator *); - - // TODO: Remove these functions (QTBUG-47967) - static QByteArray authenticationKey(const QUrl &, const QString &); - static QByteArray proxyAuthenticationKey(const QNetworkProxy &, const QString &); - static QByteArray proxyAuthenticationKey(const QString &, const QString &, const QString &); - static HistoryManager *historyManager(); static CookieJar *cookieJar(); static DownloadManager *downloadManager(); @@ -107,8 +107,6 @@ public slots: void lastWindowClosed(); void quitBrowser(); void setPrivateBrowsing(bool); - void authenticationRequired(QNetworkReply *, QAuthenticator *); - void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *); signals: void privateBrowsingChanged(bool); diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp index 5d3fa47e5..14ed10dfc 100644 --- a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp +++ b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -46,6 +56,7 @@ #include "chasewidget.h" #include "downloadmanager.h" #include "history.h" +#include "printtopdfdialog.h" #include "settings.h" #include "tabwidget.h" #include "toolbarsearch.h" @@ -302,8 +313,10 @@ void BrowserMainWindow::setupMenu() #if defined(QWEBENGINEPAGE_PRINT) fileMenu->addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview())); fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); - fileMenu->addSeparator(); #endif + fileMenu->addAction(tr("&Print to PDF..."), this, SLOT(slotFilePrintToPDF())); + fileMenu->addSeparator(); + QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); action->setCheckable(true); action->setChecked(BrowserApplication::instance()->privateBrowsing()); @@ -686,6 +699,36 @@ void BrowserMainWindow::slotFilePrint() #endif } +void BrowserMainWindow::slotHandlePdfPrinted(const QByteArray& result) +{ + if (!result.size()) + return; + + QFile file(m_printerOutputFileName); + + m_printerOutputFileName.clear(); + if (!file.open(QFile::WriteOnly)) + return; + + file.write(result.data(), result.size()); + file.close(); +} + +void BrowserMainWindow::slotFilePrintToPDF() +{ + if (!currentTab() || !m_printerOutputFileName.isEmpty()) + return; + + QFileInfo info(QStringLiteral("printout.pdf")); + PrintToPdfDialog *dialog = new PrintToPdfDialog(info.absoluteFilePath(), this); + dialog->setWindowTitle(tr("Print to PDF")); + if (dialog->exec() != QDialog::Accepted || dialog->filePath().isEmpty()) + return; + + m_printerOutputFileName = dialog->filePath(); + currentTab()->page()->printToPdf(invoke(this, &BrowserMainWindow::slotHandlePdfPrinted), dialog->pageLayout()); +} + #if defined(QWEBENGINEPAGE_PRINT) void BrowserMainWindow::printRequested(QWebEngineFrame *frame) { diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.h b/examples/webenginewidgets/demobrowser/browsermainwindow.h index 5387b3d8c..9fb6b0851 100644 --- a/examples/webenginewidgets/demobrowser/browsermainwindow.h +++ b/examples/webenginewidgets/demobrowser/browsermainwindow.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -99,6 +109,7 @@ private slots: void slotFileOpen(); void slotFilePrintPreview(); void slotFilePrint(); + void slotFilePrintToPDF(); void slotPrivateBrowsing(); void slotFileSaveAs(); void slotEditFind(); @@ -127,6 +138,7 @@ private slots: void slotOpenActionUrl(QAction *action); void slotShowWindow(); void slotSwapFocus(); + void slotHandlePdfPrinted(const QByteArray&); #if defined(QWEBENGINEPAGE_PRINT) void printRequested(QWebEngineFrame *frame); @@ -169,6 +181,7 @@ private: QIcon m_stopIcon; QString m_lastSearch; + QString m_printerOutputFileName; friend class BrowserApplication; }; diff --git a/examples/webenginewidgets/demobrowser/chasewidget.cpp b/examples/webenginewidgets/demobrowser/chasewidget.cpp index 18f040824..0f066bc73 100644 --- a/examples/webenginewidgets/demobrowser/chasewidget.cpp +++ b/examples/webenginewidgets/demobrowser/chasewidget.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/chasewidget.h b/examples/webenginewidgets/demobrowser/chasewidget.h index 325cd5e19..63a8ff310 100644 --- a/examples/webenginewidgets/demobrowser/chasewidget.h +++ b/examples/webenginewidgets/demobrowser/chasewidget.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/cookiejar.cpp b/examples/webenginewidgets/demobrowser/cookiejar.cpp index 11a8562c3..479601ee3 100644 --- a/examples/webenginewidgets/demobrowser/cookiejar.cpp +++ b/examples/webenginewidgets/demobrowser/cookiejar.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/cookiejar.h b/examples/webenginewidgets/demobrowser/cookiejar.h index 00fb70009..3f8707955 100644 --- a/examples/webenginewidgets/demobrowser/cookiejar.h +++ b/examples/webenginewidgets/demobrowser/cookiejar.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/demobrowser.pro b/examples/webenginewidgets/demobrowser/demobrowser.pro index dd5cb8006..aef7b9eac 100644 --- a/examples/webenginewidgets/demobrowser/demobrowser.pro +++ b/examples/webenginewidgets/demobrowser/demobrowser.pro @@ -15,7 +15,9 @@ FORMS += \ downloads.ui \ history.ui \ passworddialog.ui \ + printtopdfdialog.ui \ proxy.ui \ + savepagedialog.ui \ settings.ui HEADERS += \ @@ -31,6 +33,8 @@ HEADERS += \ fullscreennotification.h \ history.h \ modelmenu.h \ + printtopdfdialog.h \ + savepagedialog.h \ searchlineedit.h \ settings.h \ squeezelabel.h \ @@ -53,6 +57,8 @@ SOURCES += \ fullscreennotification.cpp \ history.cpp \ modelmenu.cpp \ + printtopdfdialog.cpp \ + savepagedialog.cpp \ searchlineedit.cpp \ settings.cpp \ squeezelabel.cpp \ diff --git a/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc index ba61dd79d..dfd7a7a3d 100644 --- a/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc +++ b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/webenginewidgets/demobrowser/downloadmanager.cpp b/examples/webenginewidgets/demobrowser/downloadmanager.cpp index 8cfa66e38..33893c912 100644 --- a/examples/webenginewidgets/demobrowser/downloadmanager.cpp +++ b/examples/webenginewidgets/demobrowser/downloadmanager.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/downloadmanager.h b/examples/webenginewidgets/demobrowser/downloadmanager.h index 794f17aef..ea5a7e79d 100644 --- a/examples/webenginewidgets/demobrowser/downloadmanager.h +++ b/examples/webenginewidgets/demobrowser/downloadmanager.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/edittableview.cpp b/examples/webenginewidgets/demobrowser/edittableview.cpp index 8ab5327da..4d237ecd9 100644 --- a/examples/webenginewidgets/demobrowser/edittableview.cpp +++ b/examples/webenginewidgets/demobrowser/edittableview.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/edittableview.h b/examples/webenginewidgets/demobrowser/edittableview.h index 4d23b607d..1acee59f1 100644 --- a/examples/webenginewidgets/demobrowser/edittableview.h +++ b/examples/webenginewidgets/demobrowser/edittableview.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/edittreeview.cpp b/examples/webenginewidgets/demobrowser/edittreeview.cpp index 001491032..f4c9a0d70 100644 --- a/examples/webenginewidgets/demobrowser/edittreeview.cpp +++ b/examples/webenginewidgets/demobrowser/edittreeview.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/edittreeview.h b/examples/webenginewidgets/demobrowser/edittreeview.h index 5dbb8b5d1..f9dcd5e63 100644 --- a/examples/webenginewidgets/demobrowser/edittreeview.h +++ b/examples/webenginewidgets/demobrowser/edittreeview.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp b/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp index 743542904..4cac05082 100644 --- a/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp +++ b/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/featurepermissionbar.h b/examples/webenginewidgets/demobrowser/featurepermissionbar.h index eb5dbf876..63290df3b 100644 --- a/examples/webenginewidgets/demobrowser/featurepermissionbar.h +++ b/examples/webenginewidgets/demobrowser/featurepermissionbar.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/fullscreennotification.cpp b/examples/webenginewidgets/demobrowser/fullscreennotification.cpp index 7b9dcd1db..aadabbadb 100644 --- a/examples/webenginewidgets/demobrowser/fullscreennotification.cpp +++ b/examples/webenginewidgets/demobrowser/fullscreennotification.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/fullscreennotification.h b/examples/webenginewidgets/demobrowser/fullscreennotification.h index b0cba215b..260f8e72f 100644 --- a/examples/webenginewidgets/demobrowser/fullscreennotification.h +++ b/examples/webenginewidgets/demobrowser/fullscreennotification.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/history.cpp b/examples/webenginewidgets/demobrowser/history.cpp index ff8258647..bce65b917 100644 --- a/examples/webenginewidgets/demobrowser/history.cpp +++ b/examples/webenginewidgets/demobrowser/history.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/history.h b/examples/webenginewidgets/demobrowser/history.h index edf7722c4..2a6dce9e1 100644 --- a/examples/webenginewidgets/demobrowser/history.h +++ b/examples/webenginewidgets/demobrowser/history.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/main.cpp b/examples/webenginewidgets/demobrowser/main.cpp index 7bb55780f..41cae306a 100644 --- a/examples/webenginewidgets/demobrowser/main.cpp +++ b/examples/webenginewidgets/demobrowser/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/modelmenu.cpp b/examples/webenginewidgets/demobrowser/modelmenu.cpp index d3ba1e129..9064320f4 100644 --- a/examples/webenginewidgets/demobrowser/modelmenu.cpp +++ b/examples/webenginewidgets/demobrowser/modelmenu.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/modelmenu.h b/examples/webenginewidgets/demobrowser/modelmenu.h index a4b9e0eac..718b1d3cf 100644 --- a/examples/webenginewidgets/demobrowser/modelmenu.h +++ b/examples/webenginewidgets/demobrowser/modelmenu.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp b/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp new file mode 100644 index 000000000..0f3b1765e --- /dev/null +++ b/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "printtopdfdialog.h" +#include "ui_printtopdfdialog.h" + +#include <QtCore/QDir> +#ifndef QT_NO_PRINTER +#include <QtPrintSupport/QPageSetupDialog> +#include <QtPrintSupport/QPrinter> +#endif // QT_NO_PRINTER +#include <QtWidgets/QFileDialog> + +PrintToPdfDialog::PrintToPdfDialog(const QString &filePath, QWidget *parent) : + QDialog(parent), + currentPageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0.0, 0.0, 0.0, 0.0))), + ui(new Ui::PrintToPdfDialog) +{ + ui->setupUi(this); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + connect(ui->chooseFilePathButton, &QToolButton::clicked, this, &PrintToPdfDialog::onChooseFilePathButtonClicked); +#ifndef QT_NO_PRINTER + connect(ui->choosePageLayoutButton, &QToolButton::clicked, this, &PrintToPdfDialog::onChoosePageLayoutButtonClicked); +#else + ui->choosePageLayoutButton->hide(); +#endif // QT_NO_PRINTER + updatePageLayoutLabel(); + setFilePath(filePath); +} + +PrintToPdfDialog::~PrintToPdfDialog() +{ + delete ui; +} + +void PrintToPdfDialog::onChoosePageLayoutButtonClicked() +{ +#ifndef QT_NO_PRINTER + QPrinter printer; + printer.setPageLayout(currentPageLayout); + + QPageSetupDialog dlg(&printer, this); + if (dlg.exec() != QDialog::Accepted) + return; + currentPageLayout.setPageSize(printer.pageLayout().pageSize()); + currentPageLayout.setOrientation(printer.pageLayout().orientation()); + updatePageLayoutLabel(); +#endif // QT_NO_PRINTER +} + +void PrintToPdfDialog::onChooseFilePathButtonClicked() +{ + QFileInfo fi(filePath()); + QFileDialog dlg(this, tr("Save PDF as"), fi.absolutePath()); + dlg.setAcceptMode(QFileDialog::AcceptSave); + dlg.setDefaultSuffix(QStringLiteral(".pdf")); + dlg.selectFile(fi.absoluteFilePath()); + if (dlg.exec() != QDialog::Accepted) + return; + setFilePath(dlg.selectedFiles().first()); +} + +QString PrintToPdfDialog::filePath() const +{ + return QDir::fromNativeSeparators(ui->filePathLineEdit->text()); +} + +void PrintToPdfDialog::setFilePath(const QString &filePath) +{ + ui->filePathLineEdit->setText(QDir::toNativeSeparators(filePath)); +} + +QPageLayout PrintToPdfDialog::pageLayout() const +{ + return currentPageLayout; +} + +void PrintToPdfDialog::updatePageLayoutLabel() +{ + ui->pageLayoutLabel->setText(QString("%1, %2").arg( + currentPageLayout.pageSize().name()).arg( + currentPageLayout.orientation() == QPageLayout::Portrait + ? tr("Portrait") : tr("Landscape") + )); +} diff --git a/examples/webenginewidgets/demobrowser/printtopdfdialog.h b/examples/webenginewidgets/demobrowser/printtopdfdialog.h new file mode 100644 index 000000000..87fca72c3 --- /dev/null +++ b/examples/webenginewidgets/demobrowser/printtopdfdialog.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PRINTTOPDFDIALOG_H +#define PRINTTOPDFDIALOG_H + +#include <QDialog> +#include <QPageLayout> + +QT_BEGIN_NAMESPACE +namespace Ui { +class PrintToPdfDialog; +} +QT_END_NAMESPACE + +class PrintToPdfDialog : public QDialog +{ + Q_OBJECT + +public: + explicit PrintToPdfDialog(const QString &filePath, QWidget *parent = 0); + ~PrintToPdfDialog(); + + QString filePath() const; + QPageLayout pageLayout() const; + +private slots: + void onChoosePageLayoutButtonClicked(); + void onChooseFilePathButtonClicked(); + +private: + void setFilePath(const QString &); + void updatePageLayoutLabel(); + + QPageLayout currentPageLayout; + Ui::PrintToPdfDialog *ui; +}; + +#endif // PRINTTOPDFDIALOG_H diff --git a/examples/webenginewidgets/demobrowser/printtopdfdialog.ui b/examples/webenginewidgets/demobrowser/printtopdfdialog.ui new file mode 100644 index 000000000..dcfd5a3aa --- /dev/null +++ b/examples/webenginewidgets/demobrowser/printtopdfdialog.ui @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PrintToPdfDialog</class> + <widget class="QDialog" name="PrintToPdfDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>372</width> + <height>117</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="2" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="3"> + <widget class="QToolButton" name="choosePageLayoutButton"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="filePathLabel"> + <property name="text"> + <string>Save as:</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLineEdit" name="filePathLineEdit"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="layoutLabel"> + <property name="text"> + <string>Page layout:</string> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QToolButton" name="chooseFilePathButton"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="pageLayoutLabel"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PrintToPdfDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PrintToPdfDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/examples/webenginewidgets/demobrowser/savepagedialog.cpp b/examples/webenginewidgets/demobrowser/savepagedialog.cpp new file mode 100644 index 000000000..8ec21f821 --- /dev/null +++ b/examples/webenginewidgets/demobrowser/savepagedialog.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "savepagedialog.h" +#include "ui_savepagedialog.h" + +#include <QtCore/QDir> +#include <QtWidgets/QFileDialog> + +const QWebEngineDownloadItem::SavePageFormat SavePageDialog::m_indexToFormatTable[] = { + QWebEngineDownloadItem::SingleHtmlSaveFormat, + QWebEngineDownloadItem::CompleteHtmlSaveFormat, + QWebEngineDownloadItem::MimeHtmlSaveFormat +}; + +SavePageDialog::SavePageDialog(QWidget *parent, QWebEngineDownloadItem::SavePageFormat format, + const QString &filePath) + : QDialog(parent) + , ui(new Ui::SavePageDialog) +{ + ui->setupUi(this); + ui->formatComboBox->setCurrentIndex(formatToIndex(format)); + setFilePath(filePath); +} + +SavePageDialog::~SavePageDialog() +{ + delete ui; +} + +QWebEngineDownloadItem::SavePageFormat SavePageDialog::pageFormat() const +{ + return indexToFormat(ui->formatComboBox->currentIndex()); +} + +QString SavePageDialog::filePath() const +{ + return QDir::fromNativeSeparators(ui->filePathLineEdit->text()); +} + +void SavePageDialog::on_chooseFilePathButton_clicked() +{ + QFileInfo fi(filePath()); + QFileDialog dlg(this, tr("Save Page As"), fi.absolutePath()); + dlg.setAcceptMode(QFileDialog::AcceptSave); + dlg.setDefaultSuffix(suffixOfFormat(pageFormat())); + dlg.selectFile(fi.absoluteFilePath()); + if (dlg.exec() != QDialog::Accepted) + return; + setFilePath(dlg.selectedFiles().first()); + ensureFileSuffix(pageFormat()); +} + +void SavePageDialog::on_formatComboBox_currentIndexChanged(int idx) +{ + ensureFileSuffix(indexToFormat(idx)); +} + +int SavePageDialog::formatToIndex(QWebEngineDownloadItem::SavePageFormat format) +{ + for (auto i : m_indexToFormatTable) { + if (m_indexToFormatTable[i] == format) + return i; + } + Q_UNREACHABLE(); +} + +QWebEngineDownloadItem::SavePageFormat SavePageDialog::indexToFormat(int idx) +{ + Q_ASSERT(idx >= 0 && size_t(idx) < (sizeof(m_indexToFormatTable) + / sizeof(QWebEngineDownloadItem::SavePageFormat))); + return m_indexToFormatTable[idx]; +} + +QString SavePageDialog::suffixOfFormat(QWebEngineDownloadItem::SavePageFormat format) +{ + if (format == QWebEngineDownloadItem::MimeHtmlSaveFormat) + return QStringLiteral(".mhtml"); + return QStringLiteral(".html"); +} + +void SavePageDialog::setFilePath(const QString &filePath) +{ + ui->filePathLineEdit->setText(QDir::toNativeSeparators(filePath)); +} + +void SavePageDialog::ensureFileSuffix(QWebEngineDownloadItem::SavePageFormat format) +{ + QFileInfo fi(filePath()); + setFilePath(fi.absolutePath() + QLatin1Char('/') + fi.completeBaseName() + + suffixOfFormat(format)); +} diff --git a/examples/webenginewidgets/demobrowser/savepagedialog.h b/examples/webenginewidgets/demobrowser/savepagedialog.h new file mode 100644 index 000000000..77095543c --- /dev/null +++ b/examples/webenginewidgets/demobrowser/savepagedialog.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SAVEPAGEDIALOG_H +#define SAVEPAGEDIALOG_H + +#include <QtWidgets/QDialog> +#include <QtWebEngineWidgets/QWebEngineDownloadItem> + +QT_BEGIN_NAMESPACE +namespace Ui { +class SavePageDialog; +} +QT_END_NAMESPACE + +class SavePageDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SavePageDialog(QWidget *parent, QWebEngineDownloadItem::SavePageFormat format, + const QString &filePath); + ~SavePageDialog(); + + QWebEngineDownloadItem::SavePageFormat pageFormat() const; + QString filePath() const; + +private slots: + void on_chooseFilePathButton_clicked(); + void on_formatComboBox_currentIndexChanged(int idx); + +private: + static int formatToIndex(QWebEngineDownloadItem::SavePageFormat format); + static QWebEngineDownloadItem::SavePageFormat indexToFormat(int idx); + static QString suffixOfFormat(QWebEngineDownloadItem::SavePageFormat format); + void setFilePath(const QString &filePath); + void ensureFileSuffix(QWebEngineDownloadItem::SavePageFormat format); + + static const QWebEngineDownloadItem::SavePageFormat m_indexToFormatTable[]; + Ui::SavePageDialog *ui; +}; + +#endif // SAVEPAGEDIALOG_H diff --git a/examples/webenginewidgets/demobrowser/savepagedialog.ui b/examples/webenginewidgets/demobrowser/savepagedialog.ui new file mode 100644 index 000000000..9aa7cbe55 --- /dev/null +++ b/examples/webenginewidgets/demobrowser/savepagedialog.ui @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SavePageDialog</class> + <widget class="QDialog" name="SavePageDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>121</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>&Format:</string> + </property> + <property name="buddy"> + <cstring>formatComboBox</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="formatComboBox"> + <item> + <property name="text"> + <string>Single HTML</string> + </property> + </item> + <item> + <property name="text"> + <string>Complete HTML</string> + </property> + </item> + <item> + <property name="text"> + <string>MIME HTML</string> + </property> + </item> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>&Save to:</string> + </property> + <property name="buddy"> + <cstring>filePathLineEdit</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="filePathLineEdit"/> + </item> + <item> + <widget class="QToolButton" name="chooseFilePathButton"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>12</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>formatComboBox</tabstop> + <tabstop>filePathLineEdit</tabstop> + <tabstop>chooseFilePathButton</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>SavePageDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>227</x> + <y>104</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>120</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>SavePageDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>295</x> + <y>110</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>120</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/examples/webenginewidgets/demobrowser/searchlineedit.cpp b/examples/webenginewidgets/demobrowser/searchlineedit.cpp index c322d2489..04f75df91 100644 --- a/examples/webenginewidgets/demobrowser/searchlineedit.cpp +++ b/examples/webenginewidgets/demobrowser/searchlineedit.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/searchlineedit.h b/examples/webenginewidgets/demobrowser/searchlineedit.h index 68d75aa66..9b9587082 100644 --- a/examples/webenginewidgets/demobrowser/searchlineedit.h +++ b/examples/webenginewidgets/demobrowser/searchlineedit.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/settings.cpp b/examples/webenginewidgets/demobrowser/settings.cpp index 9e9a7154c..aa3110ae7 100644 --- a/examples/webenginewidgets/demobrowser/settings.cpp +++ b/examples/webenginewidgets/demobrowser/settings.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -104,6 +114,13 @@ void SettingsDialog::loadDefaults() sessionCookiesCombo->setCurrentIndex(QWebEngineProfile::defaultProfile()->persistentCookiesPolicy()); httpUserAgent->setText(QWebEngineProfile::defaultProfile()->httpUserAgent()); httpAcceptLanguage->setText(defaultAcceptLanguage()); + + if (!defaultSettings->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)) + faviconDownloadMode->setCurrentIndex(0); + else if (!defaultSettings->testAttribute(QWebEngineSettings::TouchIconsEnabled)) + faviconDownloadMode->setCurrentIndex(1); + else + faviconDownloadMode->setCurrentIndex(2); } void SettingsDialog::loadFromSettings() @@ -154,6 +171,7 @@ void SettingsDialog::loadFromSettings() enableScrollAnimator->setChecked(settings.value(QLatin1String("enableScrollAnimator"), enableScrollAnimator->isChecked()).toBool()); httpUserAgent->setText(settings.value(QLatin1String("httpUserAgent"), httpUserAgent->text()).toString()); httpAcceptLanguage->setText(settings.value(QLatin1String("httpAcceptLanguage"), httpAcceptLanguage->text()).toString()); + faviconDownloadMode->setCurrentIndex(settings.value(QLatin1String("faviconDownloadMode"), faviconDownloadMode->currentIndex()).toInt()); settings.endGroup(); // Privacy @@ -213,6 +231,7 @@ void SettingsDialog::saveToSettings() settings.setValue(QLatin1String("userStyleSheet"), userStyleSheet->toPlainText()); settings.setValue(QLatin1String("httpUserAgent"), httpUserAgent->text()); settings.setValue(QLatin1String("httpAcceptLanguage"), httpAcceptLanguage->text()); + settings.setValue(QLatin1String("faviconDownloadMode"), faviconDownloadMode->currentIndex()); settings.endGroup(); //Privacy diff --git a/examples/webenginewidgets/demobrowser/settings.h b/examples/webenginewidgets/demobrowser/settings.h index 968f92cb9..ff5795609 100644 --- a/examples/webenginewidgets/demobrowser/settings.h +++ b/examples/webenginewidgets/demobrowser/settings.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/settings.ui b/examples/webenginewidgets/demobrowser/settings.ui index 38a7af344..c78a52dfe 100644 --- a/examples/webenginewidgets/demobrowser/settings.ui +++ b/examples/webenginewidgets/demobrowser/settings.ui @@ -27,13 +27,26 @@ <item row="1" column="0"> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> - <number>4</number> + <number>0</number> </property> <widget class="QWidget" name="tab"> <attribute name="title"> <string>General</string> </attribute> <layout class="QGridLayout" name="gridLayout_4"> + <item row="1" column="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>280</width> + <height>18</height> + </size> + </property> + </spacer> + </item> <item row="0" column="0"> <widget class="QLabel" name="label_3"> <property name="text"> @@ -47,36 +60,63 @@ <item row="0" column="1" colspan="2"> <widget class="QLineEdit" name="homeLineEdit"/> </item> - <item row="1" column="1"> - <widget class="QPushButton" name="setHomeToCurrentPageButton"> - <property name="text"> - <string>Set to current page</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <spacer name="horizontalSpacer"> + <item row="7" column="1" colspan="2"> + <spacer> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>280</width> - <height>18</height> + <width>391</width> + <height>262</height> </size> </property> </spacer> </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> + <item row="3" column="0"> + <widget class="QLabel" name="label_7"> <property name="text"> - <string>Remove history items:</string> + <string>Save downloads to:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Open links from applications:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> + <item row="6" column="1" colspan="2"> + <widget class="QCheckBox" name="enableScrollAnimator"> + <property name="text"> + <string>Enable Scroll Animator</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="1" colspan="2"> + <widget class="QComboBox" name="openLinksIn"> + <item> + <property name="text"> + <string>In a tab in the current window</string> + </property> + </item> + <item> + <property name="text"> + <string>In a new window</string> + </property> + </item> + </widget> + </item> <item row="2" column="1" colspan="2"> <widget class="QComboBox" name="expireHistory"> <item> @@ -111,10 +151,10 @@ </item> </widget> </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_7"> + <item row="2" column="0"> + <widget class="QLabel" name="label_4"> <property name="text"> - <string>Save downloads to:</string> + <string>Remove history items:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -124,53 +164,45 @@ <item row="3" column="1" colspan="2"> <widget class="QLineEdit" name="downloadsLocation"/> </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_8"> + <item row="1" column="1"> + <widget class="QPushButton" name="setHomeToCurrentPageButton"> <property name="text"> - <string>Open links from applications:</string> + <string>Set to current page</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string>Favicon download mode:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> - <item row="4" column="1" colspan="2"> - <widget class="QComboBox" name="openLinksIn"> + <item row="5" column="1" colspan="2"> + <widget class="QComboBox" name="faviconDownloadMode"> + <property name="currentIndex"> + <number>1</number> + </property> <item> <property name="text"> - <string>In a tab in the current window</string> + <string>Disable icons</string> </property> </item> <item> <property name="text"> - <string>In a new window</string> + <string>Enable favicons</string> + </property> + </item> + <item> + <property name="text"> + <string>Enable favicons and touch icons</string> </property> </item> </widget> </item> - <item row="5" column="1" colspan="2"> - <widget class="QCheckBox" name="enableScrollAnimator"> - <property name="text"> - <string>Enable Scroll Animator</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="6" column="1" colspan="2"> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>391</width> - <height>262</height> - </size> - </property> - </spacer> - </item> </layout> </widget> <widget class="QWidget" name="tab_3"> diff --git a/examples/webenginewidgets/demobrowser/squeezelabel.cpp b/examples/webenginewidgets/demobrowser/squeezelabel.cpp index 2d9061a80..9607bb784 100644 --- a/examples/webenginewidgets/demobrowser/squeezelabel.cpp +++ b/examples/webenginewidgets/demobrowser/squeezelabel.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/squeezelabel.h b/examples/webenginewidgets/demobrowser/squeezelabel.h index e29e9f958..8acd1fb6e 100644 --- a/examples/webenginewidgets/demobrowser/squeezelabel.h +++ b/examples/webenginewidgets/demobrowser/squeezelabel.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp index fee34f6d9..e684d3757 100644 --- a/examples/webenginewidgets/demobrowser/tabwidget.cpp +++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -45,6 +55,7 @@ #include "downloadmanager.h" #include "fullscreennotification.h" #include "history.h" +#include "savepagedialog.h" #include "urllineedit.h" #include "webview.h" @@ -125,6 +136,15 @@ void TabBar::contextMenuRequested(const QPoint &position) action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); + + // Audio mute / unmute. + action = menu.addAction(tr("Mute tab"), + this, SLOT(muteTab())); + action->setData(index); + + action = menu.addAction(tr("Unmute tab"), + this, SLOT(unmuteTab())); + action->setData(index); } else { menu.addSeparator(); } @@ -218,6 +238,22 @@ void TabBar::reloadTab() } } +void TabBar::muteTab() +{ + if (QAction *action = qobject_cast<QAction*>(sender())) { + int index = action->data().toInt(); + emit muteTab(index, true); + } +} + +void TabBar::unmuteTab() +{ + if (QAction *action = qobject_cast<QAction*>(sender())) { + int index = action->data().toInt(); + emit muteTab(index, false); + } +} + TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) @@ -243,6 +279,7 @@ TabWidget::TabWidget(QWidget *parent) connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(moveTab(int,int))); connect(m_tabBar, SIGNAL(tabBarDoubleClicked(int)), this, SLOT(handleTabBarDoubleClicked(int))); + connect(m_tabBar, SIGNAL(muteTab(int,bool)), this, SLOT(setAudioMutedForTab(int,bool))); setTabBar(m_tabBar); setDocumentMode(true); @@ -308,6 +345,18 @@ void TabWidget::moveTab(int fromIndex, int toIndex) m_lineEdits->insertWidget(toIndex, lineEdit); } +void TabWidget::setAudioMutedForTab(int index, bool mute) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + QWidget *widget = this->widget(index); + if (WebView *tab = qobject_cast<WebView*>(widget)) + tab->page()->setAudioMuted(mute); +} + void TabWidget::addWebAction(QAction *action, QWebEnginePage::WebAction webAction) { if (!action) @@ -551,10 +600,14 @@ WebView *TabWidget::newTab(bool makeCurrent) urlLineEdit->setWebView(webView); connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); - connect(webView, SIGNAL(iconChanged()), - this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged(QIcon)), + this, SLOT(webViewIconChanged(QIcon))); connect(webView, SIGNAL(titleChanged(QString)), this, SLOT(webViewTitleChanged(QString))); + connect(webView->page(), SIGNAL(audioMutedChanged(bool)), + this, SLOT(webPageMutedOrAudibleChanged())); + connect(webView->page(), SIGNAL(recentlyAudibleChanged(bool)), + this, SLOT(webPageMutedOrAudibleChanged())); connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(webViewUrlChanged(QUrl))); @@ -686,14 +739,12 @@ void TabWidget::webViewLoadStarted() } } -void TabWidget::webViewIconChanged() +void TabWidget::webViewIconChanged(const QIcon &icon) { WebView *webView = qobject_cast<WebView*>(sender()); int index = webViewIndex(webView); - if (-1 != index) { - QIcon icon = webView->icon(); + if (-1 != index) setTabIcon(index, icon); - } } void TabWidget::webViewTitleChanged(const QString &title) @@ -708,6 +759,23 @@ void TabWidget::webViewTitleChanged(const QString &title) BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); } +void TabWidget::webPageMutedOrAudibleChanged() { + QWebEnginePage* webPage = qobject_cast<QWebEnginePage*>(sender()); + WebView *webView = qobject_cast<WebView*>(webPage->view()); + + int index = webViewIndex(webView); + if (-1 != index) { + QString title = webView->title(); + + bool muted = webPage->isAudioMuted(); + bool audible = webPage->recentlyAudible(); + if (muted) title += tr(" (muted)"); + else if (audible) title += tr(" (audible)"); + + setTabText(index, title); + } +} + void TabWidget::webViewUrlChanged(const QUrl &url) { WebView *webView = qobject_cast<WebView*>(sender()); @@ -855,6 +923,14 @@ bool TabWidget::restoreState(const QByteArray &state) void TabWidget::downloadRequested(QWebEngineDownloadItem *download) { + if (download->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat) { + SavePageDialog dlg(this, download->savePageFormat(), download->path()); + if (dlg.exec() != SavePageDialog::Accepted) + return; + download->setSavePageFormat(dlg.pageFormat()); + download->setPath(dlg.filePath()); + } + BrowserApplication::downloadManager()->download(download); download->accept(); } diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h index cfe1b0397..77e7dde42 100644 --- a/examples/webenginewidgets/demobrowser/tabwidget.h +++ b/examples/webenginewidgets/demobrowser/tabwidget.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -64,6 +74,7 @@ signals: void closeTab(int index); void closeOtherTabs(int index); void reloadTab(int index); + void muteTab(int index, bool mute); void reloadAllTabs(); void tabMoveRequested(int fromIndex, int toIndex); @@ -80,6 +91,8 @@ private slots: void closeTab(); void closeOtherTabs(); void reloadTab(); + void muteTab(); + void unmuteTab(); void contextMenuRequested(const QPoint &position); private: @@ -206,6 +219,7 @@ public slots: void reloadAllTabs(); void nextTab(); void previousTab(); + void setAudioMutedForTab(int index, bool mute); private slots: void currentChanged(int index); @@ -213,7 +227,7 @@ private slots: void aboutToShowRecentTriggeredAction(QAction *action); void downloadRequested(QWebEngineDownloadItem *download); void webViewLoadStarted(); - void webViewIconChanged(); + void webViewIconChanged(const QIcon &icon); void webViewTitleChanged(const QString &title); void webViewUrlChanged(const QUrl &url); void lineEditReturnPressed(); @@ -221,6 +235,7 @@ private slots: void moveTab(int fromIndex, int toIndex); void fullScreenRequested(QWebEngineFullScreenRequest request); void handleTabBarDoubleClicked(int index); + void webPageMutedOrAudibleChanged(); private: void setupPage(QWebEnginePage* page); diff --git a/examples/webenginewidgets/demobrowser/toolbarsearch.cpp b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp index 37ba14ec0..41c5ef314 100644 --- a/examples/webenginewidgets/demobrowser/toolbarsearch.cpp +++ b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/toolbarsearch.h b/examples/webenginewidgets/demobrowser/toolbarsearch.h index 078deac49..d3e914055 100644 --- a/examples/webenginewidgets/demobrowser/toolbarsearch.h +++ b/examples/webenginewidgets/demobrowser/toolbarsearch.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/urllineedit.cpp b/examples/webenginewidgets/demobrowser/urllineedit.cpp index a8b41b963..8203e4f0f 100644 --- a/examples/webenginewidgets/demobrowser/urllineedit.cpp +++ b/examples/webenginewidgets/demobrowser/urllineedit.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -271,8 +281,8 @@ void UrlLineEdit::setWebView(WebView *webView) m_iconLabel->m_webView = webView; connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(webViewUrlChanged(QUrl))); - connect(webView, SIGNAL(iconChanged()), - this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged(QIcon)), + this, SLOT(webViewIconChanged(QIcon))); connect(webView, SIGNAL(loadProgress(int)), this, SLOT(update())); } @@ -283,11 +293,10 @@ void UrlLineEdit::webViewUrlChanged(const QUrl &url) m_lineEdit->setCursorPosition(0); } -void UrlLineEdit::webViewIconChanged() +void UrlLineEdit::webViewIconChanged(const QIcon &icon) { Q_ASSERT(m_webView); - QPixmap pixmap = m_webView->icon().pixmap(16, 16); - m_iconLabel->setPixmap(pixmap); + m_iconLabel->setPixmap(icon.pixmap(16, 16)); } QLinearGradient UrlLineEdit::generateGradient(const QColor &color) const diff --git a/examples/webenginewidgets/demobrowser/urllineedit.h b/examples/webenginewidgets/demobrowser/urllineedit.h index 06efcd528..51c5c0836 100644 --- a/examples/webenginewidgets/demobrowser/urllineedit.h +++ b/examples/webenginewidgets/demobrowser/urllineedit.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -99,7 +109,7 @@ protected: private slots: void webViewUrlChanged(const QUrl &url); - void webViewIconChanged(); + void webViewIconChanged(const QIcon &icon); private: QLinearGradient generateGradient(const QColor &color) const; diff --git a/examples/webenginewidgets/demobrowser/webview.cpp b/examples/webenginewidgets/demobrowser/webview.cpp index 94e872dbf..a785ae48b 100644 --- a/examples/webenginewidgets/demobrowser/webview.cpp +++ b/examples/webenginewidgets/demobrowser/webview.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -55,9 +65,7 @@ #include <QtWidgets/QMessageBox> #include <QtGui/QMouseEvent> -#if defined(QWEBENGINEPAGE_HITTESTCONTENT) -#include <QWebEngineHitTestResult> -#endif +#include <QWebEngineContextMenuData> #ifndef QT_NO_UITOOLS #include <QtUiTools/QUiLoader> @@ -165,6 +173,8 @@ QWebEnginePage *WebPage::createWindow(QWebEnginePage::WebWindowType type) { if (type == QWebEnginePage::WebBrowserTab) { return mainWindow()->tabWidget()->newTab()->page(); + } else if (type == QWebEnginePage::WebBrowserBackgroundTab) { + return mainWindow()->tabWidget()->newTab(false)->page(); } else if (type == QWebEnginePage::WebBrowserWindow) { BrowserApplication::instance()->newMainWindow(); BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); @@ -261,11 +271,8 @@ void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *aut passwordDialog.introLabel->setWordWrap(true); if (dialog.exec() == QDialog::Accepted) { - QByteArray key = BrowserApplication::authenticationKey(requestUrl, auth->realm()); auth->setUser(passwordDialog.userNameLineEdit->text()); auth->setPassword(passwordDialog.passwordLineEdit->text()); - auth->setOption("key", key); - BrowserApplication::instance()->setLastAuthenticator(auth); } else { // Set authenticator null if dialog is cancelled *auth = QAuthenticator(); @@ -292,12 +299,8 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator proxyDialog.introLabel->setWordWrap(true); if (dialog.exec() == QDialog::Accepted) { - QString user = proxyDialog.userNameLineEdit->text(); - QByteArray key = BrowserApplication::proxyAuthenticationKey(user, proxyHost, auth->realm()); - auth->setUser(user); + auth->setUser(proxyDialog.userNameLineEdit->text()); auth->setPassword(proxyDialog.passwordLineEdit->text()); - auth->setOption("key", key); - BrowserApplication::instance()->setLastProxyAuthenticator(auth); } else { // Set authenticator null if dialog is cancelled *auth = QAuthenticator(); @@ -308,7 +311,6 @@ WebView::WebView(QWidget* parent) : QWebEngineView(parent) , m_progress(0) , m_page(0) - , m_iconReply(0) { connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int))); @@ -347,8 +349,9 @@ void WebView::setPage(WebPage *_page) connect(page(), SIGNAL(statusBarMessage(QString)), SLOT(setStatusBarText(QString))); #endif - connect(page(), SIGNAL(iconUrlChanged(QUrl)), - this, SLOT(onIconUrlChanged(QUrl))); + disconnect(page(), &QWebEnginePage::iconChanged, this, &WebView::iconChanged); + connect(page(), SIGNAL(iconChanged(QIcon)), + this, SLOT(onIconChanged(QIcon))); connect(page(), &WebPage::featurePermissionRequested, this, &WebView::onFeaturePermissionRequested); #if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT) page()->setForwardUnsupportedContent(true); @@ -357,16 +360,20 @@ void WebView::setPage(WebPage *_page) void WebView::contextMenuEvent(QContextMenuEvent *event) { - QMenu *menu = page()->createStandardContextMenu(); - const QList<QAction*> actions = menu->actions(); - QList<QAction*>::const_iterator it = qFind(actions.cbegin(), actions.cend(), page()->action(QWebEnginePage::OpenLinkInThisWindow)); - if (it != actions.cend()) { - (*it)->setText(tr("Open Link in This Window")); - ++it; - QAction *before(it == actions.cend() ? nullptr : *it); - menu->insertAction(before, page()->action(QWebEnginePage::OpenLinkInNewWindow)); - menu->insertAction(before, page()->action(QWebEnginePage::OpenLinkInNewTab)); + QMenu *menu; + if (page()->contextMenuData().linkUrl().isValid()) { + menu = new QMenu(this); + menu->addAction(page()->action(QWebEnginePage::OpenLinkInThisWindow)); + menu->addAction(page()->action(QWebEnginePage::OpenLinkInNewWindow)); + menu->addAction(page()->action(QWebEnginePage::OpenLinkInNewBackgroundTab)); + menu->addSeparator(); + menu->addAction(page()->action(QWebEnginePage::DownloadLinkToDisk)); + menu->addAction(page()->action(QWebEnginePage::CopyLinkToClipboard)); + } else { + menu = page()->createStandardContextMenu(); } + if (page()->contextMenuData().selectedText().isEmpty()) + menu->addAction(page()->action(QWebEnginePage::SavePage)); connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater); menu->popup(event->globalPos()); } @@ -435,33 +442,12 @@ QUrl WebView::url() const return m_initialUrl; } -QIcon WebView::icon() const -{ - if (!m_icon.isNull()) - return m_icon; - return BrowserApplication::instance()->defaultIcon(); -} - -void WebView::onIconUrlChanged(const QUrl &url) +void WebView::onIconChanged(const QIcon &icon) { - QNetworkRequest iconRequest(url); - m_iconReply = BrowserApplication::networkAccessManager()->get(iconRequest); - m_iconReply->setParent(this); - connect(m_iconReply, SIGNAL(finished()), this, SLOT(iconLoaded())); -} - -void WebView::iconLoaded() -{ - m_icon = QIcon(); - if (m_iconReply) { - QByteArray data = m_iconReply->readAll(); - QPixmap pixmap; - pixmap.loadFromData(data); - m_icon.addPixmap(pixmap); - m_iconReply->deleteLater(); - m_iconReply = 0; - } - emit iconChanged(); + if (icon.isNull()) + emit iconChanged(BrowserApplication::instance()->defaultIcon()); + else + emit iconChanged(icon); } void WebView::mousePressEvent(QMouseEvent *event) diff --git a/examples/webenginewidgets/demobrowser/webview.h b/examples/webenginewidgets/demobrowser/webview.h index c506ec8b9..8cb502fd1 100644 --- a/examples/webenginewidgets/demobrowser/webview.h +++ b/examples/webenginewidgets/demobrowser/webview.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -91,7 +101,6 @@ public: void loadUrl(const QUrl &url); QUrl url() const; - QIcon icon() const; QString lastStatusBarText() const; inline int progress() const { return m_progress; } @@ -102,25 +111,19 @@ protected: void contextMenuEvent(QContextMenuEvent *event); void wheelEvent(QWheelEvent *event); -signals: - void iconChanged(); - private slots: void setProgress(int progress); void loadFinished(bool success); void setStatusBarText(const QString &string); void openLinkInNewTab(); void onFeaturePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature); - void onIconUrlChanged(const QUrl &url); - void iconLoaded(); + void onIconChanged(const QIcon &icon); private: QString m_statusBarText; QUrl m_initialUrl; int m_progress; WebPage *m_page; - QIcon m_icon; - QNetworkReply *m_iconReply; }; #endif diff --git a/examples/webenginewidgets/demobrowser/xbel.cpp b/examples/webenginewidgets/demobrowser/xbel.cpp index fa7beffde..d66c44faa 100644 --- a/examples/webenginewidgets/demobrowser/xbel.cpp +++ b/examples/webenginewidgets/demobrowser/xbel.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/demobrowser/xbel.h b/examples/webenginewidgets/demobrowser/xbel.h index b0a931431..89f5e259f 100644 --- a/examples/webenginewidgets/demobrowser/xbel.h +++ b/examples/webenginewidgets/demobrowser/xbel.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc b/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc index 5a599a1b2..3a9908ea6 100644 --- a/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc +++ b/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/webenginewidgets/markdowneditor/document.cpp b/examples/webenginewidgets/markdowneditor/document.cpp index 31dfa3d8a..69f698a2d 100644 --- a/examples/webenginewidgets/markdowneditor/document.cpp +++ b/examples/webenginewidgets/markdowneditor/document.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "document.h" void Document::setText(const QString &text) diff --git a/examples/webenginewidgets/markdowneditor/document.h b/examples/webenginewidgets/markdowneditor/document.h index 909ad4f36..3c16c251d 100644 --- a/examples/webenginewidgets/markdowneditor/document.h +++ b/examples/webenginewidgets/markdowneditor/document.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef DOCUMENT_H #define DOCUMENT_H diff --git a/examples/webenginewidgets/markdowneditor/main.cpp b/examples/webenginewidgets/markdowneditor/main.cpp index a99f401cb..1051dcfd4 100644 --- a/examples/webenginewidgets/markdowneditor/main.cpp +++ b/examples/webenginewidgets/markdowneditor/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "document.h" #include "mainwindow.h" diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.cpp b/examples/webenginewidgets/markdowneditor/mainwindow.cpp index 3c6705686..417858d8d 100644 --- a/examples/webenginewidgets/markdowneditor/mainwindow.cpp +++ b/examples/webenginewidgets/markdowneditor/mainwindow.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "mainwindow.h" #include "previewpage.h" #include "ui_mainwindow.h" diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.h b/examples/webenginewidgets/markdowneditor/mainwindow.h index fc04f6beb..ad0320373 100644 --- a/examples/webenginewidgets/markdowneditor/mainwindow.h +++ b/examples/webenginewidgets/markdowneditor/mainwindow.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef MAINWINDOW_H #define MAINWINDOW_H diff --git a/examples/webenginewidgets/markdowneditor/previewpage.cpp b/examples/webenginewidgets/markdowneditor/previewpage.cpp index a48e23175..8ea3f12f4 100644 --- a/examples/webenginewidgets/markdowneditor/previewpage.cpp +++ b/examples/webenginewidgets/markdowneditor/previewpage.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "previewpage.h" #include <QDesktopServices> diff --git a/examples/webenginewidgets/markdowneditor/previewpage.h b/examples/webenginewidgets/markdowneditor/previewpage.h index c0ea2c79a..3a1f4f20a 100644 --- a/examples/webenginewidgets/markdowneditor/previewpage.h +++ b/examples/webenginewidgets/markdowneditor/previewpage.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -37,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef PREVIEWPAGE_H #define PREVIEWPAGE_H diff --git a/examples/webenginewidgets/markdowneditor/resources/qwebchannel.js b/examples/webenginewidgets/markdowneditor/resources/qwebchannel.js index d3d7f5e11..8ebfbb1c9 100644 --- a/examples/webenginewidgets/markdowneditor/resources/qwebchannel.js +++ b/examples/webenginewidgets/markdowneditor/resources/qwebchannel.js @@ -1,12 +1,23 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com> +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the QtWebChannel module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/webenginewidgets/simplebrowser/browser.cpp b/examples/webenginewidgets/simplebrowser/browser.cpp index 78b60b8f8..f1420c2a3 100644 --- a/examples/webenginewidgets/simplebrowser/browser.cpp +++ b/examples/webenginewidgets/simplebrowser/browser.cpp @@ -42,20 +42,9 @@ #include "browserwindow.h" #include "webview.h" #include <QAuthenticator> -#include <QNetworkProxy> -#include <QNetworkReply> Browser::Browser() { - // QTBUG-47967 , downloading favIcon support is coming in 5.7 - QObject::connect(&WebView::networkAccessManager(), &QNetworkAccessManager::authenticationRequired, - [](QNetworkReply *, QAuthenticator *) { - qWarning("Authentication required for downloading favicon."); - }); - QObject::connect(&WebView::networkAccessManager(), &QNetworkAccessManager::proxyAuthenticationRequired, - [](const QNetworkProxy &, QAuthenticator *) { - qWarning("Proxy authentication required for downloading favicon."); - }); } Browser::~Browser() diff --git a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc index b8df9b02a..e57ec80ec 100644 --- a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc +++ b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc @@ -123,7 +123,6 @@ functionality: \list - \li Downloading favicons \li Displaying error messages in case \c renderProcess dies \li Handling \c createWindow requests \li Adding custom menu items to context menus @@ -136,21 +135,11 @@ \printuntil WebView( \dots \skipto protected: - \printuntil handleIconLoaded + \printuntil webActionEnabledChanged \skipto } \dots \printline }; - \section2 Downloading Favicons - - To download a favicon, we use QNetworkAccessManager and create a - QNetworkRequest every time the URL specified by - QWebEngineView::iconUrlChanged is emitted: - - \quotefromfile webenginewidgets/simplebrowser/webview.cpp - \skipto WebView::handleIconUrlChanged( - \printuntil } - \section2 Displaying Error Messages If the render process is terminated, we display a QMessageBox with an error diff --git a/examples/webenginewidgets/simplebrowser/main.cpp b/examples/webenginewidgets/simplebrowser/main.cpp index be08c1cb0..fa9f44c34 100644 --- a/examples/webenginewidgets/simplebrowser/main.cpp +++ b/examples/webenginewidgets/simplebrowser/main.cpp @@ -41,6 +41,7 @@ #include "browser.h" #include "browserwindow.h" #include <QApplication> +#include <QWebEngineSettings> QString getCommandLineUrlArgument() { @@ -61,6 +62,8 @@ int main(int argc, char **argv) QApplication app(argc, argv); app.setWindowIcon(QIcon(QLatin1String(":simplebrowser.svg"))); + QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); + BrowserWindow *window = new BrowserWindow(); Browser::instance().addWindow(window); diff --git a/examples/webenginewidgets/simplebrowser/simplebrowser.pro b/examples/webenginewidgets/simplebrowser/simplebrowser.pro index ad8a9a2bd..197d68091 100644 --- a/examples/webenginewidgets/simplebrowser/simplebrowser.pro +++ b/examples/webenginewidgets/simplebrowser/simplebrowser.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = simplebrowser -QT += webenginewidgets network +QT += webenginewidgets CONFIG += c++11 HEADERS += \ diff --git a/examples/webenginewidgets/simplebrowser/tabwidget.cpp b/examples/webenginewidgets/simplebrowser/tabwidget.cpp index 3c6269f52..a7f855c2a 100644 --- a/examples/webenginewidgets/simplebrowser/tabwidget.cpp +++ b/examples/webenginewidgets/simplebrowser/tabwidget.cpp @@ -80,7 +80,11 @@ void TabWidget::handleCurrentChanged(int index) emit titleChanged(view->title()); emit loadProgress(view->loadProgress()); emit urlChanged(view->url()); - emit iconChanged(view->icon()); + QIcon pageIcon = view->page()->icon(); + if (!pageIcon.isNull()) + emit iconChanged(pageIcon); + else + emit iconChanged(QIcon(QStringLiteral(":defaulticon.png"))); emit webActionEnabledChanged(QWebEnginePage::Back, view->isWebActionEnabled(QWebEnginePage::Back)); emit webActionEnabledChanged(QWebEnginePage::Forward, view->isWebActionEnabled(QWebEnginePage::Forward)); emit webActionEnabledChanged(QWebEnginePage::Stop, view->isWebActionEnabled(QWebEnginePage::Stop)); @@ -89,7 +93,7 @@ void TabWidget::handleCurrentChanged(int index) emit titleChanged(QString()); emit loadProgress(0); emit urlChanged(QUrl()); - emit iconChanged(QIcon()); + emit iconChanged(QIcon(QStringLiteral(":defaulticon.png"))); emit webActionEnabledChanged(QWebEnginePage::Back, false); emit webActionEnabledChanged(QWebEnginePage::Forward, false); emit webActionEnabledChanged(QWebEnginePage::Stop, false); @@ -166,12 +170,14 @@ void TabWidget::setupView(WebView *webView) if (currentIndex() == indexOf(webView)) emit linkHovered(url); }); - connect(webView, &WebView::iconChanged, [this, webView](const QIcon& icon) { + connect(webPage, &WebPage::iconChanged, [this, webView](const QIcon &icon) { int index = indexOf(webView); + QIcon ico = icon.isNull() ? QIcon(QStringLiteral(":defaulticon.png")) : icon; + if (index != -1) - setTabIcon(index, icon); + setTabIcon(index, ico); if (currentIndex() == index) - emit iconChanged(icon); + emit iconChanged(ico); }); connect(webView, &WebView::webActionEnabledChanged, [this, webView](QWebEnginePage::WebAction action, bool enabled) { if (currentIndex() == indexOf(webView)) diff --git a/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp b/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp index a3175e546..8146dcfb7 100644 --- a/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp +++ b/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp @@ -65,7 +65,7 @@ WebPopupWindow::WebPopupWindow(QWebEngineProfile *profile) connect(m_view, &WebView::titleChanged, this, &QWidget::setWindowTitle); connect(m_view, &WebView::urlChanged, this, &WebPopupWindow::setUrl); - connect(m_view, &WebView::iconChanged, this, &WebPopupWindow::handleIconChanged); + connect(m_view->page(), &WebPage::iconChanged, this, &WebPopupWindow::handleIconChanged); connect(m_view->page(), &WebPage::geometryChangeRequested, this, &WebPopupWindow::handleGeometryChangeRequested); connect(m_view->page(), &WebPage::windowCloseRequested, this, &QWidget::close); } @@ -91,5 +91,8 @@ void WebPopupWindow::handleGeometryChangeRequested(const QRect &newGeometry) void WebPopupWindow::handleIconChanged(const QIcon &icon) { - m_addressBar->setFavIcon(icon); + if (icon.isNull()) + m_addressBar->setFavIcon(QIcon(QStringLiteral(":defaulticon.png"))); + else + m_addressBar->setFavIcon(icon); } diff --git a/examples/webenginewidgets/simplebrowser/webview.cpp b/examples/webenginewidgets/simplebrowser/webview.cpp index d2a38523f..657993fc6 100644 --- a/examples/webenginewidgets/simplebrowser/webview.cpp +++ b/examples/webenginewidgets/simplebrowser/webview.cpp @@ -48,7 +48,6 @@ #include <QDebug> #include <QMenu> #include <QMessageBox> -#include <QNetworkReply> #include <QTimer> WebView::WebView(QWidget *parent) @@ -60,11 +59,10 @@ WebView::WebView(QWidget *parent) }); connect(this, &QWebEngineView::loadFinished, [this](bool success) { if (!success) { - qWarning() << "Could not load page: " << url(); m_loadProgress = 0; } }); - connect(this, &QWebEngineView::iconUrlChanged, this, &WebView::handleIconUrlChanged); + connect(this, &QWebEngineView::renderProcessTerminated, [this](QWebEnginePage::RenderProcessTerminationStatus termStatus, int statusCode) { QString status; @@ -82,8 +80,11 @@ WebView::WebView(QWidget *parent) status = tr("Render process killed"); break; } - QMessageBox::critical(window(), status, tr("Render process exited with code: %1").arg(statusCode)); - QTimer::singleShot(0, [this] { reload(); }); + QMessageBox::StandardButton btn = QMessageBox::question(window(), status, + tr("Render process exited with code: %1\n" + "Do you want to reload the page ?").arg(statusCode)); + if (btn == QMessageBox::Yes) + QTimer::singleShot(0, [this] { reload(); }); }); } @@ -96,13 +97,6 @@ void WebView::setPage(WebPage *page) QWebEngineView::setPage(page); } -QIcon WebView::icon() const -{ - if (!m_icon.isNull()) - return m_icon; - return QIcon(QLatin1String(":defaulticon.png")); -} - int WebView::loadProgress() const { return m_loadProgress; @@ -121,12 +115,6 @@ bool WebView::isWebActionEnabled(QWebEnginePage::WebAction webAction) const return page()->action(webAction)->isEnabled(); } -QNetworkAccessManager &WebView::networkAccessManager() -{ - static QNetworkAccessManager networkAccessManager; - return networkAccessManager; -} - QWebEngineView *WebView::createWindow(QWebEnginePage::WebWindowType type) { switch (type) { @@ -134,6 +122,10 @@ QWebEngineView *WebView::createWindow(QWebEnginePage::WebWindowType type) BrowserWindow *mainWindow = qobject_cast<BrowserWindow*>(window()); return mainWindow->tabWidget()->createTab(); } + case QWebEnginePage::WebBrowserBackgroundTab: { + BrowserWindow *mainWindow = qobject_cast<BrowserWindow*>(window()); + return mainWindow->tabWidget()->createTab(false); + } case QWebEnginePage::WebBrowserWindow: { BrowserWindow *mainWindow = new BrowserWindow(); Browser::instance().addWindow(mainWindow); @@ -163,30 +155,3 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu->popup(event->globalPos()); } -void WebView::handleIconUrlChanged(const QUrl &url) -{ - QNetworkRequest iconRequest(url); -#ifndef QT_NO_OPENSSL - QSslConfiguration conf = iconRequest.sslConfiguration(); - conf.setPeerVerifyMode(QSslSocket::VerifyNone); - iconRequest.setSslConfiguration(conf); -#endif - QNetworkReply *iconReply = networkAccessManager().get(iconRequest); - iconReply->setParent(this); - connect(iconReply, &QNetworkReply::finished, this, &WebView::handleIconLoaded); -} - -void WebView::handleIconLoaded() -{ - QNetworkReply *iconReply = qobject_cast<QNetworkReply*>(sender()); - if (iconReply && iconReply->error() == QNetworkReply::NoError) { - QByteArray data = iconReply->readAll(); - QPixmap pixmap; - pixmap.loadFromData(data); - m_icon.addPixmap(pixmap); - iconReply->deleteLater(); - } else { - m_icon = QIcon(QStringLiteral(":defaulticon.png")); - } - emit iconChanged(m_icon); -} diff --git a/examples/webenginewidgets/simplebrowser/webview.h b/examples/webenginewidgets/simplebrowser/webview.h index 5450ee247..f06162ea3 100644 --- a/examples/webenginewidgets/simplebrowser/webview.h +++ b/examples/webenginewidgets/simplebrowser/webview.h @@ -54,29 +54,21 @@ public: WebView(QWidget *parent = nullptr); void setPage(WebPage *page); - QIcon icon() const; int loadProgress() const; bool isWebActionEnabled(QWebEnginePage::WebAction webAction) const; - static QNetworkAccessManager &networkAccessManager(); protected: void contextMenuEvent(QContextMenuEvent *event) override; QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) override; signals: - void iconChanged(const QIcon &icon); void webActionEnabledChanged(QWebEnginePage::WebAction webAction, bool enabled); -private slots: - void handleIconUrlChanged(const QUrl &url); - void handleIconLoaded(); - private: void createWebActionTrigger(QWebEnginePage *page, QWebEnginePage::WebAction); private: int m_loadProgress; - QIcon m_icon; }; #endif |