File indexing completed on 2025-01-05 03:52:07
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-04-04 0007 * Description : a tool to generate jAlbum image galleries 0008 * 0009 * SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "jalbumfinalpage.h" 0016 0017 // Qt includes 0018 0019 #include <QIcon> 0020 #include <QSpacerItem> 0021 #include <QVBoxLayout> 0022 #include <QDesktopServices> 0023 #include <QUrl> 0024 #include <QApplication> 0025 #include <QStyle> 0026 #include <QTimer> 0027 #include <QDir> 0028 0029 // KDE includes 0030 0031 #include <klocalizedstring.h> 0032 0033 // Local includes 0034 0035 #include "jalbumwizard.h" 0036 #include "jalbumsettings.h" 0037 #include "jalbumgenerator.h" 0038 #include "dlayoutbox.h" 0039 #include "digikam_debug.h" 0040 #include "dprogresswdg.h" 0041 #include "dhistoryview.h" 0042 #include "webbrowserdlg.h" 0043 0044 namespace DigikamGenericJAlbumPlugin 0045 { 0046 0047 class Q_DECL_HIDDEN JAlbumFinalPage::Private 0048 { 0049 public: 0050 0051 explicit Private() 0052 : progressView(nullptr), 0053 progressBar(nullptr), 0054 complete(false) 0055 { 0056 } 0057 0058 DHistoryView* progressView; 0059 DProgressWdg* progressBar; 0060 bool complete; 0061 }; 0062 0063 JAlbumFinalPage::JAlbumFinalPage(QWizard* const dialog, const QString& title) 0064 : DWizardPage(dialog, title), 0065 d(new Private) 0066 { 0067 setObjectName(QLatin1String("FinalPage")); 0068 0069 DVBox* const vbox = new DVBox(this); 0070 d->progressView = new DHistoryView(vbox); 0071 d->progressBar = new DProgressWdg(vbox); 0072 0073 vbox->setStretchFactor(d->progressBar, 10); 0074 vbox->setContentsMargins(QMargins()); 0075 vbox->setSpacing(qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0076 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing))); 0077 0078 setPageWidget(vbox); 0079 setLeftBottomPix(QIcon::fromTheme(QLatin1String("system-run"))); 0080 } 0081 0082 JAlbumFinalPage::~JAlbumFinalPage() 0083 { 0084 delete d; 0085 } 0086 0087 void JAlbumFinalPage::initializePage() 0088 { 0089 d->complete = false; 0090 Q_EMIT completeChanged(); 0091 QTimer::singleShot(0, this, SLOT(slotProcess())); 0092 } 0093 0094 void JAlbumFinalPage::slotProcess() 0095 { 0096 JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant()); 0097 0098 if (!wizard) 0099 { 0100 d->progressView->addEntry(i18n("Internal Error"), 0101 DHistoryView::ErrorEntry); 0102 return; 0103 } 0104 0105 d->progressView->clear(); 0106 d->progressBar->reset(); 0107 0108 JAlbumSettings* const info = wizard->settings(); 0109 0110 // Generate JAlbumSettings 0111 0112 qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << info; 0113 0114 d->progressView->addEntry(i18n("Starting to generate jAlbum..."), 0115 DHistoryView::ProgressEntry); 0116 0117 if (info->m_getOption == JAlbumSettings::ALBUMS) 0118 { 0119 if (!info->m_iface) 0120 return; 0121 0122 d->progressView->addEntry(i18n("%1 albums to process:", info->m_albumList.count()), 0123 DHistoryView::ProgressEntry); 0124 0125 Q_FOREACH (const QUrl& url, info->m_iface->albumsItems(info->m_albumList)) 0126 { 0127 d->progressView->addEntry(QDir::toNativeSeparators(url.toLocalFile()), 0128 DHistoryView::ProgressEntry); 0129 } 0130 } 0131 else 0132 { 0133 d->progressView->addEntry(i18n("%1 items to process", info->m_imageList.count()), 0134 DHistoryView::ProgressEntry); 0135 } 0136 0137 d->progressView->addEntry(i18n("Output directory: %1", 0138 QDir::toNativeSeparators(info->m_destPath)), 0139 DHistoryView::ProgressEntry); 0140 0141 JAlbumGenerator generator(info); 0142 generator.setProgressWidgets(d->progressView, d->progressBar); 0143 0144 if (!generator.run()) 0145 { 0146 return; 0147 } 0148 0149 if (generator.warnings()) 0150 { 0151 d->progressView->addEntry(i18n("Jalbum is completed, but some warnings occurred."), 0152 DHistoryView::WarningEntry); 0153 } 0154 else 0155 { 0156 d->progressView->addEntry(i18n("Jalbum completed."), 0157 DHistoryView::ProgressEntry); 0158 } 0159 0160 d->complete = true; 0161 Q_EMIT completeChanged(); 0162 } 0163 0164 bool JAlbumFinalPage::isComplete() const 0165 { 0166 return d->complete; 0167 } 0168 0169 } // namespace DigikamGenericJAlbumPlugin 0170 0171 #include "moc_jalbumfinalpage.cpp"