File indexing completed on 2025-01-26 04:15:00
0001 /* 0002 * Copyright (C) 2016 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef PDFCOVERIMAGEPROVIDER_H 0023 #define PDFCOVERIMAGEPROVIDER_H 0024 0025 #include <QQuickAsyncImageProvider> 0026 #include <QRunnable> 0027 0028 /** 0029 * \brief Get file previews of PDF files, where the thumbnailer isn't available... 0030 * 0031 * NOTE: As this task is potentially heavy, make sure to mark any Image using this provider asynchronous 0032 */ 0033 class PDFCoverImageProvider : public QQuickAsyncImageProvider 0034 { 0035 public: 0036 explicit PDFCoverImageProvider(); 0037 ~PDFCoverImageProvider() override; 0038 0039 /** 0040 * \brief Get an image. 0041 * 0042 * @param id The source of the image. 0043 * @param requestedSize The required size of the final image, unused. 0044 * 0045 * @return an asynchronous image response 0046 */ 0047 QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override; 0048 private: 0049 class Private; 0050 Private* d; 0051 }; 0052 0053 class QDir; 0054 /** 0055 * \brief A worker class which does the bulk of the work for PreviewImageProvider 0056 */ 0057 class PDFCoverRunnable : public QObject, public QRunnable { 0058 Q_OBJECT; 0059 public: 0060 PDFCoverRunnable(const QString &id, const QSize &requestedSize, const QDir& thumbDir); 0061 0062 void run() override; 0063 0064 /** 0065 * Request that the preview worker abort what it's doing 0066 */ 0067 Q_SLOT void abort(); 0068 0069 /** 0070 * \brief Emitted once the preview has been retrieved (successfully or not) 0071 * @param image The preview image in the requested size (possibly a placeholder) 0072 */ 0073 Q_SIGNAL void done(QImage image); 0074 private: 0075 class Private; 0076 Private* d; 0077 }; 0078 0079 #endif//PDFCOVERIMAGEPROVIDER_H