| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2006-04-04 |
| 7 |
* Description : a tool to generate jAlbum image galleries |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk> |
| 10 |
* |
| 11 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 12 |
* |
| 13 |
* ============================================================ */ |
| 14 |
|
| 15 |
#include "jalbumfinalpage.h" |
| 16 |
|
| 17 |
// Qt includes |
| 18 |
|
| 19 |
#include <QIcon> |
| 20 |
#include <QSpacerItem> |
| 21 |
#include <QVBoxLayout> |
| 22 |
#include <QDesktopServices> |
| 23 |
#include <QUrl> |
| 24 |
#include <QApplication> |
| 25 |
#include <QStyle> |
| 26 |
#include <QTimer> |
| 27 |
#include <QDir> |
| 28 |
|
| 29 |
// KDE includes |
| 30 |
|
| 31 |
#include <klocalizedstring.h> |
| 32 |
|
| 33 |
// Local includes |
| 34 |
|
| 35 |
#include "digikam_globals.h" |
| 36 |
#include "jalbumwizard.h" |
| 37 |
#include "jalbumsettings.h" |
| 38 |
#include "jalbumgenerator.h" |
| 39 |
#include "dlayoutbox.h" |
| 40 |
#include "digikam_debug.h" |
| 41 |
#include "dprogresswdg.h" |
| 42 |
#include "dhistoryview.h" |
| 43 |
#include "webbrowserdlg.h" |
| 44 |
|
| 45 |
namespace DigikamGenericJAlbumPlugin |
| 46 |
{ |
| 47 |
|
| 48 |
class Q_DECL_HIDDEN JAlbumFinalPage::Private |
| 49 |
{ |
| 50 |
public: |
| 51 |
|
| 52 |
Private() = default; |
| 53 |
|
| 54 |
public: |
| 55 |
|
| 56 |
DHistoryView* progressView = nullptr; |
| 57 |
DProgressWdg* progressBar = nullptr; |
| 58 |
bool complete = false; |
| 59 |
}; |
| 60 |
|
| 61 |
JAlbumFinalPage::JAlbumFinalPage(QWizard* const dialog, const QString& title) |
| 62 |
: DWizardPage(dialog, title), |
| 63 |
d (new Private) |
| 64 |
{ |
| 65 |
setObjectName(QLatin1String("FinalPage")); |
| 66 |
|
| 67 |
DVBox* const vbox = new DVBox(this); |
| 68 |
d->progressView = new DHistoryView(vbox); |
| 69 |
d->progressBar = new DProgressWdg(vbox); |
| 70 |
|
| 71 |
vbox->setStretchFactor(d->progressBar, 10); |
| 72 |
vbox->setContentsMargins(QMargins()); |
| 73 |
vbox->setSpacing(layoutSpacing()); |
| 74 |
|
| 75 |
setPageWidget(vbox); |
| 76 |
setLeftBottomPix(QIcon::fromTheme(QLatin1String("system-run"))); |
| 77 |
} |
| 78 |
|
| 79 |
JAlbumFinalPage::~JAlbumFinalPage() |
| 80 |
{ |
| 81 |
delete d; |
| 82 |
} |
| 83 |
|
| 84 |
void JAlbumFinalPage::initializePage() |
| 85 |
{ |
| 86 |
d->complete = false; |
| 87 |
|
| 88 |
Q_EMIT completeChanged(); |
| 89 |
|
| 90 |
QTimer::singleShot(0, this, SLOT(slotProcess())); |
| 91 |
} |
| 92 |
|
| 93 |
void JAlbumFinalPage::slotProcess() |
| 94 |
{ |
| 95 |
JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant()); |
| 96 |
|
| 97 |
if (!wizard) |
| 98 |
{ |
| 99 |
d->progressView->addEntry(i18n("Internal Error"), |
| 100 |
DHistoryView::ErrorEntry); |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
d->progressView->clear(); |
| 105 |
d->progressBar->reset(); |
| 106 |
|
| 107 |
JAlbumSettings* const info = wizard->settings(); |
| 108 |
|
| 109 |
// Generate JAlbumSettings |
| 110 |
|
| 111 |
qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << info; |
| 112 |
|
| 113 |
d->progressView->addEntry(i18n("Starting to generate jAlbum..."), |
| 114 |
DHistoryView::ProgressEntry); |
| 115 |
|
| 116 |
if (info->m_getOption == JAlbumSettings::ALBUMS) |
| 117 |
{ |
| 118 |
if (!info->m_iface) |
| 119 |
return; |
| 120 |
|
| 121 |
d->progressView->addEntry(i18n("%1 albums to process:", info->m_albumList.count()), |
| 122 |
DHistoryView::ProgressEntry); |
| 123 |
const auto urls = info->m_iface->albumsItems(info->m_albumList); |
| 124 |
|
| 125 |
for (const QUrl& url : urls) |
| 126 |
{ |
| 127 |
d->progressView->addEntry(QDir::toNativeSeparators(url.toLocalFile()), |
| 128 |
DHistoryView::ProgressEntry); |
| 129 |
} |
| 130 |
} |
| 131 |
else |
| 132 |
{ |
| 133 |
d->progressView->addEntry(i18n("%1 items to process", info->m_imageList.count()), |
| 134 |
DHistoryView::ProgressEntry); |
| 135 |
} |
| 136 |
|
| 137 |
d->progressView->addEntry(i18n("Output directory: %1", |
| 138 |
QDir::toNativeSeparators(info->m_destPath)), |
| 139 |
DHistoryView::ProgressEntry); |
| 140 |
|
| 141 |
JAlbumGenerator generator(info); |
| 142 |
generator.setProgressWidgets(d->progressView, d->progressBar); |
| 143 |
|
| 144 |
if (!generator.run()) |
| 145 |
{ |
| 146 |
return; |
| 147 |
} |
| 148 |
|
| 149 |
if (generator.warnings()) |
| 150 |
{ |
| 151 |
d->progressView->addEntry(i18n("Jalbum is completed, but some warnings occurred."), |
| 152 |
DHistoryView::WarningEntry); |
| 153 |
} |
| 154 |
else |
| 155 |
{ |
| 156 |
d->progressView->addEntry(i18n("Jalbum completed."), |
| 157 |
DHistoryView::ProgressEntry); |
| 158 |
} |
| 159 |
|
| 160 |
d->complete = true; |
| 161 |
|
| 162 |
Q_EMIT completeChanged(); |
| 163 |
} |
| 164 |
|
| 165 |
bool JAlbumFinalPage::isComplete() const |
| 166 |
{ |
| 167 |
return d->complete; |
| 168 |
} |
| 169 |
|
| 170 |
} // namespace DigikamGenericJAlbumPlugin |
| 171 |
|
| 172 |
#include "moc_jalbumfinalpage.cpp" |