File indexing completed on 2025-01-05 03:53:12

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-11-07
0007  * Description : a tool to print images
0008  *
0009  * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_ADV_PRINT_TASK_H
0016 #define DIGIKAM_ADV_PRINT_TASK_H
0017 
0018 // Qt includes
0019 
0020 #include <QString>
0021 #include <QStringList>
0022 #include <QPainter>
0023 #include <QList>
0024 #include <QRect>
0025 #include <QImage>
0026 
0027 // Local includes
0028 
0029 #include "advprintsettings.h"
0030 #include "actionthreadbase.h"
0031 
0032 using namespace Digikam;
0033 
0034 namespace DigikamGenericPrintCreatorPlugin
0035 {
0036 
0037 class AdvPrintTask : public ActionJob
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042 
0043     enum PrintMode
0044     {
0045         PREPAREPRINT = 0,
0046         PRINT,
0047         PREVIEW
0048     };
0049 
0050 public:
0051 
0052     explicit AdvPrintTask(AdvPrintSettings* const settings,
0053                           PrintMode mode,
0054                           const QSize& size = QSize(),        ///< For PREVIEW stage.
0055                           int sizeIndex = 0);                 ///< For PREPAREPRINT stage.
0056     ~AdvPrintTask()     override;
0057 
0058 Q_SIGNALS:
0059 
0060     void signalMessage(const QString&, bool);
0061     void signalDone(bool);
0062     void signalPreview(const QImage&);
0063 
0064 private:
0065 
0066     // Disable
0067     explicit AdvPrintTask(QObject*) = delete;
0068 
0069 private:
0070 
0071     void run()          override;
0072 
0073     void        preparePrint();
0074     void        printPhotos();
0075     QStringList printPhotosToFile();
0076 
0077     double getMaxDPI(const QList<AdvPrintPhoto*>& photos,
0078                      const QList<QRect*>& layouts,
0079                      int current);
0080 
0081     void printCaption(QPainter& p,
0082                       AdvPrintPhoto* const photo,
0083                       int captionW,
0084                       int captionH,
0085                       const QString& caption);
0086 
0087     bool paintOnePage(QPainter& p,
0088                       const QList<AdvPrintPhoto*>& photos,
0089                       const QList<QRect*>& layouts,
0090                       int& current,
0091                       bool cropDisabled,
0092                       bool useThumbnails = false);
0093 
0094 
0095 private:
0096 
0097     class Private;
0098     Private* const d;
0099 };
0100 
0101 } // namespace DigikamGenericPrintCreatorPlugin
0102 
0103 #endif // DIGIKAM_ADV_PRINT_TASK_H