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
19class KFileItem;
20class KJob;
21class KImageFilePreviewPrivate;
22
23namespace KIO
24{
25class PreviewJob;
26}
27
28/**
29 * @class KImageFilePreview kimagefilepreview.h <KImageFilePreview>
30 *
31 * Image preview widget for the file dialog.
32 */
33class KIOFILEWIDGETS_EXPORT KImageFilePreview : public KPreviewWidgetBase
34{
35 Q_OBJECT
36
37public:
38 /**
39 * Creates a new image file preview.
40 *
41 * @param parent The parent widget.
42 */
43 explicit KImageFilePreview(QWidget *parent = nullptr);
44
45 /**
46 * Destroys the image file preview.
47 */
48 ~KImageFilePreview() override;
49
50 /**
51 * Returns the size hint for this widget.
52 */
53 QSize sizeHint() const override;
54
55public Q_SLOTS:
56 /**
57 * Shows a preview for the given @p url.
58 */
59 void showPreview(const QUrl &url) override;
60
61 /**
62 * Clears the preview.
63 */
64 void clearPreview() override;
65
66protected Q_SLOTS:
67 void showPreview();
68 void showPreview(const QUrl &url, bool force);
69
70 virtual void gotPreview(const KFileItem &, const QPixmap &);
71
72protected:
73 void resizeEvent(QResizeEvent *event) override;
74 virtual KIO::PreviewJob *createJob(const QUrl &url, int width, int height);
75
76private:
77 std::unique_ptr<KImageFilePreviewPrivate> const d;
78
79 Q_DISABLE_COPY(KImageFilePreview)
80};
81
82#endif // KIMAGEFILEPREVIEW_H
83

source code of kio/src/filewidgets/kimagefilepreview.h