File indexing completed on 2025-01-19 03:52: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 by email.
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 "mailalbumspage.h"
0016 
0017 // Qt includes
0018 
0019 #include <QIcon>
0020 #include <QPixmap>
0021 
0022 // Local includes
0023 
0024 #include "mailwizard.h"
0025 
0026 namespace DigikamGenericSendByMailPlugin
0027 {
0028 
0029 class Q_DECL_HIDDEN MailAlbumsPage::Private
0030 {
0031 public:
0032 
0033     explicit Private(QWizard* const dialog)
0034       : albumSupport(false),
0035         albumSelector(nullptr),
0036         wizard(nullptr),
0037         iface(nullptr)
0038     {
0039         wizard = dynamic_cast<MailWizard*>(dialog);
0040 
0041         if (wizard)
0042         {
0043             iface = wizard->iface();
0044         }
0045     }
0046 
0047     bool             albumSupport;
0048     QWidget*         albumSelector;
0049     MailWizard*      wizard;
0050     DInfoInterface*  iface;
0051 };
0052 
0053 MailAlbumsPage::MailAlbumsPage(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 MailAlbumsPage::~MailAlbumsPage()
0074 {
0075     delete d;
0076 }
0077 
0078 bool MailAlbumsPage::validatePage()
0079 {
0080     if (!d->iface)
0081     {
0082         return false;
0083     }
0084 
0085     if (d->iface->albumChooserItems().isEmpty())
0086     {
0087         return false;
0088     }
0089 
0090     d->wizard->settings()->inputImages.clear();
0091 
0092     // update image list with album contents.
0093 
0094     Q_FOREACH (const QUrl& url, d->iface->albumsItems(d->iface->albumChooserItems()))
0095     {
0096         d->wizard->settings()->inputImages << url;
0097     }
0098 
0099     return true;
0100 }
0101 
0102 bool MailAlbumsPage::isComplete() const
0103 {
0104     if (!d->iface)
0105     {
0106         return false;
0107     }
0108 
0109     return (!d->iface->albumChooserItems().isEmpty());
0110 }
0111 
0112 } // namespace DigikamGenericSendByMailPlugin
0113 
0114 #include "moc_mailalbumspage.cpp"