summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2019-04-01 18:41:23 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2019-04-02 11:19:47 +0000
commitf99fe9cee9d35e1fabbf45364631f4a7f049ebe3 (patch)
treeb569f82c4e9678b3f7e5ae0c7ade2e0ff498acfd /src/plugins/platforms/wasm
parent0683bbc67ccd5ad5d3a4c8afc6ed968b473bd2d3 (diff)
wasm: implement QDesktopServices::openUrl()
Call window.open(url, ”_blank”) for a new tab. Change-Id: I227904f905262c7aedd086203ed816b53f66359c Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms/wasm')
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp11
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.h4
-rw-r--r--src/plugins/platforms/wasm/qwasmservices.cpp45
-rw-r--r--src/plugins/platforms/wasm/qwasmservices.h45
-rw-r--r--src/plugins/platforms/wasm/wasm.pro6
5 files changed, 107 insertions, 4 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index 374b2e7e32..e601d553f2 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -34,6 +34,7 @@
#include "qwasmopenglcontext.h"
#include "qwasmtheme.h"
#include "qwasmclipboard.h"
+#include "qwasmservices.h"
#include "qwasmwindow.h"
#ifndef QT_NO_OPENGL
@@ -91,7 +92,7 @@ QWasmIntegration *QWasmIntegration::s_instance;
QWasmIntegration::QWasmIntegration()
: m_fontDb(nullptr),
- m_eventDispatcher(nullptr),
+ m_desktopServices(nullptr),
m_clipboard(new QWasmClipboard)
{
s_instance = this;
@@ -119,6 +120,7 @@ QWasmIntegration::QWasmIntegration()
QWasmIntegration::~QWasmIntegration()
{
delete m_fontDb;
+ delete m_desktopServices;
for (auto it = m_screens.constBegin(); it != m_screens.constEnd(); ++it)
QWindowSystemInterface::handleScreenRemoved(*it);
@@ -213,6 +215,13 @@ QPlatformTheme *QWasmIntegration::createPlatformTheme(const QString &name) const
return QPlatformIntegration::createPlatformTheme(name);
}
+QPlatformServices *QWasmIntegration::services() const
+{
+ if (m_desktopServices == nullptr)
+ m_desktopServices = new QWasmServices();
+ return m_desktopServices;
+}
+
QPlatformClipboard* QWasmIntegration::clipboard() const
{
return m_clipboard;
diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h
index ee0c7f769e..11d8d0f7f5 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.h
+++ b/src/plugins/platforms/wasm/qwasmintegration.h
@@ -50,6 +50,7 @@ class QWasmScreen;
class QWasmCompositor;
class QWasmBackingStore;
class QWasmClipboard;
+class QWasmServices;
class QWasmIntegration : public QObject, public QPlatformIntegration
{
@@ -70,6 +71,7 @@ public:
Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override;
QStringList themeNames() const override;
QPlatformTheme *createPlatformTheme(const QString &name) const override;
+ QPlatformServices *services() const override;
QPlatformClipboard *clipboard() const override;
QWasmClipboard *getWasmClipboard() { return m_clipboard; }
@@ -82,7 +84,7 @@ public:
private:
mutable QWasmFontDatabase *m_fontDb;
- mutable QWasmEventDispatcher *m_eventDispatcher;
+ mutable QWasmServices *m_desktopServices;
mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
QHash<QString, QWasmScreen *> m_screens;
diff --git a/src/plugins/platforms/wasm/qwasmservices.cpp b/src/plugins/platforms/wasm/qwasmservices.cpp
new file mode 100644
index 0000000000..9328b8c065
--- /dev/null
+++ b/src/plugins/platforms/wasm/qwasmservices.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwasmservices.h"
+#include <QtCore/QUrl>
+#include <QtCore/QDebug>
+
+#include <emscripten/val.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QWasmServices::openUrl(const QUrl &url)
+{
+ QByteArray utf8Url = url.toString().toUtf8();
+ emscripten::val::global("window").call<void>("open", emscripten::val(utf8Url.constData()), emscripten::val("_blank"));
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wasm/qwasmservices.h b/src/plugins/platforms/wasm/qwasmservices.h
new file mode 100644
index 0000000000..3b37f21f82
--- /dev/null
+++ b/src/plugins/platforms/wasm/qwasmservices.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWASMDESKTOPSERVICES_H
+#define QWASMDESKTOPSERVICES_H
+
+#include <qpa/qplatformservices.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWasmServices : public QPlatformServices
+{
+public:
+ bool openUrl(const QUrl &url) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWASMDESKTOPSERVICES_H
diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro
index 5aa6dfccf3..9b98445c68 100644
--- a/src/plugins/platforms/wasm/wasm.pro
+++ b/src/plugins/platforms/wasm/wasm.pro
@@ -19,7 +19,8 @@ SOURCES = \
qwasmcursor.cpp \
qwasmopenglcontext.cpp \
qwasmtheme.cpp \
- qwasmclipboard.cpp
+ qwasmclipboard.cpp \
+ qwasmservices.cpp
HEADERS = \
qwasmintegration.h \
@@ -33,7 +34,8 @@ HEADERS = \
qwasmcursor.h \
qwasmopenglcontext.h \
qwasmtheme.h \
- qwasmclipboard.h
+ qwasmclipboard.h \
+ qwasmservices.h
wasmfonts.files = \
../../../3rdparty/wasm/Vera.ttf \