DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dthumbnailprovider.h
1// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DTKWIDGET_DFILETHUMBNAILPROVIDER_H
6#define DTKWIDGET_DFILETHUMBNAILPROVIDER_H
7
8#include <QThread>
9#include <QFileInfo>
10
11#include <dtkwidget_global.h>
12#include <DObject>
13
14#include <functional>
15
16#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
17
18QT_BEGIN_NAMESPACE
19class QMimeType;
20QT_END_NAMESPACE
21
22DWIDGET_BEGIN_NAMESPACE
23
24class DThumbnailProviderPrivate;
25class D_DECL_DEPRECATED_X("Use libdtkgui") DThumbnailProvider : public QThread, public DTK_CORE_NAMESPACE::DObject
26{
27 Q_OBJECT
28
29public:
30 enum Size {
31 Small = 64,
32 Normal = 128,
33 Large = 256,
34 };
35
36 static DThumbnailProvider *instance();
37
38 bool hasThumbnail(const QFileInfo &info) const;
39 bool hasThumbnail(const QMimeType &mimeType) const;
40
41 QString thumbnailFilePath(const QFileInfo &info, Size size) const;
42
43 QString createThumbnail(const QFileInfo &info, Size size);
44 typedef std::function<void(const QString &)> CallBack;
45 void appendToProduceQueue(const QFileInfo &info, Size size, CallBack callback = 0);
46 void removeInProduceQueue(const QFileInfo &info, Size size);
47
48 QString errorString() const;
49
50 qint64 defaultSizeLimit() const;
51 void setDefaultSizeLimit(qint64 size);
52
53 qint64 sizeLimit(const QMimeType &mimeType) const;
54 void setSizeLimit(const QMimeType &mimeType, qint64 size);
55
56Q_SIGNALS:
57 void thumbnailChanged(const QString &sourceFilePath, const QString &thumbnailPath) const;
58 void createThumbnailFinished(const QString &sourceFilePath, const QString &thumbnailPath) const;
59 void createThumbnailFailed(const QString &sourceFilePath) const;
60
61protected:
62 explicit DThumbnailProvider(QObject *parent = 0);
63 ~DThumbnailProvider();
64
65 void run() Q_DECL_OVERRIDE;
66
67private:
68 D_DECLARE_PRIVATE(DThumbnailProvider)
69};
70
71DWIDGET_END_NAMESPACE
72
73#endif // DTKWIDGET_DFILETHUMBNAILPROVIDER_H
74
75#endif