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 "mailimagespage.h"
0016 
0017 // Qt includes
0018 
0019 #include <QIcon>
0020 #include <QPixmap>
0021 #include <QLabel>
0022 
0023 // KDE includes
0024 
0025 #include <klocalizedstring.h>
0026 
0027 // Local includes
0028 
0029 #include "mailwizard.h"
0030 #include "ditemslist.h"
0031 #include "dlayoutbox.h"
0032 
0033 namespace DigikamGenericSendByMailPlugin
0034 {
0035 
0036 class Q_DECL_HIDDEN MailImagesPage::Private
0037 {
0038 public:
0039 
0040     explicit Private(QWizard* const dialog)
0041       : imageList(nullptr),
0042         wizard(nullptr),
0043         iface(nullptr)
0044     {
0045         wizard = dynamic_cast<MailWizard*>(dialog);
0046 
0047         if (wizard)
0048         {
0049             iface = wizard->iface();
0050         }
0051     }
0052 
0053     DItemsList*     imageList;
0054     MailWizard*     wizard;
0055     DInfoInterface* iface;
0056 };
0057 
0058 MailImagesPage::MailImagesPage(QWizard* const dialog, const QString& title)
0059     : DWizardPage(dialog, title),
0060       d(new Private(dialog))
0061 {
0062     DVBox* const vbox  = new DVBox(this);
0063     QLabel* const desc = new QLabel(vbox);
0064     desc->setText(i18n("<p>This view list all items to export by mail.</p>"));
0065 
0066     d->imageList       = new DItemsList(vbox);
0067     d->imageList->setObjectName(QLatin1String("MailImages ImagesList"));
0068     d->imageList->setControlButtonsPlacement(DItemsList::ControlButtonsBelow);
0069 
0070     setPageWidget(vbox);
0071     setLeftBottomPix(QIcon::fromTheme(QLatin1String("image-stack")));
0072 
0073     connect(d->imageList, SIGNAL(signalImageListChanged()),
0074             this, SIGNAL(completeChanged()));
0075 }
0076 
0077 MailImagesPage::~MailImagesPage()
0078 {
0079     delete d;
0080 }
0081 
0082 void MailImagesPage::setItemsList(const QList<QUrl>& urls)
0083 {
0084     d->imageList->slotAddImages(urls);
0085 }
0086 
0087 void MailImagesPage::initializePage()
0088 {
0089     d->imageList->setIface(d->iface);
0090     d->imageList->listView()->clear();
0091 
0092     if (d->wizard->settings()->selMode == MailSettings::IMAGES)
0093     {
0094         d->imageList->loadImagesFromCurrentSelection();
0095     }
0096     else
0097     {
0098         setItemsList(d->wizard->settings()->inputImages);
0099     }
0100 }
0101 
0102 bool MailImagesPage::validatePage()
0103 {
0104     if (d->imageList->imageUrls().isEmpty())
0105     {
0106         return false;
0107     }
0108 
0109     d->wizard->settings()->inputImages = d->imageList->imageUrls();
0110 
0111     return true;
0112 }
0113 
0114 bool MailImagesPage::isComplete() const
0115 {
0116     return (!d->imageList->imageUrls().isEmpty());
0117 }
0118 
0119 } // namespace DigikamGenericSendByMailPlugin
0120 
0121 #include "moc_mailimagespage.cpp"