File indexing completed on 2025-01-05 03:52:08

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 "jalbumwizard.h"
0016 
0017 // Qt includes
0018 
0019 #include <QCheckBox>
0020 #include <QLabel>
0021 #include <QMenu>
0022 #include <QApplication>
0023 #include <QComboBox>
0024 #include <QListWidget>
0025 #include <QTextBrowser>
0026 
0027 // KDE includes
0028 
0029 #include <klocalizedstring.h>
0030 #include <ksharedconfig.h>
0031 #include <kconfiggroup.h>
0032 
0033 
0034 // Local includes
0035 
0036 #include "dwizardpage.h"
0037 #include "digikam_debug.h"
0038 #include "jalbumfinalpage.h"
0039 #include "jalbumsettings.h"
0040 #include "jalbumintropage.h"
0041 #include "jalbumoutputpage.h"
0042 #include "jalbumselectionpage.h"
0043 
0044 namespace DigikamGenericJAlbumPlugin
0045 {
0046 
0047 class Q_DECL_HIDDEN JAlbumWizard::Private
0048 {
0049 public:
0050 
0051     explicit Private()
0052       : settings(nullptr),
0053         introPage(nullptr),
0054         selectionPage(nullptr),
0055         outputPage(nullptr),
0056         finalPage(nullptr)
0057     {
0058     }
0059 
0060     JAlbumSettings*        settings;
0061 
0062     JAlbumIntroPage*       introPage;
0063     JAlbumSelectionPage*   selectionPage;
0064     JAlbumOutputPage*      outputPage;
0065     JAlbumFinalPage*       finalPage;
0066 };
0067 
0068 JAlbumWizard::JAlbumWizard(QWidget* const parent, DInfoInterface* const iface)
0069     : DWizardDlg(parent, QLatin1String("jAlbum Album Creation Dialog")),
0070       d(new Private)
0071 {
0072     setOption(QWizard::NoCancelButtonOnLastPage);
0073     setWindowTitle(i18nc("@title:window", "Create jAlbum Album"));
0074 
0075     d->settings          = new JAlbumSettings(iface);
0076 
0077     KSharedConfigPtr config = KSharedConfig::openConfig();
0078     KConfigGroup group      = config->group(QLatin1String("jAlbum tool"));
0079     d->settings->readSettings(group);
0080 
0081     d->introPage         = new JAlbumIntroPage(this,         i18n("Welcome to jAlbum Export Tool"));
0082     d->selectionPage     = new JAlbumSelectionPage(this,     i18n("Items Selection"));
0083     d->outputPage        = new JAlbumOutputPage(this,        i18n("Paths Selection"));
0084     d->finalPage         = new JAlbumFinalPage(this,         i18n("Generating jAlbum"));
0085 }
0086 
0087 JAlbumWizard::~JAlbumWizard()
0088 {
0089     delete d;
0090 }
0091 
0092 void JAlbumWizard::setItemsList(const QList<QUrl>& urls)
0093 {
0094     d->selectionPage->setItemsList(urls);
0095 }
0096 
0097 bool JAlbumWizard::validateCurrentPage()
0098 {
0099     if (!DWizardDlg::validateCurrentPage())
0100     {
0101         return false;
0102     }
0103 
0104     if (currentPage() == d->outputPage)
0105     {
0106         KSharedConfigPtr config = KSharedConfig::openConfig();
0107         KConfigGroup group      = config->group(QLatin1String("jAlbum tool"));
0108         d->settings->writeSettings(group);
0109     }
0110 
0111     return true;
0112 }
0113 
0114 int JAlbumWizard::nextId() const
0115 {
0116     return DWizardDlg::nextId();
0117 }
0118 
0119 JAlbumSettings* JAlbumWizard::settings() const
0120 {
0121     return d->settings;
0122 }
0123 
0124 } // namespace DigikamGenericJAlbumPlugin
0125 
0126 #include "moc_jalbumwizard.cpp"