wasm: implement QDesktopServices::openUrl()
Call window.open(url, ”_blank”) for a new tab. Change-Id: I227904f905262c7aedd086203ed816b53f66359c Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
parent
0683bbc67c
commit
f99fe9cee9
@ -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;
|
||||
|
@ -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;
|
||||
|
45
src/plugins/platforms/wasm/qwasmservices.cpp
Normal file
45
src/plugins/platforms/wasm/qwasmservices.cpp
Normal file
@ -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
|
45
src/plugins/platforms/wasm/qwasmservices.h
Normal file
45
src/plugins/platforms/wasm/qwasmservices.h
Normal file
@ -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
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user