libQuotient
A Qt library for building matrix clients
mediathumbnailjob.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2018 Kitsune Ral <Kitsune-Ral@users.sf.net>
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 
4 #pragma once
5 
6 #include "basejob.h"
7 
8 #include <QtGui/QPixmap>
9 
10 namespace Quotient {
11 class QUOTIENT_API MediaThumbnailJob : public BaseJob {
12 public:
13  static QUrl makeRequestUrl(const HomeserverData& hsData, const QUrl& mxcUri,
14  QSize requestedSize, std::optional<bool> animated = std::nullopt);
15  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName,
16  const QString& mediaId, QSize requestedSize,
17  std::optional<bool> animated = std::nullopt);
18 
19  MediaThumbnailJob(QString serverName, QString mediaId, QSize requestedSize,
20  std::optional<bool> animated = std::nullopt);
21  MediaThumbnailJob(const QUrl& mxcUri, QSize requestedSize,
22  std::optional<bool> animated = std::nullopt);
23 
24  QImage thumbnail() const;
25  [[deprecated("Use thumbnail().scaled() instead")]]
26  QImage scaledThumbnail(QSize toSize) const;
27 
28 private:
29  QString serverName;
30  QString mediaId;
31  QSize requestedSize;
32  std::optional<bool> animated;
33  QImage _thumbnail;
34 
35  void doPrepare(const ConnectionData* connectionData) override;
36  Status prepareResult() override;
37 };
38 
39 inline auto collectResponse(const MediaThumbnailJob* j) { return j->thumbnail(); }
40 
41 } // namespace Quotient