File indexing completed on 2025-03-09 03:50:50

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-12-13
0007  * Description : a tool to blend bracketed images.
0008  *
0009  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2015      by Benjamin Girault <benjamin dot girault at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "expoblendingdlg.h"
0017 
0018 // C ANSI includes
0019 
0020 extern "C"
0021 {
0022 #include <sys/types.h>
0023 #include <sys/stat.h>
0024 #ifndef Q_CC_MSVC
0025 #   include <unistd.h>
0026 #endif
0027 }
0028 
0029 // C++ includes
0030 
0031 #include <cstdio>
0032 
0033 // Qt includes
0034 
0035 #include <QPointer>
0036 #include <QCloseEvent>
0037 #include <QFile>
0038 #include <QDir>
0039 #include <QFileInfo>
0040 #include <QGridLayout>
0041 #include <QPushButton>
0042 #include <QScrollArea>
0043 #include <QApplication>
0044 #include <QMenu>
0045 #include <QMessageBox>
0046 #include <QGroupBox>
0047 #include <QWindow>
0048 
0049 // KDE includes
0050 
0051 #include <klocalizedstring.h>
0052 #include <ksharedconfig.h>
0053 #include <kconfiggroup.h>
0054 
0055 // Local includes
0056 
0057 #include "digikam_debug.h"
0058 #include "expoblendingthread.h"
0059 #include "bracketstack.h"
0060 #include "enfusebinary.h"
0061 #include "enfusesettings.h"
0062 #include "enfusestack.h"
0063 #include "dmessagebox.h"
0064 #include "dpreviewmanager.h"
0065 #include "dsavesettingswidget.h"
0066 #include "expoblendingmanager.h"
0067 #include "dfileoperations.h"
0068 #include "dxmlguiwindow.h"
0069 
0070 using namespace Digikam;
0071 
0072 namespace DigikamGenericExpoBlendingPlugin
0073 {
0074 
0075 class Q_DECL_HIDDEN ExpoBlendingDlg::Private
0076 {
0077 public:
0078 
0079     explicit Private()
0080       : templateFileName    (nullptr),
0081         previewWidget       (nullptr),
0082         enfuseSettingsBox   (nullptr),
0083         saveSettingsBox     (nullptr),
0084         bracketStack        (nullptr),
0085         enfuseStack         (nullptr),
0086         mngr                (nullptr),
0087         firstImageDisplayed (false),
0088         buttonBox           (nullptr),
0089         previewButton       (nullptr),
0090         startButton         (nullptr),
0091         propagateReject     (true)
0092     {
0093     }
0094 
0095     QString               inputFileName;
0096     QString               output;
0097 
0098     QLineEdit*            templateFileName;
0099 
0100     DPreviewManager*      previewWidget;
0101 
0102     EnfuseSettingsWidget* enfuseSettingsBox;
0103 
0104     DSaveSettingsWidget*  saveSettingsBox;
0105 
0106     BracketStackList*     bracketStack;
0107     EnfuseStackList*      enfuseStack;
0108 
0109     ExpoBlendingManager*  mngr;
0110 
0111     bool                  firstImageDisplayed;
0112 
0113     QDialogButtonBox*     buttonBox;
0114     QPushButton*          previewButton;
0115     QPushButton*          startButton;
0116 
0117     bool                  propagateReject;
0118 };
0119 
0120 ExpoBlendingDlg::ExpoBlendingDlg(ExpoBlendingManager* const mngr, QWidget* const parent)
0121     : QDialog(parent),
0122       d      (new Private)
0123 {
0124     d->mngr = mngr;
0125 
0126     setModal(false);
0127     setWindowTitle(i18nc("@title:window", "Exposure Blending"));
0128 
0129     const int spacing                = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0130                                             QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0131 
0132     d->buttonBox                     = new QDialogButtonBox(QDialogButtonBox::Close, this);
0133     d->buttonBox->button(QDialogButtonBox::Close)->setDefault(true);
0134 
0135     d->startButton                   = new QPushButton(this);
0136     d->startButton->setText(i18nc("@action:button", "&Save"));
0137     d->startButton->setIcon(QIcon::fromTheme(QLatin1String("document-save")));
0138     d->startButton->setToolTip(i18nc("@info:tooltip, button", "Process and save selected items."));
0139     d->buttonBox->addButton(d->startButton, QDialogButtonBox::ActionRole);
0140 
0141     d->previewButton                 = new QPushButton(this);
0142     d->previewButton->setText(i18nc("@action:button", "&Preview"));
0143     d->previewButton->setIcon(QIcon::fromTheme(QLatin1String("system-run")));
0144     d->previewButton->setToolTip(i18nc("@info:tooltip, button", "Process a preview of bracketed images stack with current settings."));
0145     d->buttonBox->addButton(d->previewButton, QDialogButtonBox::ActionRole);
0146 
0147     QPushButton* const defaultButton = new QPushButton(this);
0148     defaultButton->setText(i18nc("@action: button", "&Default"));
0149     defaultButton->setIcon(QIcon::fromTheme(QLatin1String("document-revert")));
0150     defaultButton->setToolTip(i18nc("@info:tooltip", "Revert current settings to default values."));
0151     d->buttonBox->addButton(defaultButton, QDialogButtonBox::ResetRole);
0152 
0153     // ---------------------------------------------------------------
0154 
0155     d->previewWidget                 = new DPreviewManager(this);
0156     d->previewWidget->setButtonText(i18nc("@action:button", "Details..."));
0157 
0158     // ---------------------------------------------------------------
0159 
0160     QScrollArea* const rightColumn   = new QScrollArea(this);
0161     QWidget* const rightPanel        = new QWidget(rightColumn->viewport());
0162     rightColumn->setWidget(rightPanel);
0163     rightColumn->setWidgetResizable(true);
0164     rightColumn->setFrameStyle(QFrame::NoFrame);
0165 
0166     QVBoxLayout* const panel         = new QVBoxLayout(rightPanel);
0167 
0168     d->bracketStack                  = new BracketStackList(rightPanel);
0169     panel->addWidget(d->bracketStack, 1);
0170 
0171     // ---------------------------------------------------------------
0172 
0173     QGroupBox* const enfuse          = new QGroupBox(rightPanel);
0174     enfuse->setTitle(i18nc("@title", "Enfuse Settings"));
0175     QVBoxLayout* const elay          = new QVBoxLayout(enfuse);
0176     enfuse->setLayout(elay);
0177 
0178     d->enfuseSettingsBox             = new EnfuseSettingsWidget(enfuse);
0179     elay->addWidget(d->enfuseSettingsBox);
0180 
0181     panel->addWidget(enfuse, 1);
0182 
0183     // ---------------------------------------------------------------
0184 
0185     QGroupBox* const save            = new QGroupBox(rightPanel);
0186     save->setTitle(i18nc("@title", "Save Result"));
0187     QVBoxLayout* const slay = new QVBoxLayout(save);
0188     save->setLayout(slay);
0189 
0190     d->saveSettingsBox               = new DSaveSettingsWidget(save);
0191     slay->addWidget(d->saveSettingsBox);
0192 
0193     QHBoxLayout* const hbox          = new QHBoxLayout(save);
0194 
0195     QLabel* const customLabel        = new QLabel(save);
0196     customLabel->setText(i18nc("@label: textbox", "File Name Template: "));
0197     hbox->addWidget(customLabel);
0198 
0199     d->templateFileName              = new QLineEdit(save);
0200     d->templateFileName->setClearButtonEnabled(true);
0201     hbox->addWidget(d->templateFileName);
0202 
0203     d->saveSettingsBox->setCustomSettingsWidget(d->saveSettingsBox);
0204     slay->addLayout(hbox);
0205 
0206     panel->addWidget(save, 1);
0207 
0208     // ---------------------------------------------------------------
0209 
0210     d->enfuseStack          = new EnfuseStackList(rightPanel);
0211     panel->addWidget(d->enfuseStack, 1);
0212 
0213     rightPanel->setLayout(panel);
0214     panel->setContentsMargins(QMargins());
0215 
0216     // ---------------------------------------------------------------
0217 
0218     QGridLayout* const grid = new QGridLayout(this);
0219     grid->addWidget(d->previewWidget, 0, 0, 3, 1);
0220     grid->addWidget(rightColumn,      0, 1, 3, 1);
0221     grid->addWidget(d->buttonBox,     4, 0, 1, 2);
0222     grid->setContentsMargins(spacing, spacing, spacing, spacing);
0223     grid->setSpacing(spacing);
0224     grid->setColumnStretch(0, 10);
0225     grid->setColumnStretch(1, 5);
0226     setLayout(grid);
0227 
0228     // ---------------------------------------------------------------
0229 
0230     connect(this, SIGNAL(finished(int)),
0231             this, SLOT(slotFinished()));
0232 
0233     connect(this, SIGNAL(cancelClicked()),
0234             this, SLOT(slotCancelClicked()));
0235 
0236     connect(defaultButton, SIGNAL(clicked()),
0237             this, SLOT(slotDefault()));
0238 
0239     connect(d->startButton, SIGNAL(clicked()),
0240             this, SLOT(slotProcess()));
0241 
0242     connect(d->previewButton, SIGNAL(clicked()),
0243             this, SLOT(slotPreview()));
0244 
0245     connect(d->buttonBox, &QDialogButtonBox::rejected,
0246             this, &ExpoBlendingDlg::slotCloseClicked);
0247 
0248     connect(d->mngr->thread(), SIGNAL(starting(DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData)),
0249             this, SLOT(slotExpoBlendingAction(DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData)));
0250 
0251     connect(d->mngr->thread(), SIGNAL(finished(DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData)),
0252             this, SLOT(slotExpoBlendingAction(DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData)));
0253 
0254     connect(d->bracketStack, SIGNAL(signalAddItems(QList<QUrl>)),
0255             this, SLOT(slotAddItems(QList<QUrl>)));
0256 
0257     connect(d->bracketStack, SIGNAL(signalItemClicked(QUrl)),
0258             this, SLOT(slotItemClicked(QUrl)));
0259 
0260     connect(d->previewWidget, SIGNAL(signalButtonClicked()),
0261             this, SLOT(slotPreviewButtonClicked()));
0262 
0263     connect(d->enfuseStack, SIGNAL(signalItemClicked(QUrl)),
0264             this, SLOT(slotLoadProcessed(QUrl)));
0265 
0266     connect(d->templateFileName, SIGNAL(textChanged(QString)),
0267             this, SLOT(slotFileFormatChanged()));
0268 
0269     connect(d->saveSettingsBox, SIGNAL(signalSaveFormatChanged()),
0270             this, SLOT(slotFileFormatChanged()));
0271 
0272     // ---------------------------------------------------------------
0273 
0274     busy(false);
0275     readSettings();
0276     loadItems(d->mngr->itemsList());
0277 }
0278 
0279 ExpoBlendingDlg::~ExpoBlendingDlg()
0280 {
0281     delete d;
0282 }
0283 
0284 void ExpoBlendingDlg::slotFinished()
0285 {
0286     d->mngr->thread()->cancel();
0287     d->mngr->cleanUp();
0288     saveSettings();
0289 }
0290 
0291 void ExpoBlendingDlg::closeEvent(QCloseEvent* e)
0292 {
0293     if (!e)
0294     {
0295         return;
0296     }
0297 
0298     slotFinished();
0299     e->accept();
0300 }
0301 
0302 void ExpoBlendingDlg::slotCancelClicked()
0303 {
0304     d->mngr->thread()->cancel();
0305 }
0306 
0307 void ExpoBlendingDlg::slotFileFormatChanged()
0308 {
0309     d->enfuseStack->setTemplateFileName(d->saveSettingsBox->fileFormat(), d->templateFileName->text());
0310 }
0311 
0312 void ExpoBlendingDlg::slotPreviewButtonClicked()
0313 {
0314     DMessageBox::showInformationList(QMessageBox::Information,
0315                                      qApp->activeWindow(),
0316                                      qApp->applicationName(),
0317                                      i18nc("@title:window", "Enfuse Processing Messages"),
0318                                      d->output.split(QLatin1Char('\n')));
0319 }
0320 
0321 void ExpoBlendingDlg::loadItems(const QList<QUrl>& urls)
0322 {
0323     d->bracketStack->clear();
0324     d->bracketStack->addItems(urls);
0325 }
0326 
0327 void ExpoBlendingDlg::slotAddItems(const QList<QUrl>& urls)
0328 {
0329     if (!urls.isEmpty())
0330     {
0331         d->mngr->thread()->identifyFiles(urls);
0332 
0333         if (!d->mngr->thread()->isRunning())
0334         {
0335             d->mngr->thread()->start();
0336         }
0337     }
0338 }
0339 
0340 void ExpoBlendingDlg::slotItemClicked(const QUrl& url)
0341 {
0342     QString fileName = url.fileName();
0343 
0344     if (fileName.isEmpty())
0345     {
0346         return;
0347     }
0348 
0349     int dot  = fileName.lastIndexOf(QLatin1Char('.'));
0350     fileName = fileName.left(dot);
0351 
0352     d->templateFileName->setText(fileName);
0353     slotFileFormatChanged();
0354 }
0355 
0356 void ExpoBlendingDlg::slotLoadProcessed(const QUrl& url)
0357 {
0358     d->mngr->thread()->loadProcessed(url);
0359 
0360     if (!d->mngr->thread()->isRunning())
0361     {
0362         d->mngr->thread()->start();
0363     }
0364 }
0365 
0366 void ExpoBlendingDlg::setIdentity(const QUrl& url, const QString& identity)
0367 {
0368     BracketStackItem* const item = d->bracketStack->findItem(url);
0369 
0370     if (item)
0371     {
0372         item->setExposure(identity);
0373     }
0374 }
0375 
0376 void ExpoBlendingDlg::busy(bool val)
0377 {
0378     d->enfuseSettingsBox->setEnabled(!val);
0379     d->saveSettingsBox->setEnabled(!val);
0380     d->bracketStack->setEnabled(!val);
0381 
0382     d->startButton->setEnabled(!val ? !d->enfuseStack->settingsList().isEmpty() : false);
0383     d->previewButton->setEnabled(!val);
0384     setRejectButtonMode(val ? QDialogButtonBox::Cancel : QDialogButtonBox::Close);
0385 
0386     if (val)
0387     {
0388         d->previewWidget->setButtonVisible(false);
0389     }
0390 }
0391 
0392 void ExpoBlendingDlg::slotDefault()
0393 {
0394     d->enfuseSettingsBox->resetToDefault();
0395     d->saveSettingsBox->resetToDefault();
0396     d->templateFileName->setText(QLatin1String("enfuse"));
0397 }
0398 
0399 void ExpoBlendingDlg::readSettings()
0400 {
0401     KSharedConfigPtr config = KSharedConfig::openConfig();
0402     KConfigGroup group      = config->group(QLatin1String("ExpoBlending Settings"));
0403 
0404     d->enfuseSettingsBox->readSettings(group);
0405     d->saveSettingsBox->readSettings(group);
0406 
0407     d->templateFileName->setText(group.readEntry("Template File Name", QString::fromLatin1("enfuse")));
0408 
0409     winId();
0410     KConfigGroup group2 = config->group(QLatin1String("ExpoBlending Dialog"));
0411     DXmlGuiWindow::restoreWindowSize(windowHandle(), group2);
0412     resize(windowHandle()->size());
0413 }
0414 
0415 void ExpoBlendingDlg::saveSettings()
0416 {
0417     KSharedConfigPtr config = KSharedConfig::openConfig();
0418     KConfigGroup group      = config->group(QLatin1String("ExpoBlending Settings"));
0419 
0420     d->enfuseSettingsBox->writeSettings(group);
0421     d->saveSettingsBox->writeSettings(group);
0422 
0423     group.writeEntry("Template File Name", d->templateFileName->text());
0424 
0425     KConfigGroup group2 = config->group(QLatin1String("ExpoBlending Dialog"));
0426     DXmlGuiWindow::saveWindowSize(windowHandle(), group2);
0427     config->sync();
0428 }
0429 
0430 void ExpoBlendingDlg::slotPreview()
0431 {
0432     QList<QUrl> selectedUrl = d->bracketStack->urls();
0433 
0434     if (selectedUrl.isEmpty())
0435     {
0436         return;
0437     }
0438 
0439     ExpoBlendingItemUrlsMap map = d->mngr->preProcessedMap();
0440     QList<QUrl> preprocessedList;
0441 
0442     Q_FOREACH (const QUrl& url, selectedUrl)
0443     {
0444         ExpoBlendingItemPreprocessedUrls preprocessedUrls = map.value(url);
0445         preprocessedList.append(preprocessedUrls.previewUrl);
0446     }
0447 
0448     EnfuseSettings settings = d->enfuseSettingsBox->settings();
0449     settings.inputUrls      = d->bracketStack->urls();
0450     settings.outputFormat   = d->saveSettingsBox->fileFormat();
0451     d->mngr->thread()->enfusePreview(preprocessedList, d->mngr->itemsList()[0], settings, d->mngr->enfuseBinary().path());
0452 
0453     if (!d->mngr->thread()->isRunning())
0454     {
0455         d->mngr->thread()->start();
0456     }
0457 }
0458 
0459 void ExpoBlendingDlg::slotProcess()
0460 {
0461     QList<EnfuseSettings> list = d->enfuseStack->settingsList();
0462 
0463     if (list.isEmpty())
0464     {
0465         return;
0466     }
0467 
0468     ExpoBlendingItemUrlsMap map = d->mngr->preProcessedMap();
0469     QList<QUrl> preprocessedList;
0470 
0471     Q_FOREACH (const EnfuseSettings& settings, list)
0472     {
0473         preprocessedList.clear();
0474 
0475         Q_FOREACH (const QUrl& url, settings.inputUrls)
0476         {
0477             ExpoBlendingItemPreprocessedUrls preprocessedUrls = map.value(url);
0478             preprocessedList.append(preprocessedUrls.preprocessedUrl);
0479         }
0480 
0481         d->mngr->thread()->enfuseFinal(preprocessedList, d->mngr->itemsList()[0], settings, d->mngr->enfuseBinary().path());
0482 
0483         if (!d->mngr->thread()->isRunning())
0484         {
0485             d->mngr->thread()->start();
0486         }
0487     }
0488 }
0489 
0490 void ExpoBlendingDlg::saveItem(const QUrl& temp, const EnfuseSettings& settings)
0491 {
0492     QUrl newUrl = QUrl::fromLocalFile(temp.adjusted(QUrl::RemoveFilename).toLocalFile() + settings.targetFileName);
0493 
0494     if (d->saveSettingsBox->conflictRule() != FileSaveConflictBox::OVERWRITE)
0495     {
0496         newUrl = DFileOperations::getUniqueFileUrl(newUrl);
0497     }
0498 
0499     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Renaming " << temp << " to " << newUrl;
0500 
0501     if (!newUrl.isEmpty())
0502     {
0503         // remove newUrl file if it exist
0504 
0505         if (temp.toLocalFile() != newUrl.toLocalFile() && QFile::exists(temp.toLocalFile()) && QFile::exists(newUrl.toLocalFile()))
0506         {
0507             QFile::remove(newUrl.toLocalFile());
0508         }
0509 
0510         if (!QFile::rename(temp.toLocalFile(), newUrl.toLocalFile()))
0511         {
0512             QMessageBox::critical(this, QString(), i18nc("@info", "Failed to save image to %1.", QDir::toNativeSeparators(newUrl.toLocalFile())));
0513             d->enfuseStack->setOnItem(settings.previewUrl, false);
0514             d->enfuseStack->processedItem(settings.previewUrl, false);
0515             return;
0516         }
0517         else
0518         {
0519             d->enfuseStack->removeItem(settings.previewUrl);
0520         }
0521     }
0522 
0523     if (d->enfuseStack->settingsList().isEmpty())
0524     {
0525         d->startButton->setEnabled(false);
0526         busy(false);
0527         d->previewWidget->setBusy(false);
0528     }
0529 
0530     Q_EMIT d->mngr->updateHostApp(newUrl);
0531 }
0532 
0533 void ExpoBlendingDlg::slotExpoBlendingAction(const DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData& ad)
0534 {
0535     QString text;
0536 
0537     if (ad.starting)            // Something have been started...
0538     {
0539         switch (ad.action)
0540         {
0541             case EXPOBLENDING_IDENTIFY:
0542             {
0543                 break;
0544             }
0545 
0546             case EXPOBLENDING_LOAD:
0547             {
0548                 busy(true);
0549                 break;
0550             }
0551 
0552             case EXPOBLENDING_ENFUSEPREVIEW:
0553             {
0554                 busy(true);
0555                 d->previewWidget->setBusy(true, i18nc("@info", "Processing preview of bracketed images..."));
0556                 break;
0557             }
0558 
0559             case EXPOBLENDING_ENFUSEFINAL:
0560             {
0561                 busy(true);
0562                 d->previewWidget->setBusy(true, i18nc("@info", "Processing output of bracketed images..."));
0563                 d->enfuseStack->processingItem(ad.enfuseSettings.previewUrl, true);
0564                 break;
0565             }
0566 
0567             default:
0568             {
0569                 qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action";
0570                 break;
0571             }
0572         }
0573     }
0574     else
0575     {
0576         if (!ad.success)        // Something is failed...
0577         {
0578             switch (ad.action)
0579             {
0580                 case EXPOBLENDING_IDENTIFY:
0581                 {
0582                     setIdentity(ad.inUrls[0], ad.message);
0583                     busy(false);
0584                     break;
0585                 }
0586 
0587                 case EXPOBLENDING_LOAD:
0588                 {
0589                     d->previewWidget->setText(i18nc("@info", "Failed to load processed image."), Qt::red);
0590                     busy(false);
0591                     break;
0592                 }
0593 
0594                 case EXPOBLENDING_ENFUSEPREVIEW:
0595                 {
0596                     d->output = ad.message;
0597                     d->previewWidget->setBusy(false);
0598                     d->previewWidget->setButtonVisible(true);
0599                     d->previewWidget->setText(i18nc("@info", "Failed to process preview of bracketed images."), Qt::red);
0600                     busy(false);
0601                     break;
0602                 }
0603 
0604                 case EXPOBLENDING_ENFUSEFINAL:
0605                 {
0606                     slotCancelClicked();
0607                     d->output = ad.message;
0608                     d->previewWidget->setBusy(false);
0609                     d->previewWidget->setButtonVisible(true);
0610                     d->previewWidget->setText(i18nc("@info", "Failed to process output of bracketed images."), Qt::red);
0611                     d->enfuseStack->processingItem(ad.enfuseSettings.previewUrl, false);
0612                     d->enfuseStack->setOnItem(ad.enfuseSettings.previewUrl, false);
0613                     busy(false);
0614                     break;
0615                 }
0616 
0617                 default:
0618                 {
0619                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action";
0620                     break;
0621                 }
0622             }
0623         }
0624         else                    // Something is done...
0625         {
0626             switch (ad.action)
0627             {
0628                 case EXPOBLENDING_IDENTIFY:
0629                 {
0630                     setIdentity(ad.inUrls[0], ad.message);
0631                     busy(false);
0632                     break;
0633                 }
0634 
0635                 case EXPOBLENDING_LOAD:
0636                 {
0637                     d->previewWidget->setImage(ad.image, !d->firstImageDisplayed);
0638                     d->firstImageDisplayed |= true;
0639                     d->enfuseStack->setThumbnail(ad.inUrls[0], ad.image);
0640                     busy(false);
0641                     break;
0642                 }
0643 
0644                 case EXPOBLENDING_ENFUSEPREVIEW:
0645                 {
0646                     d->enfuseStack->addItem(ad.outUrls[0], ad.enfuseSettings);
0647                     busy(false);
0648                     break;
0649                 }
0650 
0651                 case EXPOBLENDING_ENFUSEFINAL:
0652                 {
0653                     d->enfuseStack->processingItem(ad.enfuseSettings.previewUrl, false);
0654                     saveItem(ad.outUrls[0], ad.enfuseSettings);
0655                     break;
0656                 }
0657 
0658                 default:
0659                 {
0660                     qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action";
0661                     break;
0662                 }
0663             }
0664         }
0665     }
0666 }
0667 
0668 void ExpoBlendingDlg::setRejectButtonMode(QDialogButtonBox::StandardButton button)
0669 {
0670     if      (button == QDialogButtonBox::Close)
0671     {
0672         d->buttonBox->button(QDialogButtonBox::Close)->setText(i18nc("@action", "Close"));
0673         d->buttonBox->button(QDialogButtonBox::Close)->setIcon(QIcon::fromTheme(QLatin1String("window-close")));
0674         d->buttonBox->button(QDialogButtonBox::Close)->setToolTip(i18nc("@info", "Close window"));
0675         d->propagateReject = true;
0676     }
0677     else if (button == QDialogButtonBox::Cancel)
0678     {
0679         d->buttonBox->button(QDialogButtonBox::Close)->setText(i18nc("@action", "Cancel"));
0680         d->buttonBox->button(QDialogButtonBox::Close)->setIcon(QIcon::fromTheme(QLatin1String("dialog-cancel")));
0681         d->buttonBox->button(QDialogButtonBox::Close)->setToolTip(i18nc("@info", "Cancel current operation"));
0682         d->propagateReject = false;
0683     }
0684     else
0685     {
0686         qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unexpected button mode passed";
0687     }
0688 }
0689 
0690 void ExpoBlendingDlg::slotCloseClicked()
0691 {
0692     if (d->propagateReject)
0693     {
0694         reject();
0695     }
0696     else
0697     {
0698         Q_EMIT cancelClicked();
0699     }
0700 }
0701 
0702 } // namespace DigikamGenericExpoBlendingPlugin
0703 
0704 #include "moc_expoblendingdlg.cpp"