Qt.labs.sharedimage: Make plugin optional
This moves the sharedimage types into a new library and is meant to make them availabe to the QML compiler at some point in the future. Task-number: QTBUG-90487 Change-Id: If79425a43cb8c1831422631791d35c1f329c7e80 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
9eda73354c
commit
cd8ae755c2
|
@ -9,19 +9,13 @@ qt_internal_add_qml_module(sharedimageplugin
|
||||||
VERSION "${CMAKE_PROJECT_VERSION}"
|
VERSION "${CMAKE_PROJECT_VERSION}"
|
||||||
CLASSNAME QtQuickSharedImagePlugin
|
CLASSNAME QtQuickSharedImagePlugin
|
||||||
SKIP_TYPE_REGISTRATION
|
SKIP_TYPE_REGISTRATION
|
||||||
GENERATE_QMLTYPES
|
PLUGIN_OPTIONAL
|
||||||
INSTALL_QMLTYPES
|
|
||||||
SOURCES
|
SOURCES
|
||||||
plugin.cpp
|
plugin.cpp
|
||||||
qsharedimageloader.cpp qsharedimageloader_p.h
|
|
||||||
sharedimageprovider.cpp sharedimageprovider.h
|
|
||||||
PUBLIC_LIBRARIES
|
PUBLIC_LIBRARIES
|
||||||
Qt::Core
|
Qt::Core
|
||||||
Qt::CorePrivate
|
|
||||||
Qt::Gui
|
|
||||||
Qt::GuiPrivate
|
|
||||||
Qt::Qml
|
Qt::Qml
|
||||||
Qt::QuickPrivate
|
Qt::LabsSharedImagePrivate
|
||||||
)
|
)
|
||||||
|
|
||||||
#### Keys ignored in scope 1:.:.:sharedimage.pro:<TRUE>:
|
#### Keys ignored in scope 1:.:.:sharedimage.pro:<TRUE>:
|
||||||
|
|
|
@ -37,10 +37,11 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QtLabsSharedImage/private/qtlabssharedimageglobal_p.h>
|
||||||
|
#include <QtLabsSharedImage/private/qsharedimageprovider_p.h>
|
||||||
|
|
||||||
#include <qqmlextensionplugin.h>
|
#include <qqmlextensionplugin.h>
|
||||||
#include <qqmlengine.h>
|
#include <qqmlengine.h>
|
||||||
#include <sharedimageprovider.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmlmodule Qt.labs.sharedimage 1
|
\qmlmodule Qt.labs.sharedimage 1
|
||||||
|
@ -99,8 +100,6 @@
|
||||||
The shared image module does not provide any directly usable QML types.
|
The shared image module does not provide any directly usable QML types.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void qml_register_types_Qt_labs_sharedimage();
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QtQuickSharedImagePlugin : public QQmlEngineExtensionPlugin
|
class QtQuickSharedImagePlugin : public QQmlEngineExtensionPlugin
|
||||||
|
|
|
@ -12,3 +12,7 @@ endif()
|
||||||
if(QT_FEATURE_quick_shadereffect AND TARGET Qt::Quick)
|
if(QT_FEATURE_quick_shadereffect AND TARGET Qt::Quick)
|
||||||
add_subdirectory(wavefrontmesh)
|
add_subdirectory(wavefrontmesh)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(QT_FEATURE_systemsemaphore AND TARGET Qt::Quick)
|
||||||
|
add_subdirectory(sharedimage)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
qt_internal_add_module(LabsSharedImage
|
||||||
|
GENERATE_METATYPES
|
||||||
|
SOURCES
|
||||||
|
qsharedimageloader.cpp qsharedimageloader_p.h
|
||||||
|
qsharedimageprovider.cpp qsharedimageprovider_p.h
|
||||||
|
qtlabssharedimageglobal_p.h
|
||||||
|
DEFINES
|
||||||
|
QT_BUILD_LABSSHAREDIMAGE_LIB
|
||||||
|
PUBLIC_LIBRARIES
|
||||||
|
Qt::CorePrivate
|
||||||
|
Qt::GuiPrivate
|
||||||
|
Qt::QuickPrivate
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set_target_properties(LabsSharedImage PROPERTIES
|
||||||
|
QT_QML_MODULE_INSTALL_QMLTYPES TRUE
|
||||||
|
QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION}
|
||||||
|
QT_QML_MODULE_URI Qt.labs.sharedimage
|
||||||
|
QT_QMLTYPES_FILENAME plugins.qmltypes
|
||||||
|
QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/sharedimage"
|
||||||
|
)
|
||||||
|
|
||||||
|
qt6_qml_type_registration(LabsSharedImage)
|
|
@ -40,6 +40,19 @@
|
||||||
#ifndef QSHAREDIMAGELOADER_H
|
#ifndef QSHAREDIMAGELOADER_H
|
||||||
#define QSHAREDIMAGELOADER_H
|
#define QSHAREDIMAGELOADER_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "qtlabssharedimageglobal_p.h"
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
@ -51,7 +64,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcSharedImage);
|
||||||
|
|
||||||
class QSharedImageLoaderPrivate;
|
class QSharedImageLoaderPrivate;
|
||||||
|
|
||||||
class QSharedImageLoader : public QObject
|
class Q_LABSSHAREDIMAGE_PRIVATE_EXPORT QSharedImageLoader : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DECLARE_PRIVATE(QSharedImageLoader)
|
Q_DECLARE_PRIVATE(QSharedImageLoader)
|
|
@ -37,8 +37,7 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <sharedimageprovider.h>
|
#include <qsharedimageprovider_p.h>
|
||||||
#include <qsharedimageloader_p.h>
|
|
||||||
#include <private/qquickpixmapcache_p.h>
|
#include <private/qquickpixmapcache_p.h>
|
||||||
#include <private/qimage_p.h>
|
#include <private/qimage_p.h>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
@ -47,26 +46,10 @@
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QQuickImageProviderOptions)
|
Q_DECLARE_METATYPE(QQuickImageProviderOptions)
|
||||||
|
|
||||||
class QuickSharedImageLoader : public QSharedImageLoader
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
friend class SharedImageProvider;
|
|
||||||
|
|
||||||
public:
|
QuickSharedImageLoader::QuickSharedImageLoader(QObject *parent) : QSharedImageLoader(parent) {}
|
||||||
enum ImageParameter {
|
|
||||||
OriginalSize = 0,
|
|
||||||
RequestedSize,
|
|
||||||
ProviderOptions,
|
|
||||||
NumImageParameters
|
|
||||||
};
|
|
||||||
|
|
||||||
QuickSharedImageLoader(QObject *parent = nullptr)
|
QImage QuickSharedImageLoader::loadFile(const QString &path, ImageParameters *params)
|
||||||
: QSharedImageLoader(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QImage loadFile(const QString &path, ImageParameters *params) override
|
|
||||||
{
|
{
|
||||||
QImageReader imgio(path);
|
QImageReader imgio(path);
|
||||||
QSize realSize = imgio.size();
|
QSize realSize = imgio.size();
|
||||||
|
@ -103,7 +86,7 @@ protected:
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString key(const QString &path, ImageParameters *params) override
|
QString QuickSharedImageLoader::key(const QString &path, ImageParameters *params)
|
||||||
{
|
{
|
||||||
QSize reqSz;
|
QSize reqSz;
|
||||||
QQuickImageProviderOptions opts;
|
QQuickImageProviderOptions opts;
|
||||||
|
@ -119,8 +102,6 @@ protected:
|
||||||
qCDebug(lcSharedImage) << "KEY:" << key;
|
qCDebug(lcSharedImage) << "KEY:" << key;
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SharedImageProvider::SharedImageProvider()
|
SharedImageProvider::SharedImageProvider()
|
||||||
: QQuickImageProviderWithOptions(QQuickImageProvider::Image), loader(new QuickSharedImageLoader)
|
: QQuickImageProviderWithOptions(QQuickImageProvider::Image), loader(new QuickSharedImageLoader)
|
||||||
|
@ -156,5 +137,3 @@ QImage SharedImageProvider::requestImage(const QString &id, QSize *size, const Q
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "sharedimageprovider.moc"
|
|
|
@ -37,16 +37,50 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef SHAREDIMAGEPROVIDER_H
|
#ifndef QSHAREDIMAGEPROVIDER_H
|
||||||
#define SHAREDIMAGEPROVIDER_H
|
#define QSHAREDIMAGEPROVIDER_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "qtlabssharedimageglobal_p.h"
|
||||||
|
|
||||||
#include <QQuickImageProvider>
|
#include <QQuickImageProvider>
|
||||||
#include <private/qquickpixmapcache_p.h>
|
#include <private/qquickpixmapcache_p.h>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
class QuickSharedImageLoader;
|
#include "qsharedimageloader_p.h"
|
||||||
|
|
||||||
class SharedImageProvider : public QQuickImageProviderWithOptions
|
class SharedImageProvider;
|
||||||
|
|
||||||
|
class QuickSharedImageLoader : public QSharedImageLoader
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
friend class SharedImageProvider;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ImageParameter {
|
||||||
|
OriginalSize = 0,
|
||||||
|
RequestedSize,
|
||||||
|
ProviderOptions,
|
||||||
|
NumImageParameters
|
||||||
|
};
|
||||||
|
|
||||||
|
QuickSharedImageLoader(QObject *parent = nullptr);
|
||||||
|
protected:
|
||||||
|
QImage loadFile(const QString &path, ImageParameters *params) override;
|
||||||
|
QString key(const QString &path, ImageParameters *params) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Q_LABSSHAREDIMAGE_PRIVATE_EXPORT SharedImageProvider : public QQuickImageProviderWithOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SharedImageProvider();
|
SharedImageProvider();
|
||||||
|
@ -56,4 +90,4 @@ public:
|
||||||
protected:
|
protected:
|
||||||
QScopedPointer<QuickSharedImageLoader> loader;
|
QScopedPointer<QuickSharedImageLoader> loader;
|
||||||
};
|
};
|
||||||
#endif // SHAREDIMAGEPROVIDER_H
|
#endif // QSHAREDIMAGEPROVIDER_H
|
|
@ -0,0 +1,73 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the QtQml module of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** 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 Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QTLABSSHAREDIMAGEGLOBAL_P_H
|
||||||
|
#define QTLABSSHAREDIMAGEGLOBAL_P_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#if !defined(QT_STATIC)
|
||||||
|
# if defined(QT_BUILD_LABSSHAREDIMAGE_LIB)
|
||||||
|
# define Q_LABSSHAREDIMAGE_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define Q_LABSSHAREDIMAGE_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define Q_LABSSHAREDIMAGE_EXPORT
|
||||||
|
#endif
|
||||||
|
#define Q_LABSSHAREDIMAGE_PRIVATE_EXPORT Q_LABSSHAREDIMAGE_EXPORT
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
void Q_LABSSHAREDIMAGE_PRIVATE_EXPORT qml_register_types_Qt_labs_sharedimage();
|
||||||
|
|
||||||
|
#endif // QTLABSSHAREDIMAGEGLOBAL_P_H
|
|
@ -17,7 +17,8 @@
|
||||||
"QtLabsFolderListModel" => "$basedir/src/labs/folderlistmodel",
|
"QtLabsFolderListModel" => "$basedir/src/labs/folderlistmodel",
|
||||||
"QtLabsAnimation" => "$basedir/src/labs/animation",
|
"QtLabsAnimation" => "$basedir/src/labs/animation",
|
||||||
"QtLabsWavefrontMesh" => "$basedir/src/labs/wavefrontmesh",
|
"QtLabsWavefrontMesh" => "$basedir/src/labs/wavefrontmesh",
|
||||||
"QtLabsQmlModels" => "$basedir/src/labs/models"
|
"QtLabsQmlModels" => "$basedir/src/labs/models",
|
||||||
|
"QtLabsSharedImage" => "$basedir/src/labs/sharedimage"
|
||||||
);
|
);
|
||||||
%inject_headers = (
|
%inject_headers = (
|
||||||
"$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h", "^qml_compile_hash_p.h" ],
|
"$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h", "^qml_compile_hash_p.h" ],
|
||||||
|
|
Loading…
Reference in New Issue