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>(args&: *other.d);
31}
32
33ThumbnailRequest &ThumbnailRequest::operator=(const ThumbnailRequest &other)
34{
35 ThumbnailRequest temp(other);
36 std::swap(a&: *d, b&: *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
50QUrl ThumbnailRequest::url() const
51{
52 return d->url;
53}
54
55QSize ThumbnailRequest::targetSize() const
56{
57 return d->targetSize;
58}
59
60QString ThumbnailRequest::mimeType() const
61{
62 return d->mimeType;
63}
64
65qreal ThumbnailRequest::devicePixelRatio() const
66{
67 return d->dpr;
68}
69
70float ThumbnailRequest::sequenceIndex() const
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>(args&: *other.d);
92}
93
94ThumbnailResult &ThumbnailResult::operator=(const ThumbnailResult &other)
95{
96 ThumbnailResult temp(other);
97 std::swap(a&: *d, b&: *temp.d);
98 return *this;
99}
100
101ThumbnailResult ThumbnailResult::pass(const QImage &image)
102{
103 ThumbnailResult response;
104 response.d->image = image;
105
106 return response;
107}
108
109ThumbnailResult ThumbnailResult::fail()
110{
111 ThumbnailResult response;
112 return response;
113}
114
115float ThumbnailResult::sequenceIndexWraparoundPoint() const
116{
117 return d->sequenceIndexWraparoundPoint;
118}
119
120void ThumbnailResult::setSequenceIndexWraparoundPoint(float wraparoundPoint)
121{
122 d->sequenceIndexWraparoundPoint = wraparoundPoint;
123}
124
125QImage ThumbnailResult::image() const
126{
127 return d->image;
128}
129
130bool ThumbnailResult::isValid() const
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"
145

source code of kio/src/gui/thumbnailcreator.cpp