]> rtime.felk.cvut.cz Git - coffee/qtwebbrowser.git/commitdiff
Clean up the application after integration for b2qt
authorMichal Klocek <michal.klocek@theqtcompany.com>
Fri, 15 Jan 2016 17:37:02 +0000 (18:37 +0100)
committerMichal Klocek <michal.klocek@theqtcompany.com>
Mon, 18 Jan 2016 15:10:45 +0000 (15:10 +0000)
* put plugin.cpp into b2qt demo repository
* use resource file
* use AppEngine instead of WebEngine, WebEngine is already
registered with QtWebEgnine
* remove BrowserWindow class
* fix warnings and undefined errors in qml
* rename engine to appengine, qml name collision with launcherengine

Change-Id: I36b682a6a5e3c8f1453c9511c52561d0ff511e71
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
49 files changed:
qtwebbrowser.pro
src/app/app.pro [deleted file]
src/app/browserwindow.cpp [deleted file]
src/app/browserwindow.h [deleted file]
src/appengine.cpp [moved from src/app/engine.cpp with 87% similarity]
src/appengine.h [moved from src/app/engine.h with 92% similarity]
src/imports/imports.pro [deleted file]
src/imports/plugin.cpp [deleted file]
src/imports/qmldir [deleted file]
src/main.cpp [moved from src/app/main.cpp with 76% similarity]
src/navigationhistoryproxymodel.cpp [moved from src/app/navigationhistoryproxymodel.cpp with 100% similarity]
src/navigationhistoryproxymodel.h [moved from src/app/navigationhistoryproxymodel.h with 100% similarity]
src/qml/BrowserWindow.qml [moved from src/app/qml/BrowserWindow.qml with 97% similarity]
src/qml/FeaturePermissionBar.qml [moved from src/app/qml/FeaturePermissionBar.qml with 100% similarity]
src/qml/HomeScreen.qml [moved from src/app/qml/HomeScreen.qml with 99% similarity]
src/qml/MockTouchPoint.qml [moved from src/app/qml/MockTouchPoint.qml with 100% similarity]
src/qml/NavigationBar.qml [moved from src/app/qml/NavigationBar.qml with 99% similarity]
src/qml/PageView.qml [moved from src/app/qml/PageView.qml with 100% similarity]
src/qml/SettingsView.qml [moved from src/app/qml/SettingsView.qml with 98% similarity]
src/qml/Utils.js [moved from src/app/qml/Utils.js with 100% similarity]
src/qml/assets/UIButton.qml [moved from src/app/qml/assets/UIButton.qml with 100% similarity]
src/qml/assets/UIToolBar.qml [moved from src/app/qml/assets/UIToolBar.qml with 100% similarity]
src/qml/assets/icons/AppLogoColor.png [moved from src/app/qml/assets/icons/AppLogoColor.png with 100% similarity]
src/qml/assets/icons/AppLogoGrey.png [moved from src/app/qml/assets/icons/AppLogoGrey.png with 100% similarity]
src/qml/assets/icons/Btn_Add.png [moved from src/app/qml/assets/icons/Btn_Add.png with 100% similarity]
src/qml/assets/icons/Btn_Back.png [moved from src/app/qml/assets/icons/Btn_Back.png with 100% similarity]
src/qml/assets/icons/Btn_Bookmark_Checked.png [moved from src/app/qml/assets/icons/Btn_Bookmark_Checked.png with 100% similarity]
src/qml/assets/icons/Btn_Bookmark_Indicator.png [moved from src/app/qml/assets/icons/Btn_Bookmark_Indicator.png with 100% similarity]
src/qml/assets/icons/Btn_Bookmarks.png [moved from src/app/qml/assets/icons/Btn_Bookmarks.png with 100% similarity]
src/qml/assets/icons/Btn_Clear.png [moved from src/app/qml/assets/icons/Btn_Clear.png with 100% similarity]
src/qml/assets/icons/Btn_Delete.png [moved from src/app/qml/assets/icons/Btn_Delete.png with 100% similarity]
src/qml/assets/icons/Btn_Forward.png [moved from src/app/qml/assets/icons/Btn_Forward.png with 100% similarity]
src/qml/assets/icons/Btn_Home.png [moved from src/app/qml/assets/icons/Btn_Home.png with 100% similarity]
src/qml/assets/icons/Btn_Reload.png [moved from src/app/qml/assets/icons/Btn_Reload.png with 100% similarity]
src/qml/assets/icons/Btn_Search.png [moved from src/app/qml/assets/icons/Btn_Search.png with 100% similarity]
src/qml/assets/icons/Btn_Settings.png [moved from src/app/qml/assets/icons/Btn_Settings.png with 100% similarity]
src/qml/assets/icons/Btn_Tabs.png [moved from src/app/qml/assets/icons/Btn_Tabs.png with 100% similarity]
src/qml/assets/icons/Btn_Up.png [moved from src/app/qml/assets/icons/Btn_Up.png with 100% similarity]
src/qml/assets/icons/Error_Icon.png [moved from src/app/qml/assets/icons/Error_Icon.png with 100% similarity]
src/qml/assets/icons/LightWebBrowser_Icons.svg [moved from src/app/qml/assets/icons/LightWebBrowser_Icons.svg with 100% similarity]
src/qml/assets/icons/about_blank.png [moved from src/app/qml/assets/icons/about_blank.png with 100% similarity]
src/qml/assets/icons/qt.png [moved from src/app/qml/assets/icons/qt.png with 100% similarity]
src/qml/assets/icons/touchpoint.png [moved from src/app/qml/assets/icons/touchpoint.png with 100% similarity]
src/resources.qrc [moved from src/app/resources.qrc with 100% similarity]
src/src.pro
src/touchmockingapplication.cpp [moved from src/app/touchmockingapplication.cpp with 83% similarity]
src/touchmockingapplication.h [moved from src/app/touchmockingapplication.h with 78% similarity]
src/touchtracker.cpp [moved from src/app/touchtracker.cpp with 99% similarity]
src/touchtracker.h [moved from src/app/touchtracker.h with 100% similarity]

index be734fb1153b4269f85695f5bccecf224f3d2884..65d926226c2e1ebe6b9282f4659fb57d869574b9 100644 (file)
@@ -1,3 +1,2 @@
 TEMPLATE = subdirs
-
 SUBDIRS = src
diff --git a/src/app/app.pro b/src/app/app.pro
deleted file mode 100644 (file)
index 7b9b8a2..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-TARGET = qtwebbrowser
-
-DESTDIR = ../
-CONFIG += c++11
-CONFIG -= app_bundle
-
-SOURCES = main.cpp \
-    browserwindow.cpp \
-    engine.cpp
-
-HEADERS = browserwindow.h \
-    engine.h
-
-OTHER_FILES = \
-    qml/assets/UIButton.qml \
-    qml/assets/UIToolBar.qml \
-    qml/ApplicationRoot.qml \
-    qml/BrowserWindow.qml \
-    qml/FeaturePermissionBar.qml \
-    qml/MockTouchPoint.qml \
-    qml/PageView.qml \
-    qml/NavigationBar.qml \
-    qml/HomeScreen.qml \
-    qml/SettingsView.qml \
-
-QT += qml quick webengine
-
-RESOURCES += resources.qrc
-
-!cross_compile {
-    DEFINES += HOST_BUILD
-    SOURCES += touchmockingapplication.cpp \
-            navigationhistoryproxymodel.cpp \
-            touchtracker.cpp
-
-    HEADERS += touchmockingapplication.h \
-                navigationhistoryproxymodel.h \
-                touchtracker.h
-
-    QT_PRIVATE += quick-private gui-private core-private
-}
-else {
-    DESTPATH = /data/user/qt/qtwebbrowser
-
-    content.files = qml/*
-    content.path = $$DESTPATH
-    target.path = $$DESTPATH
-
-    INSTALLS += target content
-}
-
-
-
diff --git a/src/app/browserwindow.cpp b/src/app/browserwindow.cpp
deleted file mode 100644 (file)
index 41d8d2a..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtBrowser project.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPLv2 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "browserwindow.h"
-
-#include <QList>
-#include <QQmlContext>
-#include <QQmlEngine>
-#include <QQuickItem>
-#include <QRectF>
-#include <QUrl>
-#include <QVariant>
-
-#include "engine.h"
-
-void BrowserWindow::ensureProfileInstance()
-{
-    if (m_lazyProfileInstance)
-        return;
-    QQmlComponent *component =  new QQmlComponent(engine(), this);
-
-    component->setData(
-                QByteArrayLiteral("import QtQuick 2.0\n"
-                                  "import QtWebEngine 1.1\n"
-                                  "WebEngineProfile {\n"
-                                  "  storageName: \"YABProfile\"\n"
-                                  "}")
-                , QUrl());
-    m_lazyProfileInstance = component->create(engine()->rootContext());
-    Q_ASSERT(m_lazyProfileInstance);
-    QQmlEngine::setObjectOwnership(m_lazyProfileInstance, QQmlEngine::JavaScriptOwnership);
-}
-
-QObject *BrowserWindow::defaultProfile()
-{
-    ensureProfileInstance();
-    return m_lazyProfileInstance;
-}
-
-BrowserWindow::BrowserWindow(QWindow *)
-    : m_lazyProfileInstance(0)
-{
-    setTitle("Yet Another Browser");
-    setFlags(Qt::Window | Qt::WindowTitleHint);
-    setResizeMode(QQuickView::SizeRootObjectToView);
-    setColor(Qt::black);
-
-    engine()->rootContext()->setContextProperty("WebEngine", new Engine(this));
-    setSource(QUrl("qrc:///qml/BrowserWindow.qml"));
-}
-
-BrowserWindow::~BrowserWindow()
-{
-}
-
-void BrowserWindow::updateVisualMockTouchPoints(const QList<QTouchEvent::TouchPoint>& touchPoints)
-{
-    if (touchPoints.isEmpty()) {
-        // Hide all touch indicator items.
-        foreach (QQuickItem* item, m_activeMockComponents.values())
-            item->setProperty("pressed", false);
-
-        return;
-    }
-
-    foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) {
-        QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id());
-
-        if (!mockTouchPointItem) {
-            QQmlComponent touchMockPointComponent(engine(), QUrl("qrc:///qml/MockTouchPoint.qml"));
-            mockTouchPointItem = qobject_cast<QQuickItem*>(touchMockPointComponent.create());
-            Q_ASSERT(mockTouchPointItem);
-            m_activeMockComponents.insert(touchPoint.id(), mockTouchPointItem);
-            mockTouchPointItem->setProperty("pointId", QVariant(touchPoint.id()));
-            mockTouchPointItem->setParent(rootObject());
-            mockTouchPointItem->setParentItem(rootObject());
-        }
-
-        QRectF touchRect = touchPoint.rect();
-        mockTouchPointItem->setX(touchRect.center().x());
-        mockTouchPointItem->setY(touchRect.center().y());
-        mockTouchPointItem->setWidth(touchRect.width());
-        mockTouchPointItem->setHeight(touchRect.height());
-        mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != Qt::TouchPointReleased));
-    }
-}
diff --git a/src/app/browserwindow.h b/src/app/browserwindow.h
deleted file mode 100644 (file)
index 1d055bf..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtBrowser project.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPLv2 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef BROWSERWINDOW_H
-#define BROWSERWINDOW_H
-
-#include <QHash>
-#include <QTouchEvent>
-#include <QQuickView>
-#include <QQmlComponent>
-
-class BrowserWindow : public QQuickView
-{
-    Q_OBJECT
-
-    QHash<int, QQuickItem*> m_activeMockComponents;
-    QObject *m_lazyProfileInstance;
-
-    void ensureProfileInstance();
-public:
-    BrowserWindow(QWindow *parent = 0);
-    ~BrowserWindow();
-
-    void updateVisualMockTouchPoints(const QList<QTouchEvent::TouchPoint>& touchPoints);
-
-public Q_SLOTS:
-    QObject *defaultProfile();
-};
-
-#endif // BROWSERWINDOW_H
similarity index 87%
rename from src/app/engine.cpp
rename to src/appengine.cpp
index 3c8d0d02334ef42840876d9aa5d358a22ed61ccd..7be0e5baabbf68fabe5259ae72d3228599b80271 100644 (file)
 **
 ****************************************************************************/
 
-#include "engine.h"
+#include "appengine.h"
 
 #include <QtCore/QDir>
 #include <QtCore/QStandardPaths>
 #include <QStringBuilder>
 #include <QCoreApplication>
 
-Engine::Engine(QObject *parent)
+AppEngine::AppEngine(QObject *parent)
     : QObject(parent)
     , m_settings(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) % QDir::separator() % "settings.ini", QSettings::IniFormat, this)
 {
@@ -57,17 +57,17 @@ Engine::Engine(QObject *parent)
     }
 }
 
-QString Engine::settingsPath()
+QString AppEngine::settingsPath()
 {
     return m_settings.fileName();
 }
 
-QString Engine::initialUrl() const
+QString AppEngine::initialUrl() const
 {
     return m_initialUrl;
 }
 
-QUrl Engine::fromUserInput(const QString& userInput)
+QUrl AppEngine::fromUserInput(const QString& userInput)
 {
     QFileInfo fileInfo(userInput);
     if (fileInfo.exists())
@@ -75,7 +75,7 @@ QUrl Engine::fromUserInput(const QString& userInput)
     return QUrl::fromUserInput(userInput);
 }
 
-bool Engine::isUrl(const QString& userInput)
+bool AppEngine::isUrl(const QString& userInput)
 {
     if (userInput.startsWith(QStringLiteral("www."))
             || userInput.startsWith(QStringLiteral("http"))
@@ -86,12 +86,12 @@ bool Engine::isUrl(const QString& userInput)
     return false;
 }
 
-QString Engine::domainFromString(const QString& urlString)
+QString AppEngine::domainFromString(const QString& urlString)
 {
     return QUrl::fromUserInput(urlString).host();
 }
 
-QString Engine::fallbackColor()
+QString AppEngine::fallbackColor()
 {
     static QList<QString> colors = QList<QString>() << QStringLiteral("#46a2da")
                                                     << QStringLiteral("#18394c")
@@ -103,12 +103,13 @@ QString Engine::fallbackColor()
     return colors[index];
 }
 
-QString Engine::restoreSetting(const QString &name, const QString &defaultValue)
+QString AppEngine::restoreSetting(const QString &name, const QString &defaultValue)
 {
     return m_settings.value(name, defaultValue).toString();
 }
 
-void Engine::saveSetting(const QString &name, const QString &value)
+void AppEngine::saveSetting(const QString &name, const QString &value)
 {
     m_settings.setValue(name, value);
 }
+
similarity index 92%
rename from src/app/engine.h
rename to src/appengine.h
index af60dad4346035bbb294a5c446ecd20634b7df51..808f3b74c6ed8a01e1b095dbec8e2a2eac683b04 100644 (file)
@@ -35,8 +35,8 @@
 **
 ****************************************************************************/
 
-#ifndef ENGINE_H
-#define ENGINE_H
+#ifndef APPENGINE_H
+#define APPENGINE_H
 
 #include <QtCore/QEvent>
 #include <QtCore/QFileInfo>
@@ -73,22 +73,15 @@ inline bool isMouseEvent(const QEvent* event)
 
 }
 
-class Engine : public QObject {
+class AppEngine : public QObject {
     Q_OBJECT
 
-    Q_PROPERTY(QObject * rootWindow READ rootWindow FINAL CONSTANT)
     Q_PROPERTY(QString settingsPath READ settingsPath FINAL CONSTANT)
     Q_PROPERTY(QString initialUrl READ initialUrl FINAL CONSTANT)
 
-    QSettings m_settings;
-    QString m_initialUrl;
-
 public:
-    Engine(QObject *parent = 0);
-    QObject *rootWindow()
-    {
-        return parent();
-    }
+    AppEngine(QObject *parent = 0);
+
     QString settingsPath();
     QString initialUrl() const;
 
@@ -98,6 +91,10 @@ public:
     Q_INVOKABLE QString fallbackColor();
     Q_INVOKABLE QString restoreSetting(const QString &name, const QString &defaultValue = QString());
     Q_INVOKABLE void saveSetting(const QString &name, const QString &value);
+
+private:
+    QSettings m_settings;
+    QString m_initialUrl;
 };
 
-#endif // ENGINE_H
+#endif // APPENGINE_H
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
deleted file mode 100644 (file)
index 22f5ec1..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-CXX_MODULE = qml
-TARGET = webbrowser
-TARGETPATH = WebBrowser
-QT += qml quick
-CONFIG += qt
-
-SOURCES += \
-    plugin.cpp
-
-load(qml_plugin)
-
-target.path += /data/user/qt/qmlplugins/WebBrowser
-INSTALLS += target
-
-
-
-
diff --git a/src/imports/plugin.cpp b/src/imports/plugin.cpp
deleted file mode 100644 (file)
index ebd59c1..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtBrowser project.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPLv2 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QQmlExtensionPlugin>
-#include "../app/touchtracker.h"
-#include "../app/navigationhistoryproxymodel.h"
-
-#include <qqml.h>
-#include "../app/engine.cpp"
-#include <QQmlEngine>
-#include <QQmlContext>
-#include <QtQml/qqmlextensionplugin.h>
-#include <qqml.h>
-
-QT_BEGIN_NAMESPACE
-
-static QObject *engine_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
-{
-    Q_UNUSED(engine);
-    Q_UNUSED(scriptEngine);
-    Engine *eng = new Engine();
-    return eng;
-}
-
-class WebBrowser : public QQmlExtensionPlugin
-{
-    Q_OBJECT
-    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
-public:
-    virtual void registerTypes(const char *uri)
-    {
-        Q_ASSERT(QLatin1String(uri) == QLatin1String("WebBrowser"));
-        qmlRegisterType<TouchTracker>(uri, 1, 0, "TouchTracker");
-        qmlRegisterType<NavigationHistoryProxyModel>(uri, 1, 0, "SearchProxyModel");
-        qmlRegisterSingletonType<Engine>(uri, 1, 0, "WebEngine", engine_factory);
-    }
-
-    virtual void initializeEngine(QQmlEngine *engine, const char *uri)
-    {
-        Q_UNUSED(uri);
-    }
-};
-
-QT_END_NAMESPACE
-
-#include "plugin.moc"
-
diff --git a/src/imports/qmldir b/src/imports/qmldir
deleted file mode 100644 (file)
index 89b8c78..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-module WebBrowser
-plugin webbrowser
-class WebBrowser
-
similarity index 76%
rename from src/app/main.cpp
rename to src/main.cpp
index f4fbf5dc2f54fefa9a391ef7c274a4149a3a0a43..79cb41b740bc647f41c8e86b08b45b81d7ac1e0d 100644 (file)
 **
 ****************************************************************************/
 
+#include "appengine.h"
+#include "navigationhistoryproxymodel.h"
+#include "touchtracker.h"
+
+#if defined(DESKTOP_BUILD)
+#include "touchmockingapplication.h"
+#endif
+
 #include <QGuiApplication>
 #include <QQmlContext>
 #include <QQmlEngine>
 #include <QQuickView>
 #include <QtWebEngine/qtwebengineglobal.h>
 
-#include "browserwindow.h"
+static QObject *engine_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+    Q_UNUSED(engine);
+    Q_UNUSED(scriptEngine);
+    AppEngine *eng = new AppEngine();
+    return eng;
+}
 
-#if defined(HOST_BUILD)
-#include "touchmockingapplication.h"
-#include "navigationhistoryproxymodel.h"
-#include "touchtracker.h"
-#endif
 int main(int argc, char **argv)
 {
     qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
+
+    //do not use any plugins installed on the device
+    qputenv("QML2_IMPORT_PATH", QByteArray());
+
     // We use touch mocking on desktop and apply all the mobile switches.
     QByteArrayList args = QByteArrayList()
             << QByteArrayLiteral("--enable-embedded-switches")
@@ -65,29 +78,38 @@ int main(int argc, char **argv)
         qargv[i] = argv[i - args.size()];
 
     int qAppArgCount = qargv.size();
-#if defined(HOST_BUILD)
-    TouchMockingApplication app(qAppArgCount, qargv.data());
 
-    qmlRegisterType<TouchTracker>("WebBrowser", 1, 0, "TouchTracker");
-    qmlRegisterType<NavigationHistoryProxyModel>("WebBrowser", 1, 0, "SearchProxyModel");
+#if defined(DESKTOP_BUILD)
+    TouchMockingApplication app(qAppArgCount, qargv.data());
 #else
     QGuiApplication app(qAppArgCount, qargv.data());
 #endif
+
+    qmlRegisterType<NavigationHistoryProxyModel>("WebBrowser", 1, 0, "SearchProxyModel");
+    qmlRegisterType<TouchTracker>("WebBrowser", 1, 0, "TouchTracker");
+    qmlRegisterSingletonType<AppEngine>("WebBrowser", 1, 0, "AppEngine", engine_factory);
+
     QtWebEngine::initialize();
 
     app.setOrganizationName("The Qt Company");
     app.setOrganizationDomain("qt.io");
     app.setApplicationName("qtwebbrowser");
 
-    BrowserWindow window;
-    QObject::connect(window.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
+    QQuickView view;
+    view.setTitle("Yet Another Browser");
+    view.setFlags(Qt::Window | Qt::WindowTitleHint);
+    view.setResizeMode(QQuickView::SizeRootObjectToView);
+    view.setColor(Qt::black);
+    view.setSource(QUrl("qrc:///qml/BrowserWindow.qml"));
+
+    QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
 
-#if defined(HOST_BUILD)
-    window.show();
-    if (window.size().isEmpty())
-        window.setGeometry(0, 0, 800, 600);
+#if defined(DESKTOP_BUILD)
+    view.show();
+    if (view.size().isEmpty())
+        view.setGeometry(0, 0, 800, 600);
 #else
-    window.showFullScreen();
+    view.showFullScreen();
 #endif
 
     app.exec();
similarity index 97%
rename from src/app/qml/BrowserWindow.qml
rename to src/qml/BrowserWindow.qml
index 6f6f07ccfbd0904a755d6199523998a623271ddb..c639340e6bf74de6699ce121ced3af8821023c91 100644 (file)
@@ -215,7 +215,9 @@ Item {
                 return
 
             navigation.webView = tab.webView
-            navigation.load(WebEngine.initialUrl);
+            var url = AppEngine.initialUrl
+
+            navigation.load();
         }
         onCurrentIndexChanged: {
             if (!tabView.get(tabView.currentIndex))
@@ -230,7 +232,7 @@ Item {
         property var acceptedUrls : []
 
         function shouldAutoAccept(certificateError){
-            var domain = WebEngine.domainFromString(certificateError.url)
+            var domain = AppEngine.domainFromString(certificateError.url)
             return acceptedUrls.indexOf(domain) >= 0
         }
     }
@@ -251,7 +253,7 @@ Item {
                       "Do you wish to override the security check and continue?"
         onYes: {
             var cert = certErrors.shift()
-            var domain = WebEngine.domainFromString(cert.url)
+            var domain = AppEngine.domainFromString(cert.url)
             acceptedCertificates.acceptedUrls.push(domain)
             cert.ignoreCertificateError()
             presentError()
@@ -398,10 +400,10 @@ Item {
                     onClicked: {
                         var string = urlDropDown.searchString
                         var constructedUrl = ""
-                        if (WebEngine.isUrl(string)) {
-                            constructedUrl = WebEngine.fromUserInput(string)
+                        if (AppEngine.isUrl(string)) {
+                            constructedUrl = AppEngine.fromUserInput(string)
                         } else {
-                            constructedUrl = WebEngine.fromUserInput(googleSearchQuery + string)
+                            constructedUrl = AppEngine.fromUserInput(googleSearchQuery + string)
                         }
                         navigation.webView.url = constructedUrl
                         navigation.webView.forceActiveFocus()
similarity index 99%
rename from src/app/qml/HomeScreen.qml
rename to src/qml/HomeScreen.qml
index 25100252c6eda99f32a5df2fd3b105ac546eba51..d1ac349e615a2ea60a07ca35c6c80efcd1e567bd 100644 (file)
@@ -129,7 +129,7 @@ Rectangle {
 
         Component.onCompleted: {
             listModel.clear()
-            var string = WebEngine.restoreSetting("bookmarks", defaultBookmarks)
+            var string = AppEngine.restoreSetting("bookmarks", defaultBookmarks)
             if (!string)
                 return
             var list = JSON.parse(string)
@@ -143,7 +143,7 @@ Rectangle {
             for (var i = 0; i < listModel.count; ++i) {
                 list[i] = listModel.get(i)
             }
-            WebEngine.saveSetting("bookmarks", JSON.stringify(list))
+            AppEngine.saveSetting("bookmarks", JSON.stringify(list))
         }
     }
 
similarity index 99%
rename from src/app/qml/NavigationBar.qml
rename to src/qml/NavigationBar.qml
index 140ec916ed1807b58c8ecd95c7bae75760af8db1..fe85326a4ec86d78cbbf6613ca302881824d28d7 100644 (file)
@@ -56,7 +56,8 @@ ToolBar {
     opacity: tabView.viewState == "page" ? 1.0 : 0.0
 
     function load(url) {
-        webView.url = url
+        if (url)
+            webView.url = url
         homeScreen.state = "disabled"
     }
 
@@ -277,7 +278,7 @@ ToolBar {
                 }
             }
             onAccepted: {
-                webView.url = WebEngine.fromUserInput(text)
+                webView.url = AppEngine.fromUserInput(text)
                 homeScreen.state = "disabled"
                 tabView.viewState = "page"
             }
@@ -400,7 +401,7 @@ ToolBar {
                     return
                 }
                 var count = homeScreen.count
-                homeScreen.add(webView.title, webView.url, icon, WebEngine.fallbackColor())
+                homeScreen.add(webView.title, webView.url, icon, AppEngine.fallbackColor())
                 if (count < homeScreen.count)
                     bookmarked = true
             }
similarity index 98%
rename from src/app/qml/SettingsView.qml
rename to src/qml/SettingsView.qml
index 8ae6f649cb5338ccf5c537753f7a32305f5770d2..b801bcf1d8f7fae2e2934582e8475a3561295443 100644 (file)
@@ -67,7 +67,7 @@ Rectangle {
             // Do not persist private browsing mode
             if (setting.name === "Private Browsing")
                 continue
-            WebEngine.saveSetting(setting.name, setting.active)
+            AppEngine.saveSetting(setting.name, setting.active)
         }
     }
 
@@ -170,7 +170,7 @@ Rectangle {
         Component.onCompleted: {
             for (var i = 0; i < appSettings.length; ++i) {
                 var setting = appSettings[i]
-                var active = JSON.parse(WebEngine.restoreSetting(setting.name, setting.active))
+                var active = JSON.parse(AppEngine.restoreSetting(setting.name, setting.active))
                 if (setting.active !== active) {
                     setting.active = active
                     setting.notify(active)
similarity index 100%
rename from src/app/qml/Utils.js
rename to src/qml/Utils.js
similarity index 100%
rename from src/app/resources.qrc
rename to src/resources.qrc
index b5ae6760214ce40861cd381d867eb25bd7ea605b..22762f9e63932eeca41f557997ecfda89ab2aa4a 100644 (file)
@@ -1,8 +1,41 @@
-TEMPLATE = subdirs
-SUBDIRS += \
-    app
+TARGET = qtwebbrowser
 
-cross_compile {
-    SUBDIRS += \
-        imports
+CONFIG += c++11
+CONFIG -= app_bundle
+
+SOURCES = \
+    appengine.cpp \
+    main.cpp \
+    navigationhistoryproxymodel.cpp \
+    touchtracker.cpp
+
+HEADERS = \
+    appengine.h \
+    navigationhistoryproxymodel.h \
+    touchtracker.h \
+
+OTHER_FILES = \
+    qml/assets/UIButton.qml \
+    qml/assets/UIToolBar.qml \
+    qml/ApplicationRoot.qml \
+    qml/BrowserWindow.qml \
+    qml/FeaturePermissionBar.qml \
+    qml/MockTouchPoint.qml \
+    qml/PageView.qml \
+    qml/NavigationBar.qml \
+    qml/HomeScreen.qml \
+    qml/SettingsView.qml \
+
+QT += qml quick webengine
+
+RESOURCES += resources.qrc
+
+!cross_compile {
+    DEFINES += DESKTOP_BUILD
+    SOURCES += touchmockingapplication.cpp
+    HEADERS += touchmockingapplication.h
+    QT += gui-private
+} else {
+    target.path =/data/user/qt/qtwebbrowser-app
+    INSTALLS += target
 }
similarity index 83%
rename from src/app/touchmockingapplication.cpp
rename to src/touchmockingapplication.cpp
index 4819b01c6e3aae17c6224468a44345dab2f57b54..256c45ead6562a59819e19ce504457d29f4e8152 100644 (file)
 ****************************************************************************/
 
 #include "touchmockingapplication.h"
+#include "appengine.h"
 
 #include <qpa/qwindowsysteminterface.h>
-
-#include <QRegExp>
-#include <QEvent>
-#include <QMouseEvent>
-#include <QTouchEvent>
-
-#include "engine.h"
+#include <QtCore/QRegExp>
+#include <QtCore/QEvent>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QTouchEvent>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
 
 using namespace utils;
 
@@ -79,7 +79,7 @@ bool TouchMockingApplication::notify(QObject* target, QEvent* event)
         return QGuiApplication::notify(target, event);
     }
 
-    BrowserWindow* window = qobject_cast<BrowserWindow*>(target);
+    QQuickView* window = qobject_cast<QQuickView*>(target);
     if (!window)
         return QGuiApplication::notify(target, event);
 
@@ -216,7 +216,7 @@ void TouchMockingApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QT
     m_touchPoints.insert(mouseButton, touchPoint);
 }
 
-bool TouchMockingApplication::sendTouchEvent(BrowserWindow* window, QEvent::Type type, ulong timestamp)
+bool TouchMockingApplication::sendTouchEvent(QQuickView* window, QEvent::Type type, ulong timestamp)
 {
     static QTouchDevice* device = 0;
     if (!device) {
@@ -238,7 +238,7 @@ bool TouchMockingApplication::sendTouchEvent(BrowserWindow* window, QEvent::Type
 
     QGuiApplication::notify(window, &event);
 
-    window->updateVisualMockTouchPoints(m_holdingControl ? currentTouchPoints : QList<QTouchEvent::TouchPoint>());
+    updateVisualMockTouchPoints(window,m_holdingControl ? currentTouchPoints : QList<QTouchEvent::TouchPoint>());
 
     // Get rid of touch-points that are no longer valid
     foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) {
@@ -249,3 +249,34 @@ bool TouchMockingApplication::sendTouchEvent(BrowserWindow* window, QEvent::Type
     return event.isAccepted();
 }
 
+void TouchMockingApplication::updateVisualMockTouchPoints(QQuickView* window,const QList<QTouchEvent::TouchPoint>& touchPoints)
+{
+    if (touchPoints.isEmpty()) {
+        // Hide all touch indicator items.
+        foreach (QQuickItem* item, m_activeMockComponents.values())
+            item->setProperty("pressed", false);
+
+        return;
+    }
+
+    foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) {
+        QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id());
+
+        if (!mockTouchPointItem) {
+            QQmlComponent touchMockPointComponent(window->engine(), QUrl("qrc:///qml/MockTouchPoint.qml"));
+            mockTouchPointItem = qobject_cast<QQuickItem*>(touchMockPointComponent.create());
+            Q_ASSERT(mockTouchPointItem);
+            m_activeMockComponents.insert(touchPoint.id(), mockTouchPointItem);
+            mockTouchPointItem->setProperty("pointId", QVariant(touchPoint.id()));
+            mockTouchPointItem->setParent(window->rootObject());
+            mockTouchPointItem->setParentItem(window->rootObject());
+        }
+
+        QRectF touchRect = touchPoint.rect();
+        mockTouchPointItem->setX(touchRect.center().x());
+        mockTouchPointItem->setY(touchRect.center().y());
+        mockTouchPointItem->setWidth(touchRect.width());
+        mockTouchPointItem->setHeight(touchRect.height());
+        mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != Qt::TouchPointReleased));
+    }
+}
similarity index 78%
rename from src/app/touchmockingapplication.h
rename to src/touchmockingapplication.h
index 6350436ff5fd3e151445e26a2c2c0ed7c754eb7c..88c5e20c9e5c8736a9c7717a6fbf7ad5ce32975d 100644 (file)
 #ifndef TOUCHMOCKINGAPPLICATION_H
 #define TOUCHMOCKINGAPPLICATION_H
 
-#include "browserwindow.h"
+#include <QtCore/QHash>
+#include <QtCore/QUrl>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QTouchEvent>
 
-#include <QHash>
-#include <QGuiApplication>
-#include <QTouchEvent>
-#include <QUrl>
+QT_BEGIN_NAMESPACE
+class QQuickView;
+class QQuickItem;
+QT_END_NAMESPACE
 
 class TouchMockingApplication : public QGuiApplication
 {
     Q_OBJECT
 
 public:
-    TouchMockingApplication(int &argc, char** argv);
+    TouchMockingApplication(int &argc, char **argv);
 
-    virtual bool notify(QObject*, QEvent*) override;
+    virtual bool notify(QObject *, QEvent *) override;
 
 private:
-    void updateTouchPoint(const QMouseEvent*, QTouchEvent::TouchPoint, Qt::MouseButton);
-    bool sendTouchEvent(BrowserWindow *, QEvent::Type, ulong timestamp);
+    void updateTouchPoint(const QMouseEvent *, QTouchEvent::TouchPoint, Qt::MouseButton);
+    bool sendTouchEvent(QQuickView *, QEvent::Type, ulong timestamp);
+    void updateVisualMockTouchPoints(QQuickView *,const QList<QTouchEvent::TouchPoint> &touchPoints);
 
 private:
     bool m_realTouchEventReceived;
@@ -68,6 +72,7 @@ private:
 
     QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
     QSet<int> m_heldTouchPoints;
+    QHash<int, QQuickItem*> m_activeMockComponents;
 
     bool m_holdingControl;
 };
similarity index 99%
rename from src/app/touchtracker.cpp
rename to src/touchtracker.cpp
index 16b57c19c5f673d8de94f8db17e1d89a2a38b3dd..52a028afa1b1fc48fcac1588bc6d4a2eaf1ac34e 100644 (file)
 ****************************************************************************/
 
 #include "touchtracker.h"
+#include "appengine.h"
 
 #include <QDateTime>
 
-#include "engine.h"
-
 using namespace utils;
 
 TouchTracker::TouchTracker(QQuickItem *parent)
similarity index 100%
rename from src/app/touchtracker.h
rename to src/touchtracker.h