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; |
21 | QString mimeType; |
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>(args&: *other.d); |
31 | } |
32 | |
33 | ThumbnailRequest &ThumbnailRequest::operator=(const ThumbnailRequest &other) |
34 | { |
35 | ThumbnailRequest temp(other); |
36 | std::swap(a&: *d, b&: *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>(args&: *other.d); |
92 | } |
93 | |
94 | ThumbnailResult &ThumbnailResult::operator=(const ThumbnailResult &other) |
95 | { |
96 | ThumbnailResult temp(other); |
97 | std::swap(a&: *d, b&: *temp.d); |
98 | return *this; |
99 | } |
100 | |
101 | ThumbnailResult ThumbnailResult::pass(const QImage &image) |
102 | { |
103 | ThumbnailResult response; |
104 | response.d->image = image; |
105 | |
106 | return response; |
107 | } |
108 | |
109 | ThumbnailResult ThumbnailResult::fail() |
110 | { |
111 | ThumbnailResult response; |
112 | return response; |
113 | } |
114 | |
115 | float ThumbnailResult::sequenceIndexWraparoundPoint() const |
116 | { |
117 | return d->sequenceIndexWraparoundPoint; |
118 | } |
119 | |
120 | void ThumbnailResult::setSequenceIndexWraparoundPoint(float wraparoundPoint) |
121 | { |
122 | d->sequenceIndexWraparoundPoint = wraparoundPoint; |
123 | } |
124 | |
125 | QImage ThumbnailResult::image() const |
126 | { |
127 | return d->image; |
128 | } |
129 | |
130 | bool ThumbnailResult::isValid() const |
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" |
145 |