File indexing completed on 2025-01-05 03:52:08
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-04-04 0007 * Description : a tool to generate jAlbum image galleries 0008 * 0009 * SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "jalbumselectionpage.h" 0016 0017 // Qt includes 0018 0019 #include <QIcon> 0020 #include <QPixmap> 0021 #include <QStackedWidget> 0022 0023 // Local includes 0024 0025 #include "jalbumwizard.h" 0026 #include "jalbumsettings.h" 0027 #include "ditemslist.h" 0028 0029 namespace DigikamGenericJAlbumPlugin 0030 { 0031 0032 class Q_DECL_HIDDEN JAlbumSelectionPage::Private 0033 { 0034 public: 0035 0036 explicit Private(QWizard* const dialog) 0037 : albumSupport(false), 0038 albumSelector(nullptr), 0039 imageList(nullptr), 0040 stack(nullptr), 0041 wizard(nullptr), 0042 settings(nullptr), 0043 iface(nullptr) 0044 { 0045 wizard = dynamic_cast<JAlbumWizard*>(dialog); 0046 0047 if (wizard) 0048 { 0049 settings = wizard->settings(); 0050 iface = settings->m_iface; 0051 } 0052 } 0053 0054 bool albumSupport; 0055 QWidget* albumSelector; 0056 DItemsList* imageList; 0057 QStackedWidget* stack; 0058 JAlbumWizard* wizard; 0059 JAlbumSettings* settings; 0060 DInfoInterface* iface; 0061 }; 0062 0063 JAlbumSelectionPage::JAlbumSelectionPage(QWizard* const dialog, const QString& title) 0064 : DWizardPage(dialog, title), 0065 d(new Private(dialog)) 0066 { 0067 setObjectName(QLatin1String("AlbumSelectorPage")); 0068 0069 d->stack = new QStackedWidget(this); 0070 d->albumSupport = (d->iface && d->iface->supportAlbums()); 0071 0072 if (d->albumSupport) 0073 { 0074 d->albumSelector = d->iface->albumChooser(this); 0075 } 0076 else 0077 { 0078 d->albumSelector = new QWidget(this); 0079 } 0080 0081 d->stack->insertWidget(JAlbumSettings::ALBUMS, d->albumSelector); 0082 0083 d->imageList = new DItemsList(this); 0084 d->imageList->setObjectName(QLatin1String("JAlbum ImagesList")); 0085 d->imageList->setControlButtonsPlacement(DItemsList::ControlButtonsBelow); 0086 d->stack->insertWidget(JAlbumSettings::IMAGES, d->imageList); 0087 0088 setPageWidget(d->stack); 0089 setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-pictures"))); 0090 0091 if (d->albumSupport) 0092 { 0093 connect(d->iface, SIGNAL(signalAlbumChooserSelectionChanged()), 0094 this, SIGNAL(completeChanged())); 0095 } 0096 0097 connect(d->imageList, SIGNAL(signalImageListChanged()), 0098 this, SIGNAL(completeChanged())); 0099 } 0100 0101 JAlbumSelectionPage::~JAlbumSelectionPage() 0102 { 0103 delete d; 0104 } 0105 0106 0107 void JAlbumSelectionPage::setItemsList(const QList<QUrl>& urls) 0108 { 0109 d->imageList->slotAddImages(urls); 0110 } 0111 0112 void JAlbumSelectionPage::initializePage() 0113 { 0114 d->imageList->setIface(d->iface); 0115 0116 if (d->settings->m_getOption == JAlbumSettings::IMAGES) 0117 { 0118 d->imageList->loadImagesFromCurrentSelection(); 0119 } 0120 0121 d->stack->setCurrentIndex(d->settings->m_getOption); 0122 } 0123 0124 bool JAlbumSelectionPage::validatePage() 0125 { 0126 if (d->stack->currentIndex() == JAlbumSettings::ALBUMS) 0127 { 0128 if (d->albumSupport) 0129 { 0130 if (d->iface->albumChooserItems().isEmpty()) 0131 return false; 0132 0133 d->settings->m_albumList = d->iface->albumChooserItems(); 0134 } 0135 else 0136 { 0137 return false; 0138 } 0139 } 0140 else 0141 { 0142 if (d->imageList->imageUrls().isEmpty()) 0143 return false; 0144 0145 d->settings->m_imageList = d->imageList->imageUrls(); 0146 } 0147 0148 return true; 0149 } 0150 0151 bool JAlbumSelectionPage::isComplete() const 0152 { 0153 if (d->stack->currentIndex() == JAlbumSettings::ALBUMS) 0154 { 0155 if (!d->albumSupport) 0156 return false; 0157 0158 return (!d->iface->albumChooserItems().isEmpty()); 0159 } 0160 0161 return (!d->imageList->imageUrls().isEmpty()); 0162 } 0163 0164 } // namespace DigikamGenericJAlbumPlugin 0165 0166 #include "moc_jalbumselectionpage.cpp"