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        : 2011-05-23
0007  * Description : a tool to create panorama by fusion of several images.
0008  *
0009  * SPDX-FileCopyrightText: 2011-2016 by Benjamin Girault <benjamin dot girault at gmail dot com>
0010  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "panopreviewpage.h"
0017 
0018 // Qt includes
0019 
0020 #include <QLabel>
0021 #include <QMutex>
0022 #include <QTextDocument>
0023 #include <QStandardPaths>
0024 #include <QVBoxLayout>
0025 
0026 // KDE includes
0027 
0028 #include <klocalizedstring.h>
0029 
0030 // Local includes
0031 
0032 #include "digikam_debug.h"
0033 #include "dpreviewmanager.h"
0034 #include "dprogresswdg.h"
0035 #include "dhistoryview.h"
0036 #include "panomanager.h"
0037 #include "panoactionthread.h"
0038 #include "enblendbinary.h"
0039 #include "makebinary.h"
0040 #include "nonabinary.h"
0041 #include "pto2mkbinary.h"
0042 #include "huginexecutorbinary.h"
0043 #include "dlayoutbox.h"
0044 
0045 namespace DigikamGenericPanoramaPlugin
0046 {
0047 
0048 class Q_DECL_HIDDEN PanoPreviewPage::Private
0049 {
0050 public:
0051 
0052     explicit Private(PanoManager* const m)
0053       : title           (nullptr),
0054         previewWidget   (nullptr),
0055         previewBusy     (false),
0056         previewDone     (false),
0057         stitchingBusy   (false),
0058         stitchingDone   (false),
0059         postProcessing  (nullptr),
0060         progressBar     (nullptr),
0061         curProgress     (0),
0062         totalProgress   (0),
0063         canceled        (false),
0064         mngr            (m),
0065         dlg             (nullptr)
0066     {
0067     }
0068 
0069     QLabel*                title;
0070 
0071     DPreviewManager*       previewWidget;
0072     bool                   previewBusy;
0073     bool                   previewDone;
0074     bool                   stitchingBusy;
0075     bool                   stitchingDone;
0076     DHistoryView*          postProcessing;
0077     DProgressWdg*          progressBar;
0078     int                    curProgress;
0079     int                    totalProgress;
0080     QMutex                 previewBusyMutex;      ///< This is a precaution in case the user does a back / next action at the wrong moment
0081     bool                   canceled;
0082 
0083     QString                output;
0084 
0085     PanoManager*           mngr;
0086 
0087     QWizard*               dlg;
0088 };
0089 
0090 PanoPreviewPage::PanoPreviewPage(PanoManager* const mngr, QWizard* const dlg)
0091     : DWizardPage(dlg, i18nc("@title:window", "<b>Preview and Post-Processing</b>")),
0092       d(new Private(mngr))
0093 {
0094     d->dlg            = dlg;
0095 
0096     DVBox* const vbox = new DVBox(this);
0097 
0098     d->title          = new QLabel(vbox);
0099     d->title->setOpenExternalLinks(true);
0100     d->title->setWordWrap(true);
0101 
0102     d->previewWidget  = new DPreviewManager(vbox);
0103     d->previewWidget->setButtonText(i18nc("@action:button", "Details..."));
0104 
0105     d->postProcessing = new DHistoryView(vbox);
0106     d->progressBar    = new DProgressWdg(vbox);
0107 
0108     setPageWidget(vbox);
0109 
0110     QPixmap leftPix(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("digikam/data/assistant-hugin.png")));
0111     setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation));
0112 
0113     connect(d->progressBar, SIGNAL(signalProgressCanceled()),
0114             this, SLOT(slotCancel()));
0115 }
0116 
0117 PanoPreviewPage::~PanoPreviewPage()
0118 {
0119     delete d;
0120 }
0121 
0122 void PanoPreviewPage::computePreview()
0123 {
0124     // Cancel any stitching being processed
0125 
0126     if (d->stitchingBusy)
0127     {
0128         cleanupPage();
0129     }
0130 
0131     QMutexLocker lock(&d->previewBusyMutex);
0132 
0133     connect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0134             this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0135 
0136     connect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0137             this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0138 
0139     d->canceled = false;
0140 
0141     d->previewWidget->setBusy(true, i18n("Processing Panorama Preview..."));
0142     d->previewDone = false;
0143     d->previewBusy = true;
0144 
0145     d->mngr->resetPreviewPto();
0146     d->mngr->resetPreviewUrl();
0147     d->mngr->resetPreviewMkUrl();
0148     d->mngr->thread()->generatePanoramaPreview(d->mngr->viewAndCropOptimisePtoData(),
0149                                                d->mngr->previewPtoUrl(),
0150                                                d->mngr->previewMkUrl(),
0151                                                d->mngr->previewUrl(),
0152                                                d->mngr->preProcessedMap(),
0153                                                d->mngr->makeBinary().path(),
0154                                                d->mngr->pto2MkBinary().path(),
0155                                                d->mngr->huginExecutorBinary().path(),
0156                                                d->mngr->hugin2015(),
0157                                                d->mngr->enblendBinary().path(),
0158                                                d->mngr->nonaBinary().path());
0159 }
0160 
0161 void PanoPreviewPage::startStitching()
0162 {
0163     QMutexLocker lock(&d->previewBusyMutex);
0164 
0165     if (d->previewBusy)
0166     {
0167         // The real beginning of the stitching starts after preview has finished / failed
0168 
0169         connect(this, SIGNAL(signalPreviewFinished()), this, SLOT(slotStartStitching()));
0170         cleanupPage(lock);
0171 
0172         return;
0173     }
0174 
0175     connect(d->mngr->thread(), SIGNAL(starting(DigikamGenericPanoramaPlugin::PanoActionData)),
0176             this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0177 
0178     connect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0179             this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0180 
0181     connect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0182             this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0183 
0184     d->canceled      = false;
0185     d->stitchingBusy = true;
0186     d->curProgress   = 0;
0187 
0188     if (d->mngr->hugin2015())
0189     {
0190         d->totalProgress = 1;
0191     }
0192     else
0193     {
0194         d->totalProgress = d->mngr->preProcessedMap().size() + 1;
0195     }
0196 
0197     d->previewWidget->hide();
0198 
0199     QSize panoSize      = d->mngr->viewAndCropOptimisePtoData()->project.size;
0200     QRect panoSelection = d->mngr->viewAndCropOptimisePtoData()->project.crop;
0201 
0202     if (d->previewDone)
0203     {
0204         QSize previewSize = d->mngr->previewPtoData()->project.size;
0205         QRectF selection  = d->previewWidget->getSelectionArea();
0206         QRectF proportionSelection(selection.x()      / previewSize.width(),
0207                                    selection.y()      / previewSize.height(),
0208                                    selection.width()  / previewSize.width(),
0209                                    selection.height() / previewSize.height());
0210 
0211         // At this point, if no selection area was created, proportionSelection is null,
0212         // hence panoSelection becomes a null rectangle
0213 
0214         panoSelection     = QRect(proportionSelection.x()      * panoSize.width(),
0215                                   proportionSelection.y()      * panoSize.height(),
0216                                   proportionSelection.width()  * panoSize.width(),
0217                                   proportionSelection.height() * panoSize.height());
0218     }
0219 
0220     d->title->setText(i18n("<qt>"
0221                            "<p><h1>Panorama Post-Processing</h1></p>"
0222                            "</qt>"));
0223 
0224     d->progressBar->reset();
0225     d->progressBar->setMaximum(d->totalProgress);
0226     d->progressBar->progressScheduled(i18nc("@title:group", "Panorama Post-Processing"), true, true);
0227     d->progressBar->progressThumbnailChanged(QIcon::fromTheme(QLatin1String("panorama")).pixmap(22, 22));
0228     d->progressBar->show();
0229     d->postProcessing->show();
0230 
0231     d->mngr->resetPanoPto();
0232     d->mngr->resetMkUrl();
0233     d->mngr->resetPanoUrl();
0234     d->mngr->thread()->compileProject(d->mngr->viewAndCropOptimisePtoData(),
0235                                       d->mngr->panoPtoUrl(),
0236                                       d->mngr->mkUrl(),
0237                                       d->mngr->panoUrl(),
0238                                       d->mngr->preProcessedMap(),
0239                                       d->mngr->format(),
0240                                       panoSelection,
0241                                       d->mngr->makeBinary().path(),
0242                                       d->mngr->pto2MkBinary().path(),
0243                                       d->mngr->huginExecutorBinary().path(),
0244                                       d->mngr->hugin2015(),
0245                                       d->mngr->enblendBinary().path(),
0246                                       d->mngr->nonaBinary().path());
0247 }
0248 
0249 void PanoPreviewPage::preInitializePage()
0250 {
0251     d->title->setText(QString());
0252     d->previewWidget->show();
0253     d->progressBar->progressCompleted();
0254     d->progressBar->hide();
0255     d->postProcessing->hide();
0256 
0257     setComplete(true);
0258 
0259     Q_EMIT completeChanged();
0260 }
0261 
0262 void PanoPreviewPage::initializePage()
0263 {
0264     preInitializePage();
0265 
0266     computePreview();
0267 }
0268 
0269 bool PanoPreviewPage::validatePage()
0270 {
0271     if (d->stitchingDone)
0272     {
0273         return true;
0274     }
0275 
0276     setComplete(false);
0277     startStitching();
0278 
0279     return false;
0280 }
0281 
0282 void PanoPreviewPage::cleanupPage()
0283 {
0284     QMutexLocker lock(&d->previewBusyMutex);
0285     cleanupPage(lock);
0286 }
0287 
0288 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
0289 
0290 void PanoPreviewPage::cleanupPage(QMutexLocker<QMutex>& /*lock*/)
0291 
0292 #else
0293 
0294 void PanoPreviewPage::cleanupPage(QMutexLocker& /*lock*/)
0295 
0296 #endif
0297 
0298 {
0299     d->canceled = true;
0300 
0301     d->mngr->thread()->cancel();
0302     d->progressBar->progressCompleted();
0303 
0304     if      (d->previewBusy)
0305     {
0306         d->previewBusy = false;
0307         d->previewWidget->setBusy(false);
0308         d->previewWidget->setText(i18n("Preview Processing Cancelled."));
0309     }
0310     else if (d->stitchingBusy)
0311     {
0312         d->stitchingBusy = false;
0313     }
0314 }
0315 
0316 void PanoPreviewPage::slotCancel()
0317 {
0318     d->dlg->reject();
0319 }
0320 
0321 void PanoPreviewPage::slotStartStitching()
0322 {
0323     disconnect(this, SIGNAL(signalPreviewFinished()),
0324                this, SLOT(slotStartStitching()));
0325 
0326     startStitching();
0327 }
0328 
0329 void PanoPreviewPage::slotPanoAction(const DigikamGenericPanoramaPlugin::PanoActionData& ad)
0330 {
0331     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "SlotPanoAction (preview)";
0332     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "\tstarting, success, canceled, action: " << ad.starting << ad.success << d->canceled << ad.action;
0333 
0334     QString      text;
0335 
0336     QMutexLocker lock(&d->previewBusyMutex);
0337 
0338     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "\tbusy (preview / stitch):" << d->previewBusy << d->stitchingBusy;
0339 
0340     if (!ad.starting)           // Something is complete...
0341     {
0342         if (!ad.success)        // Something is failed...
0343         {
0344             switch (ad.action)
0345             {
0346                 case PANO_CREATEPREVIEWPTO:
0347                 case PANO_NONAFILEPREVIEW:
0348                 case PANO_STITCHPREVIEW:
0349                 case PANO_CREATEMKPREVIEW:
0350                 case PANO_HUGINEXECUTORPREVIEW:
0351                 {
0352                     if (!d->previewBusy)
0353                     {
0354                         lock.unlock();
0355                         Q_EMIT signalPreviewFinished();
0356                         return;
0357                     }
0358 
0359                     disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0360                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0361 
0362                     disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0363                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0364 
0365                     d->output      = ad.message;
0366                     d->previewWidget->setBusy(false);
0367                     d->previewBusy = false;
0368 
0369                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Preview compilation failed: " << ad.message;
0370                     QString errorString(i18n("<h1><b>Error</b></h1><p>%1</p>",
0371                                               ad.message));
0372                     d->previewWidget->setText(errorString);
0373                     d->previewWidget->setSelectionAreaPossible(false);
0374 
0375                     setComplete(false);
0376                     Q_EMIT completeChanged();
0377 
0378                     lock.unlock();
0379                     Q_EMIT signalPreviewFinished();
0380 
0381                     break;
0382                 }
0383 
0384                 case PANO_CREATEMK:
0385                 {
0386                     if (!d->stitchingBusy)
0387                     {
0388                         return;
0389                     }
0390 
0391                     disconnect(d->mngr->thread(), SIGNAL(starting(DigikamGenericPanoramaPlugin::PanoActionData)),
0392                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0393 
0394                     disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0395                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0396 
0397                     disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0398                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0399 
0400                     d->stitchingBusy = false;
0401                     QString message  = i18nc("Here a makefile is a script for GNU Make",
0402                                              "<p><b>Cannot create makefile: </b></p><p>%1</p>",
0403                                              ad.message);
0404                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "pto2mk call failed";
0405                     d->postProcessing->addEntry(message, DHistoryView::ErrorEntry);
0406 
0407                     setComplete(false);
0408                     Q_EMIT completeChanged();
0409 
0410                     break;
0411                 }
0412 
0413                 case PANO_CREATEFINALPTO:
0414                 {
0415                     if (!d->stitchingBusy)
0416                     {
0417                         return;
0418                     }
0419 
0420                     disconnect(d->mngr->thread(), SIGNAL(starting(DigikamGenericPanoramaPlugin::PanoActionData)),
0421                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0422 
0423                     disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0424                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0425 
0426                     disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0427                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0428 
0429                     d->stitchingBusy = false;
0430                     QString message  = i18nc("a project file is a .pto file, as given to hugin to build a panorama",
0431                                              "<p><b>Cannot create project file: </b></p><p>%1</p>",
0432                                              ad.message);
0433                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "pto creation failed";
0434                     d->postProcessing->addEntry(message, DHistoryView::ErrorEntry);
0435 
0436                     setComplete(false);
0437                     Q_EMIT completeChanged();
0438 
0439                     break;
0440                 }
0441 
0442                 case PANO_NONAFILE:
0443                 {
0444                     if (!d->stitchingBusy)
0445                     {
0446                         return;
0447                     }
0448 
0449                     disconnect(d->mngr->thread(), SIGNAL(starting(DigikamGenericPanoramaPlugin::PanoActionData)),
0450                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0451 
0452                     disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0453                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0454 
0455                     disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0456                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0457 
0458                     d->stitchingBusy = false;
0459                     QString message  = i18nc("Error message for image file number %1 out of %2",
0460                                              "<p><b>Processing file %1 / %2: </b></p><p>%3</p>",
0461                                              ad.id + 1,
0462                                              d->totalProgress - 1,
0463                                              ad.message);
0464                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Nona call failed for file #" << ad.id;
0465                     d->postProcessing->addEntry(message, DHistoryView::ErrorEntry);
0466 
0467                     setComplete(false);
0468                     Q_EMIT completeChanged();
0469 
0470                     break;
0471                 }
0472 
0473                 case PANO_STITCH:
0474                 case PANO_HUGINEXECUTOR:
0475                 {
0476                     if (!d->stitchingBusy)
0477                     {
0478                         return;
0479                     }
0480 
0481                     disconnect(d->mngr->thread(), SIGNAL(starting(DigikamGenericPanoramaPlugin::PanoActionData)),
0482                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0483 
0484                     disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0485                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0486 
0487                     disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0488                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0489 
0490                     d->stitchingBusy = false;
0491                     d->postProcessing->addEntry(i18nc("Error message for panorama compilation",
0492                                                          "<p><b>Panorama compilation: </b></p><p>%1</p>",
0493                                                          ad.message.toHtmlEscaped()), DHistoryView::ErrorEntry);
0494                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Enblend call failed";
0495 
0496                     setComplete(false);
0497                     Q_EMIT completeChanged();
0498 
0499                     break;
0500                 }
0501 
0502                 default:
0503                 {
0504                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action (preview) " << ad.action;
0505                     break;
0506                 }
0507             }
0508         }
0509         else                    // Something is done...
0510         {
0511             switch (ad.action)
0512             {
0513                 case PANO_CREATEPREVIEWPTO:
0514                 case PANO_CREATEMKPREVIEW:
0515                 case PANO_NONAFILEPREVIEW:
0516                 case PANO_CREATEFINALPTO:
0517                 case PANO_CREATEMK:
0518                 {
0519                     // Nothing to do yet, a step is finished, that's all
0520                     break;
0521                 }
0522 
0523                 case PANO_STITCHPREVIEW:
0524                 case PANO_HUGINEXECUTORPREVIEW:
0525                 {
0526                     if (d->previewBusy)
0527                     {
0528                         disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0529                                    this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0530 
0531                         disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0532                                    this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0533                     }
0534 
0535                     d->previewBusy = false;
0536                     d->previewDone = true;
0537 
0538                     lock.unlock();
0539                     Q_EMIT signalPreviewFinished();
0540 
0541                     d->title->setText(i18n("<qt>"
0542                                            "<h1>Panorama Preview</h1>"
0543                                            "<p>Draw a rectangle if you want to crop the image.</p>"
0544                                            "<p>Pressing the <i>Next</i> button will then launch the final "
0545                                            "stitching process.</p>"
0546                                            "</qt>"));
0547                     d->previewWidget->setSelectionAreaPossible(true);
0548 /*
0549                     d->previewWidget->load(QUrl::fromLocalFile(d->mngr->previewUrl().toLocalFile()), true);
0550 */
0551                     d->previewWidget->load(d->mngr->previewUrl(), true);
0552                     QSize panoSize    = d->mngr->viewAndCropOptimisePtoData()->project.size;
0553                     QRect panoCrop    = d->mngr->viewAndCropOptimisePtoData()->project.crop;
0554                     QSize previewSize = d->mngr->previewPtoData()->project.size;
0555                     d->previewWidget->setSelectionArea(QRectF(
0556                         ((double) panoCrop.left())   / panoSize.width()  * previewSize.width(),
0557                         ((double) panoCrop.top())    / panoSize.height() * previewSize.height(),
0558                         ((double) panoCrop.width())  / panoSize.width()  * previewSize.width(),
0559                         ((double) panoCrop.height()) / panoSize.height() * previewSize.height()
0560                     ));
0561 
0562                     break;
0563                 }
0564 
0565                 case PANO_NONAFILE:
0566                 {
0567                     QString message = i18nc("Success for image file number %1 out of %2",
0568                                             "Processing file %1 / %2",
0569                                             ad.id + 1,
0570                                             d->totalProgress - 1);
0571                     d->postProcessing->addEntry(message, DHistoryView::SuccessEntry);
0572                     d->curProgress++;
0573                     d->progressBar->setValue(d->curProgress);
0574                     d->progressBar->setMaximum(d->totalProgress);
0575 
0576                     break;
0577                 }
0578 
0579                 case PANO_STITCH:
0580                 case PANO_HUGINEXECUTOR:
0581                 {
0582                     if (!d->stitchingBusy)
0583                     {
0584                         return;
0585                     }
0586 
0587                     disconnect(d->mngr->thread(), SIGNAL(starting(DigikamGenericPanoramaPlugin::PanoActionData)),
0588                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0589 
0590                     disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0591                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0592 
0593                     disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)),
0594                                this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData)));
0595 
0596                     d->stitchingBusy = false;
0597                     d->postProcessing->addEntry(i18nc("Success for panorama compilation", "Panorama compilation"), DHistoryView::SuccessEntry);
0598                     d->curProgress++;
0599                     d->progressBar->setValue(d->curProgress);
0600                     d->progressBar->setMaximum(d->totalProgress);
0601                     d->progressBar->progressCompleted();
0602                     d->progressBar->hide();
0603                     d->postProcessing->hide();
0604                     d->stitchingDone = true;
0605 
0606                     Q_EMIT signalStitchingFinished();
0607                     preInitializePage();
0608 
0609                     break;
0610                 }
0611 
0612                 default:
0613                 {
0614                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action (preview) " << ad.action;
0615 
0616                     break;
0617                 }
0618             }
0619         }
0620     }
0621     else           // Some step is started...
0622     {
0623         switch (ad.action)
0624         {
0625             case PANO_CREATEPREVIEWPTO:
0626             case PANO_CREATEMKPREVIEW:
0627             case PANO_NONAFILEPREVIEW:
0628             case PANO_STITCHPREVIEW:
0629             case PANO_CREATEFINALPTO:
0630             case PANO_CREATEMK:
0631             case PANO_HUGINEXECUTORPREVIEW:
0632             {
0633                 // Nothing to do...
0634 
0635                 break;
0636             }
0637 
0638             case PANO_NONAFILE:
0639             {
0640                 QString message = i18nc("Compilation started for image file number %1 out of %2",
0641                                         "Processing file %1 / %2",
0642                                         ad.id + 1,
0643                                         d->totalProgress - 1);
0644                 d->postProcessing->addEntry(message, DHistoryView::StartingEntry);
0645 
0646                 break;
0647             }
0648 
0649             case PANO_STITCH:
0650             case PANO_HUGINEXECUTOR:
0651             {
0652                 lock.unlock();
0653                 d->postProcessing->addEntry(i18nc("Panorama compilation started", "Panorama compilation"), DHistoryView::StartingEntry);
0654 
0655                 break;
0656             }
0657 
0658             default:
0659             {
0660                 qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown starting action (preview) " << ad.action;
0661 
0662                 break;
0663             }
0664         }
0665     }
0666 }
0667 
0668 } // namespace DigikamGenericPanoramaPlugin
0669 
0670 #include "moc_panopreviewpage.cpp"