7#include <QtGui/qguiapplication.h>
8#include <QtGui/qscreen.h>
9#include <QtGui/qicon.h>
11#include <QtQml/qqmlinfo.h>
12#include <QtQml/qqmlfile.h>
13#include <QtQml/qqmlabstracturlinterceptor.h>
29 if (setDevicePixelRatio)
32 return setDevicePixelRatio;
94 if (
d->async != async) {
123 if (
d->sourcesize ==
size)
126 d->sourcesize =
size;
136 int width =
d->sourcesize.width();
137 int height =
d->sourcesize.height();
149 return d->sourceClipRect;
155 if (
d->sourceClipRect ==
r)
158 d->sourceClipRect =
r;
159 d->providerOptions.setSourceClipRect(
r);
160 emit sourceClipRectChanged();
191 return d->currentPix->image();
197 if (
mirror ==
d->mirrorHorizontally)
200 d->mirrorHorizontally =
mirror;
211 return d->mirrorHorizontally;
217 if (
mirror ==
d->mirrorVertically)
225 emit mirrorVerticallyChanged();
231 return d->mirrorVertically;
249 emit currentFrameChanged();
255 return d->currentFrame;
261 return d->frameCount;
267 d->currentPix->clear(
this);
268 d->pendingPix->clear(
this);
289 QQuickPixmap::Options options;
294 d->pendingPix->clear(
this);
301 const qreal targetDevicePixelRatio = (
window() ?
window()->effectiveDevicePixelRatio() :
qApp->devicePixelRatio());
302 d->devicePixelRatio = 1.0;
303 bool updatedDevicePixelRatio =
false;
304 if (
d->sourcesize.isValid()
306 updatedDevicePixelRatio =
d->updateDevicePixelRatio(targetDevicePixelRatio);
309 if (!updatedDevicePixelRatio) {
313 targetDevicePixelRatio, &loadUrl, &
d->devicePixelRatio);
321 d->sourceClipRect.toRect(),
325 d->currentFrame,
d->frameCount,
326 d->devicePixelRatio);
328 if (
d->pendingPix->isLoading()) {
332 static int thisRequestProgress = -1;
333 static int thisRequestFinished = -1;
334 if (thisRequestProgress == -1) {
335 thisRequestProgress =
336 QQuickImageBase::staticMetaObject.indexOfSlot(
"requestProgress(qint64,qint64)");
337 thisRequestFinished =
338 QQuickImageBase::staticMetaObject.indexOfSlot(
"requestFinished()");
341 d->pendingPix->connectFinished(
this, thisRequestFinished);
342 d->pendingPix->connectDownloadProgress(
this, thisRequestProgress);
343 if (!
d->retainWhileLoading)
354 if (
d->url.isEmpty()) {
366 if (
d->pendingPix !=
d->currentPix) {
367 std::swap(
d->pendingPix,
d->currentPix);
368 d->pendingPix->clear(
this);
371 if (
d->currentPix->isError()) {
391 if (
d->frameCount !=
d->currentPix->frameCount()) {
392 d->frameCount =
d->currentPix->frameCount();
393 emit frameCountChanged();
395 if (
d->colorSpace !=
d->currentPix->colorSpace()) {
396 d->colorSpace =
d->currentPix->colorSpace();
397 emit colorSpaceChanged();
403void QQuickImageBase::requestProgress(
qint64 received,
qint64 total)
406 if (
d->status ==
Loading && total > 0)
407 d->setProgress(
qreal(received) / total);
415 const auto oldDpr =
d->devicePixelRatio;
421 if (
d->devicePixelRatio == oldDpr)
422 d->updateDevicePixelRatio(
value.realValue);
432 if (
d->url.isValid())
439 setImplicitSize(
d->currentPix->width() /
d->devicePixelRatio,
d->currentPix->height() /
d->devicePixelRatio);
449 if (disable2xImageLoading)
455 if (localFile.isEmpty())
459 int atLocation = localFile.lastIndexOf(
QLatin1Char(
'@'));
460 if (atLocation > 0 && atLocation + 3 < localFile.size()) {
461 if (localFile[atLocation + 1].
isDigit()
463 && localFile[atLocation + 3] ==
QLatin1Char(
'.')) {
464 *sourceDevicePixelRatio = localFile[atLocation + 1].digitValue();
471 if (localFileX != localFile)
496 return d->colorSpace;
505 d->providerOptions.setTargetColorSpace(
colorSpace);
506 emit colorSpaceChanged();
512 return d->retainWhileLoading;
522 if (
d->retainWhileLoading) {
523 if (
d->currentPix == &
d->pix1)
524 d->pendingPix = &
d->pix2;
526 d->pendingPix = &
d->pix1;
528 d->pendingPix->clear();
529 d->pendingPix =
d->currentPix;
535#include "moc_qquickimagebase_p.cpp"
The QColorSpace class provides a color space abstraction.
The QQmlContext class defines a context within a QML engine.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to \l{QFile}.
QQuickImageBase::Status status
virtual bool updateDevicePixelRatio(qreal targetDevicePixelRatio)
void setProgress(qreal value)
void setStatus(QQuickImageBase::Status value)
bool autoTransform() const
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
void setRetainWhileLoading(bool retain)
virtual void pixmapChange()
virtual void setMirror(bool mirror)
virtual void setAutoTransform(bool transform)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
virtual void setSourceSize(const QSize &)
void asynchronousChanged()
void statusChanged(QQuickImageBase::Status)
virtual void setColorSpace(const QColorSpace &colorSpace)
void resetSourceClipRect()
void loadPixmap(const QUrl &url, LoadPixmapOptions loadOptions=NoOption)
void setSourceClipRect(const QRectF &r)
static void resolve2xLocalFile(const QUrl &url, qreal targetDevicePixelRatio, QUrl *sourceUrl, qreal *sourceDevicePixelRatio)
QRectF sourceClipRect() const
virtual void setCurrentFrame(int frame)
virtual void requestFinished()
virtual void emitAutoTransformBaseChanged()
virtual void setSource(const QUrl &url)
void sourceChanged(const QUrl &)
void setAsynchronous(bool)
QQuickImageBase(QQuickItem *parent=nullptr)
virtual void setMirrorVertically(bool mirror)
The QQuickImageProviderOptions class provides options for QQuickImageProviderWithOptions image reques...
@ UsePluginDefaultTransform
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
QQuickWindow * window() const
Returns the window in which this item is rendered.
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
qreal height
This property holds the height of this item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
@ ItemDevicePixelRatioHasChanged
void update()
Schedules a call to updatePaintNode() for this item.
void setImplicitSize(qreal, qreal)
static bool isScalableImageFormat(const QUrl &url)
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, qreal *sourceDevicePixelRatio)
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static QT_BEGIN_NAMESPACE bool isDigit(ushort ch)
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
QUrl url("example.com")
[constructor-url-reference]
\inmodule QtCore \reentrant