Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickimagepreviewprovider.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <QtCore/qmutex.h>
6#include <QtCore/qdebug.h>
7
9
11{
15};
16
18
21{
22}
23
25{
27 QMutexLocker lock(&d->mutex);
28 d->id.clear();
29 d->image = QImage();
30}
31
33{
35 QMutexLocker lock(&d->mutex);
36
37 if (d->id != id)
38 return QImage();
39
40 QImage res = d->image;
41 if (!requestedSize.isEmpty())
42 res = res.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
43
44 if (size)
45 *size = res.size();
46
47 return res;
48}
49
51{
52 //only the last preview is kept
54 QMutexLocker lock(&d->mutex);
55 d->id = id;
56 d->image = preview;
57}
58
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qmutex.h:317
\inmodule QtCore
Definition qmutex.h:285
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override
Implement this method to return the image with id.
static void registerPreview(const QString &id, const QImage &preview)
The QQuickImageProvider class provides an interface for supporting pixmaps and threaded image request...
\inmodule QtCore
Definition qsize.h:25
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Definition qsize.h:123
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
@ SmoothTransformation
@ KeepAspectRatio
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
static const QMetaObjectPrivate * priv(const uint *data)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint id
[7]
GLuint res
QReadWriteLock lock
[0]