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 
13 namespace KIO
14 {
15 
16 class ThumbnailRequestPrivate
17 {
18 public:
19  QUrl url;
20  QSize targetSize;
22  qreal dpr;
23  float sequenceIndex;
24 };
25 
26 ThumbnailRequest::~ThumbnailRequest() = default;
27 
28 ThumbnailRequest::ThumbnailRequest(const ThumbnailRequest &other)
29 {
30  d = std::make_unique<ThumbnailRequestPrivate>(*other.d);
31 }
32 
33 ThumbnailRequest &ThumbnailRequest::operator=(const ThumbnailRequest &other)
34 {
35  ThumbnailRequest temp(other);
36  std::swap(*d, *temp.d);
37  return *this;
38 }
39 
40 ThumbnailRequest::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 
50 QUrl ThumbnailRequest::url() const
51 {
52  return d->url;
53 }
54 
55 QSize ThumbnailRequest::targetSize() const
56 {
57  return d->targetSize;
58 }
59 
60 QString ThumbnailRequest::mimeType() const
61 {
62  return d->mimeType;
63 }
64 
65 qreal ThumbnailRequest::devicePixelRatio() const
66 {
67  return d->dpr;
68 }
69 
70 float ThumbnailRequest::sequenceIndex() const
71 {
72  return d->sequenceIndex;
73 }
74 
75 class ThumbnailResultPrivate
76 {
77 public:
78  QImage image;
79  float sequenceIndexWraparoundPoint = -1;
80 };
81 
82 ThumbnailResult::ThumbnailResult()
83  : d(new ThumbnailResultPrivate)
84 {
85 }
86 
87 ThumbnailResult::~ThumbnailResult() = default;
88 
89 ThumbnailResult::ThumbnailResult(const ThumbnailResult &other)
90 {
91  d = std::make_unique<ThumbnailResultPrivate>(*other.d);
92 }
93 
94 ThumbnailResult &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 
135 ThumbnailCreator::ThumbnailCreator(QObject *parent, const QVariantList &args)
136  : QObject(parent)
137 {
138  Q_UNUSED(args);
139 }
140 
141 ThumbnailCreator::~ThumbnailCreator() = default;
142 };
143 
144 #include "moc_thumbnailcreator.cpp"
QImage image() const
The requested thumbnail.
float sequenceIndexWraparoundPoint() const
Returns the point at which this thumb-creator's sequence indices will wrap around (loop).
QString url(QUrl::FormattingOptions options) const const
KCALUTILS_EXPORT QString mimeType()
const QUrl & url() const
Returns the SimpleJob's URL.
Definition: simplejob.cpp:70
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.
Encapsulates the output of a thumbnail request.
A namespace for KIO globals.
static ThumbnailResult pass(const QImage &image)
Create a successful result with a given image.
static ThumbnailResult fail()
Create an error result, i.e.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:51:27 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.