1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2007-11-07 7 * Description : a tool to print images 8 * 9 * Copyright (C) 2017-2021 by Gilles Caulier <caulier dot gilles at gmail dot com> 10 * 11 * This program is free software; you can redistribute it 12 * and/or modify it under the terms of the GNU General 13 * Public License as published by the Free Software Foundation; 14 * either version 2, or (at your option) 15 * any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * ============================================================ */ 23 24 #ifndef DIGIKAM_ADV_PRINT_TASK_H 25 #define DIGIKAM_ADV_PRINT_TASK_H 26 27 // Qt includes 28 29 #include <QString> 30 #include <QStringList> 31 #include <QPainter> 32 #include <QList> 33 #include <QRect> 34 #include <QImage> 35 36 // Local includes 37 38 #include "advprintsettings.h" 39 #include "actionthreadbase.h" 40 41 using namespace Digikam; 42 43 namespace DigikamGenericPrintCreatorPlugin 44 { 45 46 class AdvPrintTask : public ActionJob 47 { 48 Q_OBJECT 49 50 public: 51 52 enum PrintMode 53 { 54 PREPAREPRINT = 0, 55 PRINT, 56 PREVIEW 57 }; 58 59 public: 60 61 explicit AdvPrintTask(AdvPrintSettings* const settings, 62 PrintMode mode, 63 const QSize& size = QSize(), ///< For PREVIEW stage. 64 int sizeIndex = 0); ///< For PREPAREPRINT stage. 65 ~AdvPrintTask() override; 66 67 Q_SIGNALS: 68 69 void signalMessage(const QString&, bool); 70 void signalDone(bool); 71 void signalPreview(const QImage&); 72 73 private: 74 75 // Disable 76 explicit AdvPrintTask(QObject*) = delete; 77 78 private: 79 80 void run() override; 81 82 void preparePrint(); 83 void printPhotos(); 84 QStringList printPhotosToFile(); 85 86 double getMaxDPI(const QList<AdvPrintPhoto*>& photos, 87 const QList<QRect*>& layouts, 88 int current); 89 90 void printCaption(QPainter& p, 91 AdvPrintPhoto* const photo, 92 int captionW, 93 int captionH, 94 const QString& caption); 95 96 bool paintOnePage(QPainter& p, 97 const QList<AdvPrintPhoto*>& photos, 98 const QList<QRect*>& layouts, 99 int& current, 100 bool cropDisabled, 101 bool useThumbnails = false); 102 103 104 private: 105 106 class Private; 107 Private* const d; 108 }; 109 110 } // namespace DigikamGenericPrintCreatorPlugin 111 112 #endif // DIGIKAM_ADV_PRINT_TASK_H 113