File indexing completed on 2025-01-19 03:52:46

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 "mailwizard.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 // Local includes
0034 
0035 #include "dwizardpage.h"
0036 #include "digikam_debug.h"
0037 #include "mailintropage.h"
0038 #include "mailalbumspage.h"
0039 #include "mailimagespage.h"
0040 #include "mailsettingspage.h"
0041 #include "mailfinalpage.h"
0042 
0043 namespace DigikamGenericSendByMailPlugin
0044 {
0045 
0046 class Q_DECL_HIDDEN MailWizard::Private
0047 {
0048 public:
0049 
0050     explicit Private()
0051       : iface(nullptr),
0052         introPage(nullptr),
0053         albumsPage(nullptr),
0054         imagesPage(nullptr),
0055         settingsPage(nullptr),
0056         finalPage(nullptr),
0057         settings(nullptr)
0058     {
0059     }
0060 
0061     DInfoInterface*     iface;
0062     MailIntroPage*      introPage;
0063     MailAlbumsPage*     albumsPage;
0064     MailImagesPage*     imagesPage;
0065     MailSettingsPage*   settingsPage;
0066     MailFinalPage*      finalPage;
0067     MailSettings*       settings;
0068 };
0069 
0070 MailWizard::MailWizard(QWidget* const parent, DInfoInterface* const iface)
0071     : DWizardDlg(parent, QLatin1String("Email Dialog")),
0072       d(new Private)
0073 {
0074     setOption(QWizard::NoCancelButtonOnLastPage);
0075     setWindowTitle(i18nc("@title:window", "Send by Email"));
0076 
0077     d->iface             = iface;
0078     d->settings          = new MailSettings;
0079 
0080     KSharedConfigPtr config = KSharedConfig::openConfig();
0081     KConfigGroup group      = config->group(QLatin1String("Email Dialog Settings"));
0082     d->settings->readSettings(group);
0083 
0084     d->introPage         = new MailIntroPage(this,    i18n("Welcome to Email Tool"));
0085     d->albumsPage        = new MailAlbumsPage(this,   i18n("Albums Selection"));
0086     d->imagesPage        = new MailImagesPage(this,   i18n("Images List"));
0087     d->settingsPage      = new MailSettingsPage(this, i18n("Email Settings"));
0088     d->finalPage         = new MailFinalPage(this,    i18n("Export by Email"));
0089 }
0090 
0091 MailWizard::~MailWizard()
0092 {
0093     KSharedConfigPtr config = KSharedConfig::openConfig();
0094     KConfigGroup group      = config->group(QLatin1String("Email Dialog Settings"));
0095     d->settings->writeSettings(group);
0096 
0097     delete d;
0098 }
0099 
0100 void MailWizard::setItemsList(const QList<QUrl>& urls)
0101 {
0102     d->imagesPage->setItemsList(urls);
0103 }
0104 
0105 DInfoInterface* MailWizard::iface() const
0106 {
0107     return d->iface;
0108 }
0109 
0110 MailSettings* MailWizard::settings() const
0111 {
0112     return d->settings;
0113 }
0114 
0115 bool MailWizard::validateCurrentPage()
0116 {
0117     if (!DWizardDlg::validateCurrentPage())
0118     {
0119         return false;
0120     }
0121 
0122     return true;
0123 }
0124 
0125 int MailWizard::nextId() const
0126 {
0127     if (d->settings->selMode == MailSettings::ALBUMS)
0128     {
0129         if (currentPage() == d->introPage)
0130         {
0131             return d->albumsPage->id();
0132         }
0133     }
0134     else
0135     {
0136         if (currentPage() == d->introPage)
0137         {
0138             return d->imagesPage->id();
0139         }
0140     }
0141 
0142     return DWizardDlg::nextId();
0143 }
0144 
0145 } // namespace DigikamGenericSendByMailPlugin
0146 
0147 #include "moc_mailwizard.cpp"