File indexing completed on 2025-01-05 03:53:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2017-06-27
0007  * Description : a tool to export items to web services.
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 "wsalbumspage.h"
0016 
0017 // Qt includes
0018 
0019 #include <QIcon>
0020 #include <QPixmap>
0021 
0022 // Local includes
0023 
0024 #include "wswizard.h"
0025 
0026 namespace DigikamGenericUnifiedPlugin
0027 {
0028 
0029 class Q_DECL_HIDDEN WSAlbumsPage::Private
0030 {
0031 public:
0032 
0033     explicit Private(QWizard* const dialog)
0034       : albumSupport(false),
0035         albumSelector(0),
0036         wizard(0),
0037         iface(0)
0038     {
0039         wizard = dynamic_cast<WSWizard*>(dialog);
0040 
0041         if (wizard)
0042         {
0043             iface = wizard->iface();
0044         }
0045     }
0046 
0047     bool             albumSupport;
0048     QWidget*         albumSelector;
0049     WSWizard*        wizard;
0050     DInfoInterface*  iface;
0051 };
0052 
0053 WSAlbumsPage::WSAlbumsPage(QWizard* const dialog, const QString& title)
0054     : DWizardPage(dialog, title),
0055       d(new Private(dialog))
0056 {
0057     if (d->iface)
0058     {
0059         d->albumSelector = d->iface->albumChooser(this);
0060 
0061         connect(d->iface, SIGNAL(signalAlbumChooserSelectionChanged()),
0062                 this, SIGNAL(completeChanged()));
0063     }
0064     else
0065     {
0066         d->albumSelector = new QWidget(this);
0067     }
0068 
0069     setPageWidget(d->albumSelector);
0070     setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-mail")));
0071 }
0072 
0073 WSAlbumsPage::~WSAlbumsPage()
0074 {
0075     delete d;
0076 }
0077 
0078 bool WSAlbumsPage::validatePage()
0079 {
0080     if (!d->iface)
0081         return false;
0082 
0083     if (d->iface->albumChooserItems().isEmpty())
0084         return false;
0085 
0086     d->wizard->settings()->inputImages.clear();
0087 
0088     // update image list with album contents.
0089     Q_FOREACH (const QUrl& url, d->iface->albumsItems(d->iface->albumChooserItems()))
0090     {
0091         d->wizard->settings()->inputImages << url;
0092     }
0093 
0094     return true;
0095 }
0096 
0097 bool WSAlbumsPage::isComplete() const
0098 {
0099     if (!d->iface)
0100         return false;
0101 
0102     return (!d->iface->albumChooserItems().isEmpty());
0103 }
0104 
0105 } // namespace DigikamGenericUnifiedPlugin