File indexing completed on 2024-04-21 03:55:23

0001 /*
0002     This file is part of the KDE project.
0003     SPDX-FileCopyrightText: 2001 Martin R. Jones <mjones@kde.org>
0004     SPDX-FileCopyrightText: 2001 Carsten Pfeiffer <pfeiffer@kde.org>
0005     SPDX-FileCopyrightText: 2008 Rafael Fernández López <ereslibre@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #ifndef KIMAGEFILEPREVIEW_H
0011 #define KIMAGEFILEPREVIEW_H
0012 
0013 #include <QPixmap>
0014 #include <QUrl>
0015 #include <kpreviewwidgetbase.h>
0016 
0017 #include <memory>
0018 
0019 class KFileItem;
0020 class KJob;
0021 class KImageFilePreviewPrivate;
0022 
0023 namespace KIO
0024 {
0025 class PreviewJob;
0026 }
0027 
0028 /**
0029  * @class KImageFilePreview kimagefilepreview.h <KImageFilePreview>
0030  *
0031  * Image preview widget for the file dialog.
0032  */
0033 class KIOFILEWIDGETS_EXPORT KImageFilePreview : public KPreviewWidgetBase
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     /**
0039      * Creates a new image file preview.
0040      *
0041      * @param parent The parent widget.
0042      */
0043     explicit KImageFilePreview(QWidget *parent = nullptr);
0044 
0045     /**
0046      * Destroys the image file preview.
0047      */
0048     ~KImageFilePreview() override;
0049 
0050     /**
0051      * Returns the size hint for this widget.
0052      */
0053     QSize sizeHint() const override;
0054 
0055 public Q_SLOTS:
0056     /**
0057      * Shows a preview for the given @p url.
0058      */
0059     void showPreview(const QUrl &url) override;
0060 
0061     /**
0062      * Clears the preview.
0063      */
0064     void clearPreview() override;
0065 
0066 protected Q_SLOTS:
0067     void showPreview();
0068     void showPreview(const QUrl &url, bool force);
0069 
0070     virtual void gotPreview(const KFileItem &, const QPixmap &);
0071 
0072 protected:
0073     void resizeEvent(QResizeEvent *event) override;
0074     virtual KIO::PreviewJob *createJob(const QUrl &url, int width, int height);
0075 
0076 private:
0077     std::unique_ptr<KImageFilePreviewPrivate> const d;
0078 
0079     Q_DISABLE_COPY(KImageFilePreview)
0080 };
0081 
0082 #endif // KIMAGEFILEPREVIEW_H