1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qtwebviewfunctions.h"
5
6#include "qwebviewfactory_p.h"
7#include "qwebviewplugin_p.h"
8
9#include <QtCore/QCoreApplication>
10
11#if defined(QTWEBVIEW_LINK_WEBENGINE)
12# include <QtWebEngineQuick/QtWebEngineQuick>
13#endif
14
15QT_BEGIN_NAMESPACE
16
17/*!
18 \namespace QtWebView
19 \inmodule QtWebView
20 \brief The QtWebView namespace provides functions that makes it easier to set-up and use the WebView.
21 \inheaderfile QtWebView
22*/
23
24// This is a separate function so we can be sure that in non-static cases it can be registered
25// as a pre hook for QCoreApplication, ensuring this is called after the plugin paths have
26// been set to their defaults. For static builds then this will be called explicitly when
27// QtWebView::initialize() is called by the application
28
29static void initializeImpl()
30{
31 if (QWebViewFactory::requiresExtraInitializationSteps()) {
32 // There might be plugins available, but their dependencies might not be met,
33 // so make sure we have a valid plugin before using it.
34 // Note: A warning will be printed later if we're unable to load the plugin.
35 QWebViewPlugin *plugin = QWebViewFactory::getPlugin();
36 if (plugin)
37 plugin->prepare();
38 }
39}
40
41#ifndef QT_STATIC
42Q_COREAPP_STARTUP_FUNCTION(initializeImpl);
43#endif
44
45/*!
46 \fn void QtWebView::initialize()
47 \keyword qtwebview-initialize
48
49 This function initializes resources or sets options that are required by the different back-ends.
50
51 \note The \c initialize() function needs to be called immediately before the QGuiApplication
52 instance is created.
53 */
54
55void QtWebView::initialize()
56{
57#ifdef QT_STATIC
58 initializeImpl();
59#elif defined(QTWEBVIEW_LINK_WEBENGINE)
60 QtWebEngineQuick::initialize();
61#endif
62}
63
64QT_END_NAMESPACE
65

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtwebview/src/webview/qtwebviewfunctions.cpp