KIO

thumbnailcreator.cpp
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 Malte Starostik <malte@kde.org>
4 SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "thumbnailcreator.h"
10
11#include <QImage>
12
13namespace KIO
14{
15
16class ThumbnailRequestPrivate
17{
18public:
19 QUrl url;
20 QSize targetSize;
21 QString mimeType;
22 qreal dpr;
23 float sequenceIndex;
24};
25
26ThumbnailRequest::~ThumbnailRequest() = default;
27
28ThumbnailRequest::ThumbnailRequest(const ThumbnailRequest &other)
29{
30 d = std::make_unique<ThumbnailRequestPrivate>(*other.d);
31}
32
33ThumbnailRequest &ThumbnailRequest::operator=(const ThumbnailRequest &other)
34{
35 ThumbnailRequest temp(other);
36 std::swap(*d, *temp.d);
37 return *this;
38}
39
40ThumbnailRequest::ThumbnailRequest(const QUrl &url, const QSize &targetSize, const QString &mimeType, qreal dpr, float sequenceIndex)
41 : d(new ThumbnailRequestPrivate)
42{
43 d->url = url;
44 d->targetSize = targetSize;
45 d->mimeType = mimeType;
46 d->dpr = dpr;
47 d->sequenceIndex = sequenceIndex;
48}
49
51{
52 return d->url;
53}
54
56{
57 return d->targetSize;
58}
59
61{
62 return d->mimeType;
63}
64
66{
67 return d->dpr;
68}
69
71{
72 return d->sequenceIndex;
73}
74
75class ThumbnailResultPrivate
76{
77public:
78 QImage image;
79 float sequenceIndexWraparoundPoint = -1;
80};
81
82ThumbnailResult::ThumbnailResult()
83 : d(new ThumbnailResultPrivate)
84{
85}
86
87ThumbnailResult::~ThumbnailResult() = default;
88
89ThumbnailResult::ThumbnailResult(const ThumbnailResult &other)
90{
91 d = std::make_unique<ThumbnailResultPrivate>(*other.d);
92}
93
94ThumbnailResult &ThumbnailResult::operator=(const ThumbnailResult &other)
95{
96 ThumbnailResult temp(other);
97 std::swap(*d, *temp.d);
98 return *this;
99}
100
102{
103 ThumbnailResult response;
104 response.d->image = image;
105
106 return response;
107}
108
110{
111 ThumbnailResult response;
112 return response;
113}
114
116{
117 return d->sequenceIndexWraparoundPoint;
118}
119
121{
122 d->sequenceIndexWraparoundPoint = wraparoundPoint;
123}
124
126{
127 return d->image;
128}
129
131{
132 return !d->image.isNull();
133}
134
135ThumbnailCreator::ThumbnailCreator(QObject *parent, const QVariantList &args)
136 : QObject(parent)
137{
138 Q_UNUSED(args);
139}
140
141ThumbnailCreator::~ThumbnailCreator() = default;
142};
143
144#include "moc_thumbnailcreator.cpp"
ThumbnailRequest(const QUrl &url, const QSize &targetSize, const QString &mimeType, qreal dpr, float sequenceIndex)
Contruct a new ThumbnailRequest for a given file.
QString mimeType() const
The target file's MIME type.
QSize targetSize() const
The target thumbnail size.
qreal devicePixelRatio() const
The device Pixel Ratio used for thumbnail creation.
QUrl url() const
URL of the relevant file.
float sequenceIndex() const
If the thumb-creator can create a sequence of thumbnails, it should use this to decide what sequence ...
Encapsulates the output of a thumbnail request.
QImage image() const
The requested thumbnail.
static ThumbnailResult fail()
Create an error result, i.e.
float sequenceIndexWraparoundPoint() const
Returns the point at which this thumb-creator's sequence indices will wrap around (loop).
void setSequenceIndexWraparoundPoint(float wraparoundPoint)
Sets the point at which this thumb-creator's sequence indices will wrap around.
bool isValid() const
Whether the request was successful.
static ThumbnailResult pass(const QImage &image)
Create a successful result with a given image.
A namespace for KIO globals.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.