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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2017-05-25
0007  * Description : a tool to generate video slideshow from images.
0008  *
0009  * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "vidslidealbumspage.h"
0016 
0017 // Qt includes
0018 
0019 #include <QIcon>
0020 #include <QPixmap>
0021 
0022 // Local includes
0023 
0024 #include "vidslidewizard.h"
0025 
0026 namespace DigikamGenericVideoSlideShowPlugin
0027 {
0028 
0029 class Q_DECL_HIDDEN VidSlideAlbumsPage::Private
0030 {
0031 public:
0032 
0033     explicit Private(QWizard* const dialog)
0034     {
0035         wizard = dynamic_cast<VidSlideWizard*>(dialog);
0036 
0037         if (wizard)
0038         {
0039             settings = wizard->settings();
0040         }
0041     }
0042 
0043     bool              albumSupport  = false;
0044     QWidget*          albumSelector = nullptr;
0045     VidSlideWizard*   wizard        = nullptr;
0046     VidSlideSettings* settings      = nullptr;
0047 };
0048 
0049 VidSlideAlbumsPage::VidSlideAlbumsPage(QWizard* const dialog, const QString& title)
0050     : DWizardPage(dialog, title),
0051       d          (new Private(dialog))
0052 {
0053     if (d->settings->iface)
0054     {
0055         d->albumSelector = d->settings->iface->albumChooser(this);
0056 
0057         connect(d->settings->iface, SIGNAL(signalAlbumChooserSelectionChanged()),
0058                 this, SIGNAL(completeChanged()));
0059     }
0060     else
0061     {
0062         d->albumSelector = new QWidget(this);
0063     }
0064 
0065     setPageWidget(d->albumSelector);
0066     setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-pictures")));
0067 }
0068 
0069 VidSlideAlbumsPage::~VidSlideAlbumsPage()
0070 {
0071     delete d;
0072 }
0073 
0074 bool VidSlideAlbumsPage::validatePage()
0075 {
0076     if (!d->settings->iface)
0077     {
0078         return false;
0079     }
0080 
0081     if (d->settings->iface && d->settings->iface->albumChooserItems().isEmpty())
0082     {
0083         return false;
0084     }
0085 
0086     d->wizard->settings()->inputImages.clear();
0087 
0088     // update image list with album contents.
0089     Q_FOREACH (const QUrl& url, d->settings->iface->albumsItems(d->settings->iface->albumChooserItems()))
0090     {
0091         d->wizard->settings()->inputImages << url;
0092     }
0093 
0094     return true;
0095 }
0096 
0097 bool VidSlideAlbumsPage::isComplete() const
0098 {
0099     if (!d->settings->iface)
0100     {
0101         return false;
0102     }
0103 
0104     return (!d->settings->iface->albumChooserItems().isEmpty());
0105 }
0106 
0107 } // namespace DigikamGenericVideoSlideShowPlugin
0108 
0109 #include "moc_vidslidealbumspage.cpp"