diff --git a/src/main.cpp b/src/main.cpp index efeffb6..9ebd00d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,88 +1,95 @@ /* Copyright (C) 2019 Jonah BrĂ¼chert This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "browsermanager.h" #include "urlfilterproxymodel.h" #include "urlmodel.h" #include "urlutils.h" #include "useragent.h" Q_DECL_EXPORT int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + + // Setup QtWebEngine + qputenv("QTWEBENGINE_DIALOG_SET", "QtQuickControls2"); +#if QT_VERSION > QT_VERSION_CHECK(5, 14, 0) + QtWebEngine::initialize(); +#endif + QApplication app(argc, argv); QCoreApplication::setOrganizationName("KDE"); QCoreApplication::setOrganizationDomain("mobile.kde.org"); QCoreApplication::setApplicationName("angelfish"); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + QtWebEngine::initialize(); +#endif + // Command line parser QCommandLineParser parser; parser.addPositionalArgument("url", i18n("URL to open"), "[url]"); parser.addOption({ "webapp-container", i18n("Start without UI") }); parser.addHelpOption(); parser.process(app); // QML loading QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); - // Setup QtWebEngine - qputenv("QTWEBENGINE_DIALOG_SET", "QtQuickControls2"); - QtWebEngine::initialize(); - // initial url command line parameter QUrl initialUrl; if (!parser.positionalArguments().isEmpty()) initialUrl = QUrl::fromUserInput(parser.positionalArguments().first()); engine.rootContext()->setContextProperty("initialUrl", initialUrl.url()); engine.rootContext()->setContextProperty("webappcontainer", parser.isSet("webapp-container")); // Browser manager qmlRegisterType("org.kde.mobile.angelfish", 1, 0, "BrowserManager"); qmlRegisterType("org.kde.mobile.angelfish", 1, 0, "UrlFilterProxyModel"); qmlRegisterType("org.kde.mobile.angelfish", 1, 0, "UserAgentGenerator"); // URL utils qmlRegisterSingletonType("org.kde.mobile.angelfish", 1, 0, "UrlUtils", [](QQmlEngine * /*engine*/, QJSEngine * /*scriptEngine*/) -> QObject * { AngelFish::UrlUtils *urlUtils = new AngelFish::UrlUtils(); return urlUtils; }); // Load QML engine.load(QUrl(QStringLiteral("qrc:///webbrowser.qml"))); // Error handling if (engine.rootObjects().isEmpty()) { return -1; } return app.exec(); }