Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
16
18
23
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:313
\inmodule QtCore
Definition qmutex.h:281
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
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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]