TEMPLATE = subdirs
-
SUBDIRS = src
+++ /dev/null
-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
-}
-
-
-
+++ /dev/null
-/****************************************************************************
-**
-** 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));
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** 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
**
****************************************************************************/
-#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)
{
}
}
-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())
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"))
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")
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);
}
+
**
****************************************************************************/
-#ifndef ENGINE_H
-#define ENGINE_H
+#ifndef APPENGINE_H
+#define APPENGINE_H
#include <QtCore/QEvent>
#include <QtCore/QFileInfo>
}
-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;
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
+++ /dev/null
-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
-
-
-
-
+++ /dev/null
-/****************************************************************************
-**
-** 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"
-
+++ /dev/null
-module WebBrowser
-plugin webbrowser
-class WebBrowser
-
**
****************************************************************************/
+#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")
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();
return
navigation.webView = tab.webView
- navigation.load(WebEngine.initialUrl);
+ var url = AppEngine.initialUrl
+
+ navigation.load();
}
onCurrentIndexChanged: {
if (!tabView.get(tabView.currentIndex))
property var acceptedUrls : []
function shouldAutoAccept(certificateError){
- var domain = WebEngine.domainFromString(certificateError.url)
+ var domain = AppEngine.domainFromString(certificateError.url)
return acceptedUrls.indexOf(domain) >= 0
}
}
"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()
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()
Component.onCompleted: {
listModel.clear()
- var string = WebEngine.restoreSetting("bookmarks", defaultBookmarks)
+ var string = AppEngine.restoreSetting("bookmarks", defaultBookmarks)
if (!string)
return
var list = JSON.parse(string)
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))
}
}
opacity: tabView.viewState == "page" ? 1.0 : 0.0
function load(url) {
- webView.url = url
+ if (url)
+ webView.url = url
homeScreen.state = "disabled"
}
}
}
onAccepted: {
- webView.url = WebEngine.fromUserInput(text)
+ webView.url = AppEngine.fromUserInput(text)
homeScreen.state = "disabled"
tabView.viewState = "page"
}
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
}
// Do not persist private browsing mode
if (setting.name === "Private Browsing")
continue
- WebEngine.saveSetting(setting.name, setting.active)
+ AppEngine.saveSetting(setting.name, setting.active)
}
}
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)
-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
}
****************************************************************************/
#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;
return QGuiApplication::notify(target, event);
}
- BrowserWindow* window = qobject_cast<BrowserWindow*>(target);
+ QQuickView* window = qobject_cast<QQuickView*>(target);
if (!window)
return QGuiApplication::notify(target, event);
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) {
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) {
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));
+ }
+}
#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;
QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
QSet<int> m_heldTouchPoints;
+ QHash<int, QQuickItem*> m_activeMockComponents;
bool m_holdingControl;
};
****************************************************************************/
#include "touchtracker.h"
+#include "appengine.h"
#include <QDateTime>
-#include "engine.h"
-
using namespace utils;
TouchTracker::TouchTracker(QQuickItem *parent)