2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2012-02-16 04:43:03 +00:00
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2012-09-20 05:21:40 +00:00
|
|
|
** 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
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 09:38:36 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-20 05:21:40 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-20 05:21:40 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2016-01-19 09:38:36 +00:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 3 requirements
|
|
|
|
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 2.0 or (at your option) the GNU General
|
|
|
|
** Public license version 3 or 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.GPL2 and 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-2.0.html and
|
|
|
|
** https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
#ifndef QQUICKWORKERSCRIPT_P_H
|
|
|
|
#define QQUICKWORKERSCRIPT_P_H
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
2017-10-23 12:49:22 +00:00
|
|
|
#include <qqml.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2020-01-30 09:48:21 +00:00
|
|
|
#include <QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h>
|
2013-01-23 23:17:27 +00:00
|
|
|
#include <QtQml/qqmlparserstatus.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <QtCore/qthread.h>
|
2012-02-16 04:43:03 +00:00
|
|
|
#include <QtQml/qjsvalue.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <QtCore/qurl.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
class QQuickWorkerScript;
|
|
|
|
class QQuickWorkerScriptEnginePrivate;
|
|
|
|
class QQuickWorkerScriptEngine : public QThread
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-02-21 09:41:54 +00:00
|
|
|
QQuickWorkerScriptEngine(QQmlEngine *parent = nullptr);
|
2016-09-19 09:05:31 +00:00
|
|
|
~QQuickWorkerScriptEngine();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
int registerWorkerScript(QQuickWorkerScript *);
|
2011-04-27 10:05:43 +00:00
|
|
|
void removeWorkerScript(int);
|
|
|
|
void executeUrl(int, const QUrl &);
|
2011-05-11 07:20:40 +00:00
|
|
|
void sendMessage(int, const QByteArray &);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
protected:
|
2016-09-19 09:05:31 +00:00
|
|
|
void run() override;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private:
|
2012-02-16 04:43:03 +00:00
|
|
|
QQuickWorkerScriptEnginePrivate *d;
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
class QQmlV4Function;
|
2021-07-12 12:49:10 +00:00
|
|
|
class Q_QMLWORKERSCRIPT_PRIVATE_EXPORT QQuickWorkerScript : public QObject, public QQmlParserStatus
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-07-14 07:35:37 +00:00
|
|
|
Q_DISABLE_COPY_MOVE(QQuickWorkerScript)
|
2011-04-27 10:05:43 +00:00
|
|
|
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
|
2020-03-09 00:00:06 +00:00
|
|
|
Q_PROPERTY(bool ready READ ready NOTIFY readyChanged REVISION(2, 15))
|
2019-12-06 09:56:22 +00:00
|
|
|
|
2019-08-21 16:34:21 +00:00
|
|
|
QML_NAMED_ELEMENT(WorkerScript);
|
2020-01-16 12:42:11 +00:00
|
|
|
QML_ADDED_IN_VERSION(2, 0)
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
Q_INTERFACES(QQmlParserStatus)
|
2011-04-27 10:05:43 +00:00
|
|
|
public:
|
2018-02-21 09:41:54 +00:00
|
|
|
QQuickWorkerScript(QObject *parent = nullptr);
|
2016-09-19 09:05:31 +00:00
|
|
|
~QQuickWorkerScript();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QUrl source() const;
|
|
|
|
void setSource(const QUrl &);
|
|
|
|
|
2019-12-06 09:56:22 +00:00
|
|
|
bool ready() const;
|
|
|
|
|
2013-09-09 13:55:04 +00:00
|
|
|
public Q_SLOTS:
|
2013-05-08 14:22:39 +00:00
|
|
|
void sendMessage(QQmlV4Function*);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2013-09-09 13:55:04 +00:00
|
|
|
Q_SIGNALS:
|
2011-04-27 10:05:43 +00:00
|
|
|
void sourceChanged();
|
2020-03-09 00:00:06 +00:00
|
|
|
Q_REVISION(2, 15) void readyChanged();
|
2019-04-04 14:00:36 +00:00
|
|
|
void message(const QJSValue &messageObject);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
protected:
|
2016-09-19 09:05:31 +00:00
|
|
|
void classBegin() override;
|
|
|
|
void componentComplete() override;
|
|
|
|
bool event(QEvent *) override;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private:
|
2012-02-16 04:43:03 +00:00
|
|
|
QQuickWorkerScriptEngine *engine();
|
|
|
|
QQuickWorkerScriptEngine *m_engine;
|
2011-04-27 10:05:43 +00:00
|
|
|
int m_scriptId;
|
|
|
|
QUrl m_source;
|
|
|
|
bool m_componentComplete;
|
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
QML_DECLARE_TYPE(QQuickWorkerScript)
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
#endif // QQUICKWORKERSCRIPT_P_H
|