summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2016-01-15 18:37:02 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2016-01-18 15:10:45 +0000
commit60a8ef724c11c35413d42ef1ccd118e9c4f6c3c9 (patch)
tree9181e29679d53c1cde1a07cdefe2dbcae40091e6
parent5b999a1817e7829c87977b5d99f75a179ec36fda (diff)
Clean up the application after integration for b2qt
* 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>
-rw-r--r--qtwebbrowser.pro1
-rw-r--r--src/app/app.pro53
-rw-r--r--src/app/browserwindow.cpp120
-rw-r--r--src/app/browserwindow.h64
-rw-r--r--src/appengine.cpp (renamed from src/app/engine.cpp)21
-rw-r--r--src/appengine.h (renamed from src/app/engine.h)23
-rw-r--r--src/imports/imports.pro17
-rw-r--r--src/imports/plugin.cpp81
-rw-r--r--src/imports/qmldir4
-rw-r--r--src/main.cpp (renamed from src/app/main.cpp)56
-rw-r--r--src/navigationhistoryproxymodel.cpp (renamed from src/app/navigationhistoryproxymodel.cpp)0
-rw-r--r--src/navigationhistoryproxymodel.h (renamed from src/app/navigationhistoryproxymodel.h)0
-rw-r--r--src/qml/BrowserWindow.qml (renamed from src/app/qml/BrowserWindow.qml)14
-rw-r--r--src/qml/FeaturePermissionBar.qml (renamed from src/app/qml/FeaturePermissionBar.qml)0
-rw-r--r--src/qml/HomeScreen.qml (renamed from src/app/qml/HomeScreen.qml)4
-rw-r--r--src/qml/MockTouchPoint.qml (renamed from src/app/qml/MockTouchPoint.qml)0
-rw-r--r--src/qml/NavigationBar.qml (renamed from src/app/qml/NavigationBar.qml)7
-rw-r--r--src/qml/PageView.qml (renamed from src/app/qml/PageView.qml)0
-rw-r--r--src/qml/SettingsView.qml (renamed from src/app/qml/SettingsView.qml)4
-rw-r--r--src/qml/Utils.js (renamed from src/app/qml/Utils.js)0
-rw-r--r--src/qml/assets/UIButton.qml (renamed from src/app/qml/assets/UIButton.qml)0
-rw-r--r--src/qml/assets/UIToolBar.qml (renamed from src/app/qml/assets/UIToolBar.qml)0
-rw-r--r--src/qml/assets/icons/AppLogoColor.png (renamed from src/app/qml/assets/icons/AppLogoColor.png)bin6113 -> 6113 bytes
-rw-r--r--src/qml/assets/icons/AppLogoGrey.png (renamed from src/app/qml/assets/icons/AppLogoGrey.png)bin5539 -> 5539 bytes
-rw-r--r--src/qml/assets/icons/Btn_Add.png (renamed from src/app/qml/assets/icons/Btn_Add.png)bin1169 -> 1169 bytes
-rw-r--r--src/qml/assets/icons/Btn_Back.png (renamed from src/app/qml/assets/icons/Btn_Back.png)bin1184 -> 1184 bytes
-rw-r--r--src/qml/assets/icons/Btn_Bookmark_Checked.png (renamed from src/app/qml/assets/icons/Btn_Bookmark_Checked.png)bin1696 -> 1696 bytes
-rw-r--r--src/qml/assets/icons/Btn_Bookmark_Indicator.png (renamed from src/app/qml/assets/icons/Btn_Bookmark_Indicator.png)bin1972 -> 1972 bytes
-rw-r--r--src/qml/assets/icons/Btn_Bookmarks.png (renamed from src/app/qml/assets/icons/Btn_Bookmarks.png)bin1792 -> 1792 bytes
-rw-r--r--src/qml/assets/icons/Btn_Clear.png (renamed from src/app/qml/assets/icons/Btn_Clear.png)bin1467 -> 1467 bytes
-rw-r--r--src/qml/assets/icons/Btn_Delete.png (renamed from src/app/qml/assets/icons/Btn_Delete.png)bin2793 -> 2793 bytes
-rw-r--r--src/qml/assets/icons/Btn_Forward.png (renamed from src/app/qml/assets/icons/Btn_Forward.png)bin1178 -> 1178 bytes
-rw-r--r--src/qml/assets/icons/Btn_Home.png (renamed from src/app/qml/assets/icons/Btn_Home.png)bin1461 -> 1461 bytes
-rw-r--r--src/qml/assets/icons/Btn_Reload.png (renamed from src/app/qml/assets/icons/Btn_Reload.png)bin1614 -> 1614 bytes
-rw-r--r--src/qml/assets/icons/Btn_Search.png (renamed from src/app/qml/assets/icons/Btn_Search.png)bin1691 -> 1691 bytes
-rw-r--r--src/qml/assets/icons/Btn_Settings.png (renamed from src/app/qml/assets/icons/Btn_Settings.png)bin1149 -> 1149 bytes
-rw-r--r--src/qml/assets/icons/Btn_Tabs.png (renamed from src/app/qml/assets/icons/Btn_Tabs.png)bin1235 -> 1235 bytes
-rw-r--r--src/qml/assets/icons/Btn_Up.png (renamed from src/app/qml/assets/icons/Btn_Up.png)bin1223 -> 1223 bytes
-rw-r--r--src/qml/assets/icons/Error_Icon.png (renamed from src/app/qml/assets/icons/Error_Icon.png)bin4371 -> 4371 bytes
-rw-r--r--src/qml/assets/icons/LightWebBrowser_Icons.svg (renamed from src/app/qml/assets/icons/LightWebBrowser_Icons.svg)0
-rw-r--r--src/qml/assets/icons/about_blank.png (renamed from src/app/qml/assets/icons/about_blank.png)bin6022 -> 6022 bytes
-rw-r--r--src/qml/assets/icons/qt.png (renamed from src/app/qml/assets/icons/qt.png)bin7345 -> 7345 bytes
-rw-r--r--src/qml/assets/icons/touchpoint.png (renamed from src/app/qml/assets/icons/touchpoint.png)bin1331 -> 1331 bytes
-rw-r--r--src/resources.qrc (renamed from src/app/resources.qrc)0
-rw-r--r--src/src.pro45
-rw-r--r--src/touchmockingapplication.cpp (renamed from src/app/touchmockingapplication.cpp)51
-rw-r--r--src/touchmockingapplication.h (renamed from src/app/touchmockingapplication.h)23
-rw-r--r--src/touchtracker.cpp (renamed from src/app/touchtracker.cpp)3
-rw-r--r--src/touchtracker.h (renamed from src/app/touchtracker.h)0
49 files changed, 171 insertions, 420 deletions
diff --git a/qtwebbrowser.pro b/qtwebbrowser.pro
index be734fb..65d9262 100644
--- a/qtwebbrowser.pro
+++ b/qtwebbrowser.pro
@@ -1,3 +1,2 @@
TEMPLATE = subdirs
-
SUBDIRS = src
diff --git a/src/app/app.pro b/src/app/app.pro
deleted file mode 100644
index 7b9b8a2..0000000
--- a/src/app/app.pro
+++ /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
index 41d8d2a..0000000
--- a/src/app/browserwindow.cpp
+++ /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
index 1d055bf..0000000
--- a/src/app/browserwindow.h
+++ /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
diff --git a/src/app/engine.cpp b/src/appengine.cpp
index 3c8d0d0..7be0e5b 100644
--- a/src/app/engine.cpp
+++ b/src/appengine.cpp
@@ -35,14 +35,14 @@
**
****************************************************************************/
-#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);
}
+
diff --git a/src/app/engine.h b/src/appengine.h
index af60dad..808f3b7 100644
--- a/src/app/engine.h
+++ b/src/appengine.h
@@ -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
index 22f5ec1..0000000
--- a/src/imports/imports.pro
+++ /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
index ebd59c1..0000000
--- a/src/imports/plugin.cpp
+++ /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
index 89b8c78..0000000
--- a/src/imports/qmldir
+++ /dev/null
@@ -1,4 +0,0 @@
-module WebBrowser
-plugin webbrowser
-class WebBrowser
-
diff --git a/src/app/main.cpp b/src/main.cpp
index f4fbf5d..79cb41b 100644
--- a/src/app/main.cpp
+++ b/src/main.cpp
@@ -35,22 +35,35 @@
**
****************************************************************************/
+#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();
diff --git a/src/app/navigationhistoryproxymodel.cpp b/src/navigationhistoryproxymodel.cpp
index d574ae5..d574ae5 100644
--- a/src/app/navigationhistoryproxymodel.cpp
+++ b/src/navigationhistoryproxymodel.cpp
diff --git a/src/app/navigationhistoryproxymodel.h b/src/navigationhistoryproxymodel.h
index c2e3886..c2e3886 100644
--- a/src/app/navigationhistoryproxymodel.h
+++ b/src/navigationhistoryproxymodel.h
diff --git a/src/app/qml/BrowserWindow.qml b/src/qml/BrowserWindow.qml
index 6f6f07c..c639340 100644
--- a/src/app/qml/BrowserWindow.qml
+++ b/src/qml/BrowserWindow.qml
@@ -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()
diff --git a/src/app/qml/FeaturePermissionBar.qml b/src/qml/FeaturePermissionBar.qml
index 8595724..8595724 100644
--- a/src/app/qml/FeaturePermissionBar.qml
+++ b/src/qml/FeaturePermissionBar.qml
diff --git a/src/app/qml/HomeScreen.qml b/src/qml/HomeScreen.qml
index 2510025..d1ac349 100644
--- a/src/app/qml/HomeScreen.qml
+++ b/src/qml/HomeScreen.qml
@@ -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))
}
}
diff --git a/src/app/qml/MockTouchPoint.qml b/src/qml/MockTouchPoint.qml
index f7fa1b1..f7fa1b1 100644
--- a/src/app/qml/MockTouchPoint.qml
+++ b/src/qml/MockTouchPoint.qml
diff --git a/src/app/qml/NavigationBar.qml b/src/qml/NavigationBar.qml
index 140ec91..fe85326 100644
--- a/src/app/qml/NavigationBar.qml
+++ b/src/qml/NavigationBar.qml
@@ -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
}
diff --git a/src/app/qml/PageView.qml b/src/qml/PageView.qml
index 87381ce..87381ce 100644
--- a/src/app/qml/PageView.qml
+++ b/src/qml/PageView.qml
diff --git a/src/app/qml/SettingsView.qml b/src/qml/SettingsView.qml
index 8ae6f64..b801bcf 100644
--- a/src/app/qml/SettingsView.qml
+++ b/src/qml/SettingsView.qml
@@ -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)
diff --git a/src/app/qml/Utils.js b/src/qml/Utils.js
index 88e2bbe..88e2bbe 100644
--- a/src/app/qml/Utils.js
+++ b/src/qml/Utils.js
diff --git a/src/app/qml/assets/UIButton.qml b/src/qml/assets/UIButton.qml
index cc9351f..cc9351f 100644
--- a/src/app/qml/assets/UIButton.qml
+++ b/src/qml/assets/UIButton.qml
diff --git a/src/app/qml/assets/UIToolBar.qml b/src/qml/assets/UIToolBar.qml
index 39a0974..39a0974 100644
--- a/src/app/qml/assets/UIToolBar.qml
+++ b/src/qml/assets/UIToolBar.qml
diff --git a/src/app/qml/assets/icons/AppLogoColor.png b/src/qml/assets/icons/AppLogoColor.png
index 2a49717..2a49717 100644
--- a/src/app/qml/assets/icons/AppLogoColor.png
+++ b/src/qml/assets/icons/AppLogoColor.png
Binary files differ
diff --git a/src/app/qml/assets/icons/AppLogoGrey.png b/src/qml/assets/icons/AppLogoGrey.png
index b2baae5..b2baae5 100644
--- a/src/app/qml/assets/icons/AppLogoGrey.png
+++ b/src/qml/assets/icons/AppLogoGrey.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Add.png b/src/qml/assets/icons/Btn_Add.png
index 3c45c42..3c45c42 100644
--- a/src/app/qml/assets/icons/Btn_Add.png
+++ b/src/qml/assets/icons/Btn_Add.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Back.png b/src/qml/assets/icons/Btn_Back.png
index 562c9f6..562c9f6 100644
--- a/src/app/qml/assets/icons/Btn_Back.png
+++ b/src/qml/assets/icons/Btn_Back.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Bookmark_Checked.png b/src/qml/assets/icons/Btn_Bookmark_Checked.png
index a6dbe6a..a6dbe6a 100644
--- a/src/app/qml/assets/icons/Btn_Bookmark_Checked.png
+++ b/src/qml/assets/icons/Btn_Bookmark_Checked.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Bookmark_Indicator.png b/src/qml/assets/icons/Btn_Bookmark_Indicator.png
index a8b8b6b..a8b8b6b 100644
--- a/src/app/qml/assets/icons/Btn_Bookmark_Indicator.png
+++ b/src/qml/assets/icons/Btn_Bookmark_Indicator.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Bookmarks.png b/src/qml/assets/icons/Btn_Bookmarks.png
index fc286cc..fc286cc 100644
--- a/src/app/qml/assets/icons/Btn_Bookmarks.png
+++ b/src/qml/assets/icons/Btn_Bookmarks.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Clear.png b/src/qml/assets/icons/Btn_Clear.png
index 1c9870a..1c9870a 100644
--- a/src/app/qml/assets/icons/Btn_Clear.png
+++ b/src/qml/assets/icons/Btn_Clear.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Delete.png b/src/qml/assets/icons/Btn_Delete.png
index 2010838..2010838 100644
--- a/src/app/qml/assets/icons/Btn_Delete.png
+++ b/src/qml/assets/icons/Btn_Delete.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Forward.png b/src/qml/assets/icons/Btn_Forward.png
index e4c96f8..e4c96f8 100644
--- a/src/app/qml/assets/icons/Btn_Forward.png
+++ b/src/qml/assets/icons/Btn_Forward.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Home.png b/src/qml/assets/icons/Btn_Home.png
index 7358a59..7358a59 100644
--- a/src/app/qml/assets/icons/Btn_Home.png
+++ b/src/qml/assets/icons/Btn_Home.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Reload.png b/src/qml/assets/icons/Btn_Reload.png
index cff41cd..cff41cd 100644
--- a/src/app/qml/assets/icons/Btn_Reload.png
+++ b/src/qml/assets/icons/Btn_Reload.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Search.png b/src/qml/assets/icons/Btn_Search.png
index a6ef383..a6ef383 100644
--- a/src/app/qml/assets/icons/Btn_Search.png
+++ b/src/qml/assets/icons/Btn_Search.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Settings.png b/src/qml/assets/icons/Btn_Settings.png
index 33d7400..33d7400 100644
--- a/src/app/qml/assets/icons/Btn_Settings.png
+++ b/src/qml/assets/icons/Btn_Settings.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Tabs.png b/src/qml/assets/icons/Btn_Tabs.png
index c007408..c007408 100644
--- a/src/app/qml/assets/icons/Btn_Tabs.png
+++ b/src/qml/assets/icons/Btn_Tabs.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Btn_Up.png b/src/qml/assets/icons/Btn_Up.png
index f70a78d..f70a78d 100644
--- a/src/app/qml/assets/icons/Btn_Up.png
+++ b/src/qml/assets/icons/Btn_Up.png
Binary files differ
diff --git a/src/app/qml/assets/icons/Error_Icon.png b/src/qml/assets/icons/Error_Icon.png
index cf40696..cf40696 100644
--- a/src/app/qml/assets/icons/Error_Icon.png
+++ b/src/qml/assets/icons/Error_Icon.png
Binary files differ
diff --git a/src/app/qml/assets/icons/LightWebBrowser_Icons.svg b/src/qml/assets/icons/LightWebBrowser_Icons.svg
index fce4b40..fce4b40 100644
--- a/src/app/qml/assets/icons/LightWebBrowser_Icons.svg
+++ b/src/qml/assets/icons/LightWebBrowser_Icons.svg
diff --git a/src/app/qml/assets/icons/about_blank.png b/src/qml/assets/icons/about_blank.png
index 6901b0b..6901b0b 100644
--- a/src/app/qml/assets/icons/about_blank.png
+++ b/src/qml/assets/icons/about_blank.png
Binary files differ
diff --git a/src/app/qml/assets/icons/qt.png b/src/qml/assets/icons/qt.png
index 6a22d2e..6a22d2e 100644
--- a/src/app/qml/assets/icons/qt.png
+++ b/src/qml/assets/icons/qt.png
Binary files differ
diff --git a/src/app/qml/assets/icons/touchpoint.png b/src/qml/assets/icons/touchpoint.png
index 7649ee9..7649ee9 100644
--- a/src/app/qml/assets/icons/touchpoint.png
+++ b/src/qml/assets/icons/touchpoint.png
Binary files differ
diff --git a/src/app/resources.qrc b/src/resources.qrc
index 93b48eb..93b48eb 100644
--- a/src/app/resources.qrc
+++ b/src/resources.qrc
diff --git a/src/src.pro b/src/src.pro
index b5ae676..22762f9 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -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
}
diff --git a/src/app/touchmockingapplication.cpp b/src/touchmockingapplication.cpp
index 4819b01..256c45e 100644
--- a/src/app/touchmockingapplication.cpp
+++ b/src/touchmockingapplication.cpp
@@ -36,15 +36,15 @@
****************************************************************************/
#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));
+ }
+}
diff --git a/src/app/touchmockingapplication.h b/src/touchmockingapplication.h
index 6350436..88c5e20 100644
--- a/src/app/touchmockingapplication.h
+++ b/src/touchmockingapplication.h
@@ -38,25 +38,29 @@
#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;
};
diff --git a/src/app/touchtracker.cpp b/src/touchtracker.cpp
index 16b57c1..52a028a 100644
--- a/src/app/touchtracker.cpp
+++ b/src/touchtracker.cpp
@@ -36,11 +36,10 @@
****************************************************************************/
#include "touchtracker.h"
+#include "appengine.h"
#include <QDateTime>
-#include "engine.h"
-
using namespace utils;
TouchTracker::TouchTracker(QQuickItem *parent)
diff --git a/src/app/touchtracker.h b/src/touchtracker.h
index 3aaecd2..3aaecd2 100644
--- a/src/app/touchtracker.h
+++ b/src/touchtracker.h