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 #include "advprintthread.h"
0016 
0017 // Local includes
0018 
0019 #include "digikam_debug.h"
0020 #include "digikam_config.h"
0021 
0022 namespace DigikamGenericPrintCreatorPlugin
0023 {
0024 
0025 AdvPrintThread::AdvPrintThread(QObject* const parent)
0026     : ActionThreadBase(parent)
0027 {
0028     setObjectName(QLatin1String("AdvPrintThread"));
0029 }
0030 
0031 AdvPrintThread::~AdvPrintThread()
0032 {
0033     cancel();
0034     wait();
0035 }
0036 
0037 void AdvPrintThread::preparePrint(AdvPrintSettings* const settings, int sizeIndex)
0038 {
0039     ActionJobCollection collection;
0040 
0041     AdvPrintTask* const t = new AdvPrintTask(settings,
0042                                              AdvPrintTask::PREPAREPRINT,
0043                                              QSize(),
0044                                              sizeIndex);
0045 
0046     connect(t, SIGNAL(signalProgress(int)),
0047             this, SIGNAL(signalProgress(int)));
0048 
0049     connect(t, SIGNAL(signalDone(bool)),
0050             this, SIGNAL(signalDone(bool)));
0051 
0052     connect(t, SIGNAL(signalMessage(QString,bool)),
0053             this, SIGNAL(signalMessage(QString,bool)));
0054 
0055     collection.insert(t, 0);
0056 
0057     appendJobs(collection);
0058 }
0059 
0060 void AdvPrintThread::print(AdvPrintSettings* const settings)
0061 {
0062     ActionJobCollection collection;
0063 
0064     AdvPrintTask* const t = new AdvPrintTask(settings,
0065                                              AdvPrintTask::PRINT);
0066 
0067     connect(t, SIGNAL(signalProgress(int)),
0068             this, SIGNAL(signalProgress(int)));
0069 
0070     connect(t, SIGNAL(signalDone(bool)),
0071             this, SIGNAL(signalDone(bool)));
0072 
0073     connect(t, SIGNAL(signalMessage(QString,bool)),
0074             this, SIGNAL(signalMessage(QString,bool)));
0075 
0076     collection.insert(t, 0);
0077 
0078     appendJobs(collection);
0079 }
0080 
0081 void AdvPrintThread::preview(AdvPrintSettings* const settings, const QSize& size)
0082 {
0083     ActionJobCollection collection;
0084 
0085     AdvPrintTask* const t = new AdvPrintTask(settings,
0086                                              AdvPrintTask::PREVIEW,
0087                                              size);
0088 
0089     connect(t, SIGNAL(signalProgress(int)),
0090             this, SIGNAL(signalProgress(int)));
0091 
0092     connect(t, SIGNAL(signalDone(bool)),
0093             this, SIGNAL(signalDone(bool)));
0094 
0095     connect(t, SIGNAL(signalMessage(QString,bool)),
0096             this, SIGNAL(signalMessage(QString,bool)));
0097 
0098     connect(t, SIGNAL(signalPreview(QImage)),
0099             this, SIGNAL(signalPreview(QImage)));
0100 
0101     collection.insert(t, 0);
0102 
0103     appendJobs(collection);
0104 }
0105 
0106 } // namespace DigikamGenericPrintCreatorPlugin
0107 
0108 #include "moc_advprintthread.cpp"