1 | /* |
2 | This file is part of the KDE project. |
3 | SPDX-FileCopyrightText: 2001 Martin R. Jones <mjones@kde.org> |
4 | SPDX-FileCopyrightText: 2001 Carsten Pfeiffer <pfeiffer@kde.org> |
5 | SPDX-FileCopyrightText: 2008 Rafael Fernández López <ereslibre@kde.org> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.0-only |
8 | */ |
9 | |
10 | #ifndef KIMAGEFILEPREVIEW_H |
11 | #define KIMAGEFILEPREVIEW_H |
12 | |
13 | #include <QPixmap> |
14 | #include <QUrl> |
15 | #include <kpreviewwidgetbase.h> |
16 | |
17 | #include <memory> |
18 | |
19 | class KFileItem; |
20 | class KJob; |
21 | class KImageFilePreviewPrivate; |
22 | |
23 | namespace KIO |
24 | { |
25 | class PreviewJob; |
26 | } |
27 | |
28 | /*! |
29 | * \class KImageFilePreview |
30 | * \inmodule KIOFileWidgets |
31 | * |
32 | * \brief Image preview widget for the file dialog. |
33 | */ |
34 | class KIOFILEWIDGETS_EXPORT KImageFilePreview : public KPreviewWidgetBase |
35 | { |
36 | Q_OBJECT |
37 | |
38 | public: |
39 | /*! |
40 | * Creates a new image file preview. |
41 | * |
42 | * \a parent The parent widget. |
43 | */ |
44 | explicit KImageFilePreview(QWidget *parent = nullptr); |
45 | |
46 | ~KImageFilePreview() override; |
47 | |
48 | QSize sizeHint() const override; |
49 | |
50 | public Q_SLOTS: |
51 | /*! |
52 | * Shows a preview for the given \a url. |
53 | */ |
54 | void showPreview(const QUrl &url) override; |
55 | |
56 | /*! |
57 | * Clears the preview. |
58 | */ |
59 | void clearPreview() override; |
60 | |
61 | protected Q_SLOTS: |
62 | /*! |
63 | * |
64 | */ |
65 | void showPreview(); |
66 | |
67 | /*! |
68 | * |
69 | */ |
70 | void showPreview(const QUrl &url, bool force); |
71 | |
72 | /*! |
73 | * |
74 | */ |
75 | virtual void gotPreview(const KFileItem &, const QPixmap &); |
76 | |
77 | protected: |
78 | void resizeEvent(QResizeEvent *event) override; |
79 | |
80 | /*! |
81 | * |
82 | */ |
83 | virtual KIO::PreviewJob *createJob(const QUrl &url, int width, int height); |
84 | |
85 | private: |
86 | std::unique_ptr<KImageFilePreviewPrivate> const d; |
87 | |
88 | Q_DISABLE_COPY(KImageFilePreview) |
89 | }; |
90 | |
91 | #endif // KIMAGEFILEPREVIEW_H |
92 | |