2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2019-01-17 10:47:47 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-03-25 02:45:40 +01:00
|
|
|
#include "qmlpreview_global.h"
|
|
|
|
|
#include "qmldebugtranslationclient.h"
|
|
|
|
|
|
2019-03-13 08:06:08 +01:00
|
|
|
#include <projectexplorer/runcontrol.h>
|
2019-01-17 10:47:47 +01:00
|
|
|
#include <extensionsystem/iplugin.h>
|
|
|
|
|
#include <qmljs/qmljsdialect.h>
|
2019-03-13 08:06:08 +01:00
|
|
|
|
2019-01-17 10:47:47 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
|
|
namespace Core { class IEditor; }
|
|
|
|
|
|
2023-01-05 13:53:41 +01:00
|
|
|
namespace ProjectExplorer { class RunControl; }
|
|
|
|
|
|
2021-03-25 02:45:40 +01:00
|
|
|
namespace QmlDebug { class QmlDebugConnection; }
|
|
|
|
|
|
2019-01-17 10:47:47 +01:00
|
|
|
namespace QmlPreview {
|
|
|
|
|
|
2023-01-05 13:53:41 +01:00
|
|
|
using QmlPreviewFileClassifier = bool (*)(const QString &);
|
|
|
|
|
using QmlPreviewFileLoader = QByteArray (*)(const QString &, bool *);
|
|
|
|
|
using QmlPreviewFpsHandler = void (*)(quint16[8]);
|
|
|
|
|
using QmlPreviewRunControlList = QList<ProjectExplorer::RunControl *>;
|
|
|
|
|
using QmlDebugTranslationClientCreator =
|
|
|
|
|
std::function<std::unique_ptr<QmlDebugTranslationClient>(QmlDebug::QmlDebugConnection *)>;
|
2019-01-17 10:47:47 +01:00
|
|
|
|
2021-03-25 02:45:40 +01:00
|
|
|
class QMLPREVIEW_EXPORT QmlPreviewPlugin : public ExtensionSystem::IPlugin
|
2019-01-17 10:47:47 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlPreview.json")
|
|
|
|
|
Q_PROPERTY(QString previewedFile READ previewedFile WRITE setPreviewedFile
|
|
|
|
|
NOTIFY previewedFileChanged)
|
|
|
|
|
Q_PROPERTY(QmlPreview::QmlPreviewRunControlList runningPreviews READ runningPreviews
|
|
|
|
|
NOTIFY runningPreviewsChanged)
|
|
|
|
|
Q_PROPERTY(QmlPreview::QmlPreviewFileLoader fileLoader READ fileLoader
|
|
|
|
|
WRITE setFileLoader NOTIFY fileLoaderChanged)
|
|
|
|
|
Q_PROPERTY(QmlPreview::QmlPreviewFileClassifier fileClassifer READ fileClassifier
|
|
|
|
|
WRITE setFileClassifier NOTIFY fileClassifierChanged)
|
|
|
|
|
Q_PROPERTY(QmlPreview::QmlPreviewFpsHandler fpsHandler READ fpsHandler
|
|
|
|
|
WRITE setFpsHandler NOTIFY fpsHandlerChanged)
|
|
|
|
|
Q_PROPERTY(float zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
|
2020-09-28 08:20:23 +02:00
|
|
|
Q_PROPERTY(QString localeIsoCode READ localeIsoCode WRITE setLocaleIsoCode NOTIFY localeIsoCodeChanged)
|
2019-01-17 10:47:47 +01:00
|
|
|
|
|
|
|
|
public:
|
2019-08-13 10:57:37 +02:00
|
|
|
~QmlPreviewPlugin() override;
|
|
|
|
|
|
2023-01-20 12:28:36 +01:00
|
|
|
void initialize() override;
|
2019-01-17 10:47:47 +01:00
|
|
|
ShutdownFlag aboutToShutdown() override;
|
|
|
|
|
|
|
|
|
|
QString previewedFile() const;
|
|
|
|
|
void setPreviewedFile(const QString &previewedFile);
|
|
|
|
|
QmlPreviewRunControlList runningPreviews() const;
|
|
|
|
|
|
|
|
|
|
void setFileLoader(QmlPreviewFileLoader fileLoader);
|
|
|
|
|
QmlPreviewFileLoader fileLoader() const;
|
|
|
|
|
|
|
|
|
|
QmlPreviewFileClassifier fileClassifier() const;
|
|
|
|
|
void setFileClassifier(QmlPreviewFileClassifier fileClassifer);
|
|
|
|
|
|
|
|
|
|
float zoomFactor() const;
|
|
|
|
|
void setZoomFactor(float zoomFactor);
|
|
|
|
|
|
|
|
|
|
QmlPreview::QmlPreviewFpsHandler fpsHandler() const;
|
|
|
|
|
void setFpsHandler(QmlPreview::QmlPreviewFpsHandler fpsHandler);
|
|
|
|
|
|
2020-09-28 08:20:23 +02:00
|
|
|
QString localeIsoCode() const;
|
|
|
|
|
void setLocaleIsoCode(const QString &localeIsoCode);
|
2019-01-17 10:47:47 +01:00
|
|
|
|
2021-03-25 02:45:40 +01:00
|
|
|
void setQmlDebugTranslationClientCreator(QmlDebugTranslationClientCreator creator);
|
2020-07-23 08:37:37 +02:00
|
|
|
|
2023-01-05 13:53:41 +01:00
|
|
|
void previewCurrentFile();
|
|
|
|
|
void addPreview(ProjectExplorer::RunControl *preview);
|
|
|
|
|
void removePreview(ProjectExplorer::RunControl *preview);
|
|
|
|
|
|
2019-01-17 10:47:47 +01:00
|
|
|
signals:
|
|
|
|
|
void checkDocument(const QString &name, const QByteArray &contents,
|
|
|
|
|
QmlJS::Dialect::Enum dialect);
|
|
|
|
|
void updatePreviews(const QString &previewedFile, const QString &changedFile,
|
|
|
|
|
const QByteArray &contents);
|
|
|
|
|
void previewedFileChanged(const QString &previewedFile);
|
|
|
|
|
void runningPreviewsChanged(const QmlPreviewRunControlList &runningPreviews);
|
|
|
|
|
void rerunPreviews();
|
|
|
|
|
void fileLoaderChanged(QmlPreviewFileLoader fileLoader);
|
|
|
|
|
void fileClassifierChanged(QmlPreviewFileClassifier fileClassifer);
|
|
|
|
|
void fpsHandlerChanged(QmlPreview::QmlPreviewFpsHandler fpsHandler);
|
|
|
|
|
|
|
|
|
|
void zoomFactorChanged(float zoomFactor);
|
2020-09-28 08:20:23 +02:00
|
|
|
void localeIsoCodeChanged(const QString &localeIsoCode);
|
2019-01-17 10:47:47 +01:00
|
|
|
|
|
|
|
|
private:
|
2019-08-13 10:57:37 +02:00
|
|
|
class QmlPreviewPluginPrivate *d = nullptr;
|
2019-01-17 10:47:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlPreview
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QmlPreview::QmlPreviewFileLoader)
|
|
|
|
|
Q_DECLARE_METATYPE(QmlPreview::QmlPreviewFileClassifier)
|
|
|
|
|
Q_DECLARE_METATYPE(QmlPreview::QmlPreviewFpsHandler)
|
|
|
|
|
Q_DECLARE_METATYPE(QmlPreview::QmlPreviewRunControlList)
|