1 /****************************************************************************
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
6 ** This file is part of the QtBrowser project.
8 ** $QT_BEGIN_LICENSE:GPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 2 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.GPLv2 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU General Public License version 2 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 3.0 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 3.0 requirements will be
31 ** met: http://www.gnu.org/copyleft/gpl.html.
36 ****************************************************************************/
38 #include "appengine.h"
39 #include "navigationhistoryproxymodel.h"
40 #include "touchtracker.h"
42 #if defined(DESKTOP_BUILD)
43 #include "touchmockingapplication.h"
46 #include <QGuiApplication>
47 #include <QQmlContext>
50 #include <QtWebEngine/qtwebengineglobal.h>
52 static QObject *engine_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
55 Q_UNUSED(scriptEngine);
56 AppEngine *eng = new AppEngine();
60 int main(int argc, char **argv)
62 qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
64 //do not use any plugins installed on the device
65 qputenv("QML2_IMPORT_PATH", QByteArray());
67 // We use touch mocking on desktop and apply all the mobile switches.
68 QByteArrayList args = QByteArrayList()
69 << QByteArrayLiteral("--enable-embedded-switches")
70 << QByteArrayLiteral("--log-level=0");
71 const int count = args.size() + argc;
72 QVector<char*> qargv(count);
75 for (int i = 0; i < args.size(); ++i)
76 qargv[i + 1] = args[i].data();
77 for (int i = args.size() + 1; i < count; ++i)
78 qargv[i] = argv[i - args.size()];
80 int qAppArgCount = qargv.size();
82 #if defined(DESKTOP_BUILD)
83 TouchMockingApplication app(qAppArgCount, qargv.data());
85 QGuiApplication app(qAppArgCount, qargv.data());
88 qmlRegisterType<NavigationHistoryProxyModel>("WebBrowser", 1, 0, "SearchProxyModel");
89 qmlRegisterType<TouchTracker>("WebBrowser", 1, 0, "TouchTracker");
90 qmlRegisterSingletonType<AppEngine>("WebBrowser", 1, 0, "AppEngine", engine_factory);
92 QtWebEngine::initialize();
94 app.setOrganizationName("The Qt Company");
95 app.setOrganizationDomain("qt.io");
96 app.setApplicationName("qtwebbrowser");
99 view.setTitle("Yet Another Browser");
100 view.setFlags(Qt::Window | Qt::WindowTitleHint);
101 view.setResizeMode(QQuickView::SizeRootObjectToView);
102 view.setColor(Qt::black);
103 view.setSource(QUrl("qrc:///qml/BrowserWindow.qml"));
105 QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
107 #if defined(DESKTOP_BUILD)
109 if (view.size().isEmpty())
110 view.setGeometry(0, 0, 800, 600);
112 view.showFullScreen();