| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2006-04-04 |
| 7 |
* Description : a tool to generate jAlbum image galleries |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk> |
| 10 |
* |
| 11 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 12 |
* |
| 13 |
* ============================================================ */ |
| 14 |
|
| 15 |
#include "jalbumselectionpage.h" |
| 16 |
|
| 17 |
// Qt includes |
| 18 |
|
| 19 |
#include <QIcon> |
| 20 |
#include <QPixmap> |
| 21 |
#include <QStackedWidget> |
| 22 |
|
| 23 |
// Local includes |
| 24 |
|
| 25 |
#include "jalbumwizard.h" |
| 26 |
#include "jalbumsettings.h" |
| 27 |
#include "ditemslist.h" |
| 28 |
|
| 29 |
namespace DigikamGenericJAlbumPlugin |
| 30 |
{ |
| 31 |
|
| 32 |
class Q_DECL_HIDDEN JAlbumSelectionPage::Private |
| 33 |
{ |
| 34 |
public: |
| 35 |
|
| 36 |
explicit Private(QWizard* const dialog) |
| 37 |
{ |
| 38 |
wizard = dynamic_cast<JAlbumWizard*>(dialog); |
| 39 |
|
| 40 |
if (wizard) |
| 41 |
{ |
| 42 |
settings = wizard->settings(); |
| 43 |
iface = settings->m_iface; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public: |
| 48 |
|
| 49 |
bool albumSupport = false; |
| 50 |
QWidget* albumSelector = nullptr; |
| 51 |
DItemsList* imageList = nullptr; |
| 52 |
QStackedWidget* stack = nullptr; |
| 53 |
JAlbumWizard* wizard = nullptr; |
| 54 |
JAlbumSettings* settings = nullptr; |
| 55 |
DInfoInterface* iface = nullptr; |
| 56 |
}; |
| 57 |
|
| 58 |
JAlbumSelectionPage::JAlbumSelectionPage(QWizard* const dialog, const QString& title) |
| 59 |
: DWizardPage(dialog, title), |
| 60 |
d (new Private(dialog)) |
| 61 |
{ |
| 62 |
setObjectName(QLatin1String("AlbumSelectorPage")); |
| 63 |
|
| 64 |
d->stack = new QStackedWidget(this); |
| 65 |
d->albumSupport = (d->iface && d->iface->supportAlbums()); |
| 66 |
|
| 67 |
if (d->albumSupport) |
| 68 |
{ |
| 69 |
d->albumSelector = d->iface->albumChooser(this); |
| 70 |
} |
| 71 |
else |
| 72 |
{ |
| 73 |
d->albumSelector = new QWidget(this); |
| 74 |
} |
| 75 |
|
| 76 |
d->stack->insertWidget(JAlbumSettings::ALBUMS, d->albumSelector); |
| 77 |
|
| 78 |
d->imageList = new DItemsList(this); |
| 79 |
d->imageList->setObjectName(QLatin1String("JAlbum ImagesList")); |
| 80 |
d->imageList->setControlButtonsPlacement(DItemsList::ControlButtonsBelow); |
| 81 |
d->stack->insertWidget(JAlbumSettings::IMAGES, d->imageList); |
| 82 |
|
| 83 |
setPageWidget(d->stack); |
| 84 |
setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-pictures"))); |
| 85 |
|
| 86 |
if (d->albumSupport) |
| 87 |
{ |
| 88 |
connect(d->iface, SIGNAL(signalAlbumChooserSelectionChanged()), |
| 89 |
this, SIGNAL(completeChanged())); |
| 90 |
} |
| 91 |
|
| 92 |
connect(d->imageList, SIGNAL(signalImageListChanged()), |
| 93 |
this, SIGNAL(completeChanged())); |
| 94 |
} |
| 95 |
|
| 96 |
JAlbumSelectionPage::~JAlbumSelectionPage() |
| 97 |
{ |
| 98 |
delete d; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
void JAlbumSelectionPage::setItemsList(const QList<QUrl>& urls) |
| 103 |
{ |
| 104 |
d->imageList->slotAddImages(urls); |
| 105 |
} |
| 106 |
|
| 107 |
void JAlbumSelectionPage::initializePage() |
| 108 |
{ |
| 109 |
d->imageList->setIface(d->iface); |
| 110 |
|
| 111 |
if (d->settings->m_getOption == JAlbumSettings::IMAGES) |
| 112 |
{ |
| 113 |
d->imageList->loadImagesFromCurrentSelection(); |
| 114 |
} |
| 115 |
|
| 116 |
d->stack->setCurrentIndex(d->settings->m_getOption); |
| 117 |
} |
| 118 |
|
| 119 |
bool JAlbumSelectionPage::validatePage() |
| 120 |
{ |
| 121 |
if (d->stack->currentIndex() == JAlbumSettings::ALBUMS) |
| 122 |
{ |
| 123 |
if (d->albumSupport) |
| 124 |
{ |
| 125 |
if (d->iface->albumChooserItems().isEmpty()) |
| 126 |
return false; |
| 127 |
|
| 128 |
d->settings->m_albumList = d->iface->albumChooserItems(); |
| 129 |
} |
| 130 |
else |
| 131 |
{ |
| 132 |
return false; |
| 133 |
} |
| 134 |
} |
| 135 |
else |
| 136 |
{ |
| 137 |
if (d->imageList->imageUrls().isEmpty()) |
| 138 |
{ |
| 139 |
return false; |
| 140 |
} |
| 141 |
|
| 142 |
d->settings->m_imageList = d->imageList->imageUrls(); |
| 143 |
} |
| 144 |
|
| 145 |
return true; |
| 146 |
} |
| 147 |
|
| 148 |
bool JAlbumSelectionPage::isComplete() const |
| 149 |
{ |
| 150 |
if (d->stack->currentIndex() == JAlbumSettings::ALBUMS) |
| 151 |
{ |
| 152 |
if (!d->albumSupport) |
| 153 |
{ |
| 154 |
return false; |
| 155 |
} |
| 156 |
|
| 157 |
return (!d->iface->albumChooserItems().isEmpty()); |
| 158 |
} |
| 159 |
|
| 160 |
return (!d->imageList->imageUrls().isEmpty()); |
| 161 |
} |
| 162 |
|
| 163 |
} // namespace DigikamGenericJAlbumPlugin |
| 164 |
|
| 165 |
#include "moc_jalbumselectionpage.cpp" |