From fffd02a307aeae30ceb6184503f8ebbf73812095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Fri, 17 May 2019 14:52:17 +0200 Subject: Document PDF viewing feature Documents settings needed to activate the feature that was added in 5.13.0 Fixes: QTBUG-75892 Change-Id: Ia4dbbc2e3c4f5a173d482dcae8ec5a1c31a8d6be Reviewed-by: Leena Miettinen --- src/webengine/doc/src/qtwebengine-features.qdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc index 5c6bdda5d..08c189740 100644 --- a/src/webengine/doc/src/qtwebengine-features.qdoc +++ b/src/webengine/doc/src/qtwebengine-features.qdoc @@ -44,6 +44,7 @@ \li \l{HTTP/2 Protocol} \li \l{Native Dialogs} \li \l{Pepper Plugin API} + \li \l{PDF File Viewing} \li \l{Print to PDF} \li \l{Process Models} \li \l{Spellchecker} @@ -319,6 +320,21 @@ feature, the \c https://helpx.adobe.com/flash-player.html page can be opened in the browser. + \section1 PDF File Viewing + + \QWE supports viewing PDF documents by navigating to them. This feature uses the Chromium + extensions API and PDF viewer plugin to display the PDF documents. + It can be tested in \l{WebEngine Widgets Simple Browser Example}{Simple Browser} or + \l{WebEngine Quick Nano Browser}{Nano Browser}. + + Loading plugins needs to be enabled using QWebEngineSettings::PluginsEnabled or + WebEngineSettings::pluginsEnabled in order to use this feature. + + This feature can be turned on (default) or off via the QWebEngineSettings::PdfViewerEnabled or + WebEngineSettings::pdfViewerEnabled setting. + + Support for this feature was added in Qt 5.13.0. + \section1 Print to PDF \QWE supports printing a web page to a PDF file. For more -- cgit v1.2.3 From 546c42e42643a209d893d5291c26c3f8ef7102a3 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 16 May 2019 21:58:06 +0200 Subject: Fix linker too long argument list For yocto builds linker can get quite long path since all archives are listed as absolute paths. This can end up as "execvp: /bin/sh: Argument list too long" Use rsp files also for archives. Change-Id: I096e2f35ed72b68261bf465e84baddd1f78cd917 Reviewed-by: Allan Sandfeld Jensen --- src/core/core_module.pro | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/core_module.pro b/src/core/core_module.pro index e2fa3494d..10169a49e 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -25,14 +25,17 @@ isEmpty(NINJA_LIBS): error("Missing library files from QtWebEngineCore linking p NINJA_OBJECTS = $$eval($$list($$NINJA_OBJECTS)) # Do manual response file linking for macOS and Linux -RSP_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}.rsp -for(object, NINJA_OBJECTS): RSP_CONTENT += $$object -write_file($$RSP_FILE, RSP_CONTENT) -macos:LIBS_PRIVATE += -Wl,-filelist,$$shell_quote($$RSP_FILE) -linux:LIBS_PRIVATE += @$$RSP_FILE +RSP_OBJECT_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}_o.rsp +for(object, NINJA_OBJECTS): RSP_O_CONTENT += $$object +write_file($$RSP_OBJECT_FILE, RSP_O_CONTENT) +RSP_ARCHIVE_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}_a.rsp +for(archive, NINJA_ARCHIVES): RSP_A_CONTENT += $$archive +write_file($$RSP_ARCHIVE_FILE, RSP_A_CONTENT) +macos:LIBS_PRIVATE += -Wl,-filelist,$$shell_quote($$RSP_OBJECT_FILE) +linux:LIBS_PRIVATE += @$${RSP_OBJECT_FILE} # QTBUG-58710 add main rsp file on windows -win32:QMAKE_LFLAGS += @$$RSP_FILE -linux: LIBS_PRIVATE += -Wl,--start-group $$NINJA_ARCHIVES -Wl,--end-group +win32:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} +linux: LIBS_PRIVATE += -Wl,--start-group @$${RSP_ARCHIVE_FILE} -Wl,--end-group else: LIBS_PRIVATE += $$NINJA_ARCHIVES LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS # GN's LFLAGS doesn't always work across all the Linux configurations we support. -- cgit v1.2.3 From ee12b53eba009e8a3ca12ef77031d9a48c609cb4 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Fri, 17 May 2019 15:49:23 +0200 Subject: Make linker call look great again Fix issues with messed up linker path: * do not use LIBS_PRIVATE on linux at least for passing object and archive responses files. * do not use QT and QT_PRIVATE with same libs, it simply includes libs in LIB and LIB_PRIVATE so doubles linker libs. * remove bogus dependency for gui and core for webengineheaders pseudo module. * remove unused egl config flag Fixes: QTBUG-75832 Task-number: QTBUG-75357 Change-Id: I1720394e636e3f89d546f372b10932dd4ad395fe Reviewed-by: Allan Sandfeld Jensen --- src/core/core_chromium.pri | 2 -- src/core/core_common.pri | 4 ++-- src/core/core_headers.pro | 1 + src/core/core_module.pro | 13 ++++++------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 4d8db0d1e..d8ef25d8c 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -33,8 +33,6 @@ RCC_DIR = $$OUT_PWD/$$getConfigDir()/.rcc # whenever we are cross compiling. qtConfig(webengine-embedded-build): DEFINES += QTWEBENGINE_EMBEDDED_SWITCHES -qtConfig(egl): CONFIG += egl - INCLUDEPATH += $$PWD $$PWD/api clang_cl { diff --git a/src/core/core_common.pri b/src/core/core_common.pri index 8375d89e5..51f5e21b0 100644 --- a/src/core/core_common.pri +++ b/src/core/core_common.pri @@ -2,8 +2,8 @@ # gyp/ninja will take care of the compilation, qmake/make will finish with linking and install. TARGET = QtWebEngineCore -QT += qml quick -QT_PRIVATE += quick-private gui-private core-private webenginecoreheaders-private +QT += qml-private quick-private gui-private core-private +QT_PRIVATE += webenginecoreheaders-private qtConfig(webengine-geolocation): QT += positioning qtConfig(webengine-webchannel): QT += webchannel diff --git a/src/core/core_headers.pro b/src/core/core_headers.pro index 21b5d58c3..cd5352eb7 100644 --- a/src/core/core_headers.pro +++ b/src/core/core_headers.pro @@ -1,5 +1,6 @@ TARGET = QtWebEngineCore CONFIG += no_private_module header_module internal_module no_plist +QT -= core gui MODULE = webenginecoreheaders MODULE_CFG_FILE = qtwebenginecore-config load(qt_module) diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 10169a49e..2bfbc65b9 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -10,8 +10,6 @@ linking_pri = $$OUT_PWD/$$getConfigDir()/$${TARGET}.pri error("Could not find the linking information that gn should have generated.") } -load(qt_module) - api_library_name = qtwebenginecoreapi$$qtPlatformTargetSuffix() api_library_path = $$OUT_PWD/api/$$getConfigDir() @@ -32,10 +30,10 @@ RSP_ARCHIVE_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}_a.rsp for(archive, NINJA_ARCHIVES): RSP_A_CONTENT += $$archive write_file($$RSP_ARCHIVE_FILE, RSP_A_CONTENT) macos:LIBS_PRIVATE += -Wl,-filelist,$$shell_quote($$RSP_OBJECT_FILE) -linux:LIBS_PRIVATE += @$${RSP_OBJECT_FILE} +linux:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} # QTBUG-58710 add main rsp file on windows win32:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} -linux: LIBS_PRIVATE += -Wl,--start-group @$${RSP_ARCHIVE_FILE} -Wl,--end-group +linux:QMAKE_LFLAGS += -Wl,--start-group @$${RSP_ARCHIVE_FILE} -Wl,--end-group else: LIBS_PRIVATE += $$NINJA_ARCHIVES LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS # GN's LFLAGS doesn't always work across all the Linux configurations we support. @@ -74,7 +72,7 @@ osx { # API library as response file to the linker. QMAKE_LFLAGS += @$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib.objects } else { - LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive + QMAKE_LFLAGS += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive } win32 { @@ -87,8 +85,6 @@ win32 { # and doesn't let Chromium get access to libc symbols through dlsym. CONFIG -= bsymbolic_functions -qtConfig(egl): CONFIG += egl - linux:qtConfig(separate_debug_info): QMAKE_POST_LINK="cd $(DESTDIR) && $(STRIP) --strip-unneeded $(TARGET)" REPACK_DIR = $$OUT_PWD/$$getConfigDir() @@ -157,3 +153,6 @@ OTHER_FILES = \ $$files(../3rdparty/chromium/*.gypi, true) \ $$files(../3rdparty/chromium/*.gn, true) \ $$files(../3rdparty/chromium/*.gni, true) + +load(qt_module) + -- cgit v1.2.3 From 4d4ff2afbb5fae7a9779aa7727b1a55ac1f4c276 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 15 May 2019 14:08:45 +0200 Subject: Update changes Reflect the last Chrome security release included Change-Id: I5eb1fca0301a857c0a40bab9933e8cdcd8a9a649 Reviewed-by: Michal Klocek --- dist/changes-5.13.0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/changes-5.13.0 b/dist/changes-5.13.0 index 6370cc9ed..2b0e30bea 100644 --- a/dist/changes-5.13.0 +++ b/dist/changes-5.13.0 @@ -30,7 +30,7 @@ Chromium Snapshot ----------------- - Updated the Chromium version to 73.0.3683.105 - - Applied security fixes from Chrome up to version 74.0.3729.108 + - Applied security fixes from Chrome up to version 74.0.3729.131 Platforms -- cgit v1.2.3 From 819aa370ec413ba1ea4506d591d4debe87c21831 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 22 May 2019 18:29:16 +0200 Subject: Claim to support hover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chromium sets those settings based on ui::GetAvailableHoverTypes() and GetPrimaryHoverType() which (on Linux) use an InputDeviceManager to check whether there's a mouse or touchpad present. With them being unset, CSS media queries (hover/any-hover) tell websites that hovering isn't supported: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hover https://developer.mozilla.org/en-US/docs/Web/CSS/@media/any-hover On some websites such as GitHub, this disables/breaks hovering functionality. QtWebEngine can't figure out whether it's running on a device with a mouse/touchpad (using Chromium's code won't work as no InputDeviceManager is available, and Qt doesn't seem to have any comparable functionality). However, since QtWebEngine is not available for mobile platforms, assuming that a mouse is present (rather than assuming that none is) seems reasonable. Change-Id: Ie038318f105bafdf955d512ab10f13f33da1111b Fixes: QTBUG-75894 Reviewed-by: Jüri Valdmann --- src/core/web_engine_settings.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 5a01308a1..b6250a65f 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -345,6 +345,10 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p { // Override for now prefs->touch_event_feature_detection_enabled = isTouchEventsAPIEnabled(); +#if !QT_CONFIG(webengine_embedded_build) + prefs->available_hover_types = ui::HOVER_TYPE_HOVER; + prefs->primary_hover_type = ui::HOVER_TYPE_HOVER; +#endif if (prefs->viewport_enabled) { // We need to enable the viewport options together as it doesn't really work // to enable them separately. With viewport-enabled we match Android defaults. -- cgit v1.2.3 From 8e8cd9ea03dbdfab4d1707ca751b72dd6ac3c178 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Tue, 19 Mar 2019 10:15:07 +0100 Subject: Web Notifications widgets' API example Change-Id: If6aba0e9da1ece59c91be03ae2f56513e758f5e5 Reviewed-by: Kai Koehne Reviewed-by: Leena Miettinen --- .../webenginewidgets/notifications/data/data.qrc | 6 + .../webenginewidgets/notifications/data/icon.png | Bin 0 -> 2252 bytes .../webenginewidgets/notifications/data/index.html | 90 ++++++++++++ .../doc/images/notifications-example.png | Bin 0 -> 14732 bytes .../notifications/doc/src/notifications.qdoc | 156 +++++++++++++++++++++ examples/webenginewidgets/notifications/main.cpp | 100 +++++++++++++ .../notifications/notificationpopup.h | 132 +++++++++++++++++ .../notifications/notifications.pro | 10 ++ examples/webenginewidgets/webenginewidgets.pro | 1 + 9 files changed, 495 insertions(+) create mode 100644 examples/webenginewidgets/notifications/data/data.qrc create mode 100644 examples/webenginewidgets/notifications/data/icon.png create mode 100644 examples/webenginewidgets/notifications/data/index.html create mode 100644 examples/webenginewidgets/notifications/doc/images/notifications-example.png create mode 100644 examples/webenginewidgets/notifications/doc/src/notifications.qdoc create mode 100644 examples/webenginewidgets/notifications/main.cpp create mode 100644 examples/webenginewidgets/notifications/notificationpopup.h create mode 100644 examples/webenginewidgets/notifications/notifications.pro diff --git a/examples/webenginewidgets/notifications/data/data.qrc b/examples/webenginewidgets/notifications/data/data.qrc new file mode 100644 index 000000000..bc252b89c --- /dev/null +++ b/examples/webenginewidgets/notifications/data/data.qrc @@ -0,0 +1,6 @@ + + + index.html + icon.png + + diff --git a/examples/webenginewidgets/notifications/data/icon.png b/examples/webenginewidgets/notifications/data/icon.png new file mode 100644 index 000000000..4c3870c06 Binary files /dev/null and b/examples/webenginewidgets/notifications/data/icon.png differ diff --git a/examples/webenginewidgets/notifications/data/index.html b/examples/webenginewidgets/notifications/data/index.html new file mode 100644 index 000000000..ebb73b573 --- /dev/null +++ b/examples/webenginewidgets/notifications/data/index.html @@ -0,0 +1,90 @@ + + + +Web Notifications Example + + + +

Click the button to send a notification

+ + + +

+ + +


+ +

+ + + +


+ +

More info can be found on:

+ + + diff --git a/examples/webenginewidgets/notifications/doc/images/notifications-example.png b/examples/webenginewidgets/notifications/doc/images/notifications-example.png new file mode 100644 index 000000000..671cd1703 Binary files /dev/null and b/examples/webenginewidgets/notifications/doc/images/notifications-example.png differ diff --git a/examples/webenginewidgets/notifications/doc/src/notifications.qdoc b/examples/webenginewidgets/notifications/doc/src/notifications.qdoc new file mode 100644 index 000000000..2c999e7e1 --- /dev/null +++ b/examples/webenginewidgets/notifications/doc/src/notifications.qdoc @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** 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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example webenginewidgets/notifications + \title WebEngine Notifications Example + \ingroup webengine-widgetexamples + \brief Demonstrates how to pass HTML5 web notifications to users. + + \image notifications-example.png + + \e {\WebEngine Notifications} demonstrates how to use the + \l QWebEngineProfile::setNotificationPresenter() method and + \l QWebEngineNotification class to show an HTML5 web + notification to the user. + + \include examples-run.qdocinc + + \section1 HTML Page + + In this example, we create an internal HTML page that is added through + a resource collection file (.qrc). The page displays buttons for requesting + permissions and creating a notification. In addition, it contains JavaScript + logic for triggering these actions. + + \quotefromfile webenginewidgets/notifications/data/index.html + \skipto Notification.requestPermission + \printline requestPermission + \dots + \skipto if + \printuntil createNotification() + \printline /^})$/ + + \quotefromfile webenginewidgets/notifications/data/index.html + \skipto createNotification() + \printuntil Notification + \dots + \printline /^})$/ + + \section1 Main Function + + In the \c main function, we instantiate a QWebEngineView, load our internal + HTML page, and set up the required callbacks for notifications handling. + + \section2 Requesting Feature Permissions + + We then use the \l QWebEnginePage::featurePermissionRequested() call to + request the user's permission to show notifications on their device. + + \quotefromfile webenginewidgets/notifications/main.cpp + \skipto featurePermissionRequested + \printuntil }); + + \section2 Handling New Notifications + + We then construct a \c NotificationPopup that encapsulates + the data of the HTML web notification. We also use the + \l QWebEngineProfile::setNotificationPresenter() call to set + our handler, which we use in conjunction with our \c popup + to handle all new notifications. + + \skipto popup + \printuntil }); + + \section1 Presenting Notifications to Users + + The \c NotificationPopup class in this example is a simple + QWidget-based class that uses multiple QLabel instances + for displaying the notification's title, message, and icon. + + \quotefromfile webenginewidgets/notifications/notificationpopup.h + \skipto class NotificationPopup + \printto public: + + \section2 Presenting Notifications + + Inside the \c present method, we first close and release the previous + notification if we have one and then take ownership of a new notification + by calling the \c std::unique_ptr::swap method on our internal notification + instance. + + \skipto present + \printto m_title + + Then we query the notification instance for a title, a message, + and an icon by calling \l QWebEngineNotification::title(), + \l QWebEngineNotification::message(), \l QWebEngineNotification::icon() + and set up the appropriate labels in our popup. + + \printuntil m_icon + + After that we are ready to display our notification to the user + by calling the \l QWidget::show() method. On this step we also call the + \l QWebEngineNotification::show() method to notify \c JavaScript code + about our \e show event. + + \printuntil notification->show + + Finally, we set up a callback to handle the \e close event from the + \c JavaScript side by connecting to the \l QWebEngineNotification::closed() + signal. We also schedule a timer event to close our active notification + automatically. + + \skipto QWebEngineNotification::closed + \printuntil QTimer + \printline /^\}/ + + \section2 Closing Active Notification + + We execute the \e close step for the currently active notification either by + timeout or by handling the \c JavaScript event. First, we hide the popup + widget itself by calling \l QWidget::hide(). Then, we notify the \c JavaScript + code by calling the \l QWebEngineNotification::close() method. Finally, we + destroy the notification object through the \c std::unique_ptr::reset() method. + + \skipto onClosed + \dots + \skipto hide() + \printuntil reset + + \section2 Implementing User Interaction + + To implement the \e click step for a notification, we handle mouse interaction + through \l QWidget::mouseReleaseEvent(). On this event, the \c JavaScript code + is notified by calling the \l QWebEngineNotification::click() method. + Then we automatically perform the \e close step as a notification is + considered fully handled and no longer needed, and therefore can be destroyed. + + \skipto mouseReleaseEvent + \printuntil onClosed + \printuntil /^\}/ +*/ diff --git a/examples/webenginewidgets/notifications/main.cpp b/examples/webenginewidgets/notifications/main.cpp new file mode 100644 index 000000000..661b82ff5 --- /dev/null +++ b/examples/webenginewidgets/notifications/main.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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$ +** 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 "notificationpopup.h" + +#include +#include +#include +#include +#include + +class WebEnginePage : public QWebEnginePage { +public: + WebEnginePage(QWidget *parent) : QWebEnginePage(parent) { } + + bool acceptNavigationRequest(const QUrl &url, NavigationType, bool) override { + if (url.scheme() != "https") + return true; + QDesktopServices::openUrl(url); + return false; + } +}; + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setOrganizationName("QtExamples"); + QApplication app(argc, argv); + + QWebEngineView view; + + // set custom page to open all page's links for https scheme in system browser + view.setPage(new WebEnginePage(&view)); + + QObject::connect(view.page(), &QWebEnginePage::featurePermissionRequested, + [&] (const QUrl &origin, QWebEnginePage::Feature feature) { + if (feature != QWebEnginePage::Notifications) + return; + view.page()->setFeaturePermission(origin, feature, QWebEnginePage::PermissionGrantedByUser); + }); + + auto profile = view.page()->profile(); + auto popup = new NotificationPopup(&view); + profile->setNotificationPresenter([&] (std::unique_ptr notification) { + popup->present(notification); + }); + + view.resize(640, 480); + view.show(); + view.setUrl(QStringLiteral("qrc:/index.html")); + return app.exec(); +} + diff --git a/examples/webenginewidgets/notifications/notificationpopup.h b/examples/webenginewidgets/notifications/notificationpopup.h new file mode 100644 index 000000000..fcbb003b9 --- /dev/null +++ b/examples/webenginewidgets/notifications/notificationpopup.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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$ +** 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$ +** +****************************************************************************/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class NotificationPopup : public QWidget { + Q_OBJECT + + QLabel m_icon, m_title, m_message; + std::unique_ptr notification; + +public: + NotificationPopup(QWidget *parent) : QWidget(parent) { + setWindowFlags(Qt::ToolTip); + auto rootLayout = new QHBoxLayout(this); + + rootLayout->addWidget(&m_icon); + + auto bodyLayout = new QVBoxLayout; + rootLayout->addLayout(bodyLayout); + + auto titleLayout = new QHBoxLayout; + bodyLayout->addLayout(titleLayout); + + titleLayout->addWidget(&m_title); + titleLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding)); + + auto close = new QPushButton(tr("Close")); + titleLayout->addWidget(close); + connect(close, &QPushButton::clicked, this, &NotificationPopup::onClosed); + + bodyLayout->addWidget(&m_message); + adjustSize(); + } + + void present(std::unique_ptr &newNotification) { + if (notification) { + notification->close(); + notification.reset(); + } + + notification.swap(newNotification); + + m_title.setText("" + notification->title() + ""); + m_message.setText(notification->message()); + m_icon.setPixmap(QPixmap::fromImage(notification->icon()).scaledToHeight(m_icon.height())); + + show(); + notification->show(); + + connect(notification.get(), &QWebEngineNotification::closed, this, &NotificationPopup::onClosed); + QTimer::singleShot(10000, notification.get(), [&] () { onClosed(); }); + + // position our popup in the right corner of its parent widget + move(parentWidget()->mapToGlobal(parentWidget()->rect().bottomRight() - QPoint(width() + 10, height() + 10))); + } + +protected slots: + void onClosed() { + hide(); + notification->close(); + notification.reset(); + } + +protected: + void mouseReleaseEvent(QMouseEvent *event) override { + QWidget::mouseReleaseEvent(event); + if (notification && event->button() == Qt::LeftButton) { + notification->click(); + onClosed(); + } + } +}; + diff --git a/examples/webenginewidgets/notifications/notifications.pro b/examples/webenginewidgets/notifications/notifications.pro new file mode 100644 index 000000000..6e276d405 --- /dev/null +++ b/examples/webenginewidgets/notifications/notifications.pro @@ -0,0 +1,10 @@ +QT += webenginewidgets + +HEADERS = notificationpopup.h + +SOURCES = main.cpp + +RESOURCES = data/data.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/notifications +INSTALLS += target diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro index 0d47aac80..deb42a8cd 100644 --- a/examples/webenginewidgets/webenginewidgets.pro +++ b/examples/webenginewidgets/webenginewidgets.pro @@ -7,6 +7,7 @@ SUBDIRS += \ minimal \ contentmanipulation \ cookiebrowser \ + notifications \ simplebrowser \ stylesheetbrowser \ videoplayer \ -- cgit v1.2.3 From 0835dfa3f9b2b20f6f40ee0c2140d5222ed4fff5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 21 May 2019 12:39:10 +0200 Subject: Update Chromium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pull in the one security patch from 74.0.3729.157 Submodule src/3rdparty 599fa1c6..00390e99: > Try different versions when creating a CoreProfile context on macOS > Fix crashes due to pa_context_get_server_info Task-number: QTBUG-75496 Change-Id: I9dd05cf17fdf56912168dbaedc238fdd7a5412d8 Reviewed-by: Jüri Valdmann --- dist/changes-5.13.0 | 2 +- src/3rdparty | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/changes-5.13.0 b/dist/changes-5.13.0 index 2b0e30bea..fbd2c54e9 100644 --- a/dist/changes-5.13.0 +++ b/dist/changes-5.13.0 @@ -30,7 +30,7 @@ Chromium Snapshot ----------------- - Updated the Chromium version to 73.0.3683.105 - - Applied security fixes from Chrome up to version 74.0.3729.131 + - Applied security fixes from Chrome up to version 74.0.3729.157 Platforms diff --git a/src/3rdparty b/src/3rdparty index 599fa1c61..00390e99a 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 599fa1c61c3ee9d86823033f3d5ab2743cfd78dd +Subproject commit 00390e99a0041585e1b4ae6dcc6ff12a3d64c743 -- cgit v1.2.3 From d2adbbca95ee35f290b6842fde87b40b0f8b947e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 23 May 2019 10:23:16 +0200 Subject: Update Chromium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Actually pull in the one security patch from 74.0.3729.157 that was missed in the last commit. Changes: 56c1f8e6c4f [Backport] Fix for security issue 951322 8a28c0bb19f FIXUP: [Backport] Fix for security issue 951322 Task-number: QTBUG-75496 Change-Id: I1eef649169f5a4d1179673413da9f49acd6a20ef Reviewed-by: Jüri Valdmann --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty b/src/3rdparty index 00390e99a..8a28c0bb1 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 00390e99a0041585e1b4ae6dcc6ff12a3d64c743 +Subproject commit 8a28c0bb19fc8627812cb7c3154408b71ff2bf5e -- cgit v1.2.3 From 5d4bac57a0191287a2fc345f6b398fb1f5d08517 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 24 May 2019 11:01:39 +0200 Subject: Blacklist tst_QWebEngineView::inputContextQueryInput on windows Has failed twice in a row now. Change-Id: I9433ec9a3b2f1720efbaf7a34fcaa563525126e5 Reviewed-by: Kai Koehne --- tests/auto/widgets/qwebengineview/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST index 7c86a72d6..9a574a687 100644 --- a/tests/auto/widgets/qwebengineview/BLACKLIST +++ b/tests/auto/widgets/qwebengineview/BLACKLIST @@ -6,3 +6,6 @@ osx [textSelectionOutOfInputField] * + +[inputContextQueryInput] +windows -- cgit v1.2.3 From 20b5e2797c7495a69a4969c8eb2db90a2599d65c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 4 Jun 2019 16:13:43 +0000 Subject: Revert "Make .moc files jumbo built" This reverts commit 87570b4e360ab62ef5791d5c23ddd36aaa07ba05. Reason for revert: Made QTBUG-59769 worse Task-number: QTBUG-59769 Change-Id: I616930145eb6f89d6167f10d5be56b2ae898f29d Reviewed-by: Michal Klocek --- mkspecs/features/gn_generator.prf | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/mkspecs/features/gn_generator.prf b/mkspecs/features/gn_generator.prf index 78b56d123..863169c4d 100644 --- a/mkspecs/features/gn_generator.prf +++ b/mkspecs/features/gn_generator.prf @@ -26,8 +26,6 @@ isEmpty(GN_FILE): GN_FILE = $$system_path($$_PRO_FILE_PWD_/BUILD.gn) isEmpty(GN_RUN_BINARY_SCRIPT): GN_RUN_BINARY_SCRIPT = "//build/gn_run_binary.py" isEmpty(GN_FIND_MOCABLES_SCRIPT): GN_FIND_MOCABLES_SCRIPT = "//build/gn_find_mocables.py" -GN_CONTENTS += "import(\"//build/config/jumbo.gni\")" - # MOC SETUP GN_CONTENTS += "moc_source_h_files = exec_script(\"$$GN_FIND_MOCABLES_SCRIPT\"," @@ -176,26 +174,6 @@ GN_CONTENTS += "}" # TARGET SETUP -GN_CONTENTS += "jumbo_source_set(\"$${TARGET}_MOC\") {" -GN_CONTENTS += " configs += [ \":$${TARGET}_config\" ]" -GN_CONTENTS += " configs += [ \"//build/config:precompiled_headers\" ]" -GN_CONTENTS += " sources = []" -GN_CONTENTS += " deps = []" -GN_CONTENTS += " if (moc_source_h_files != []) {" -GN_CONTENTS += " deps += [" -GN_CONTENTS += " \":generate_h_mocs\"," -GN_CONTENTS += " ]" -# Add moc output files to compile -GN_CONTENTS += " sources += get_target_outputs(\":generate_h_mocs\")" -GN_CONTENTS += " }" -GN_CONTENTS += " if (moc_source_cpp_files != []) {" -GN_CONTENTS += " deps += [" -GN_CONTENTS += " \":generate_cpp_mocs\"," -GN_CONTENTS += " ]" -GN_CONTENTS += " }" -GN_CONTENTS += "}" - - TARGET_TYPE = $$getTargetType() GN_CONTENTS += "$${TARGET_TYPE}(\"$$TARGET\") {" @@ -248,7 +226,18 @@ win32 { CONFIG(rtti): GN_CONTENTS += " configs += [\"//build/config/compiler:rtti\"]" } -GN_CONTENTS += " deps += [ \":$${TARGET}_MOC\" ]" +GN_CONTENTS += " if (moc_source_h_files != []) {" +GN_CONTENTS += " deps += [" +GN_CONTENTS += " \":generate_h_mocs\"," +GN_CONTENTS += " ]" +# Add moc output files to compile +GN_CONTENTS += " sources += get_target_outputs(\":generate_h_mocs\")" +GN_CONTENTS += " }" +GN_CONTENTS += " if (moc_source_cpp_files != []) {" +GN_CONTENTS += " deps += [" +GN_CONTENTS += " \":generate_cpp_mocs\"," +GN_CONTENTS += " ]" +GN_CONTENTS += " }" GN_CONTENTS += "}" GN_CONTENTS += "" GN_CONTENTS += "if (!defined(core_include_dirs)) {"\ -- cgit v1.2.3