1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2017-05-25
7 * Description : a tool to generate video slideshow from images.
8 *
9 * Copyright (C) 2017-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 *
11 * This program is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software Foundation;
14 * either version 2, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * ============================================================ */
22
23 #include "vidslidealbumspage.h"
24
25 // Qt includes
26
27 #include <QIcon>
28 #include <QPixmap>
29
30 // Local includes
31
32 #include "vidslidewizard.h"
33
34 namespace DigikamGenericVideoSlideShowPlugin
35 {
36
37 class Q_DECL_HIDDEN VidSlideAlbumsPage::Private
38 {
39 public:
40
Private(QWizard * const dialog)41 explicit Private(QWizard* const dialog)
42 : albumSupport(false),
43 albumSelector(nullptr),
44 wizard(nullptr),
45 iface(nullptr)
46 {
47 wizard = dynamic_cast<VidSlideWizard*>(dialog);
48
49 if (wizard)
50 {
51 iface = wizard->iface();
52 }
53 }
54
55 bool albumSupport;
56 QWidget* albumSelector;
57 VidSlideWizard* wizard;
58 DInfoInterface* iface;
59 };
60
VidSlideAlbumsPage(QWizard * const dialog,const QString & title)61 VidSlideAlbumsPage::VidSlideAlbumsPage(QWizard* const dialog, const QString& title)
62 : DWizardPage(dialog, title),
63 d(new Private(dialog))
64 {
65 if (d->iface)
66 {
67 d->albumSelector = d->iface->albumChooser(this);
68
69 connect(d->iface, SIGNAL(signalAlbumChooserSelectionChanged()),
70 this, SIGNAL(completeChanged()));
71 }
72 else
73 {
74 d->albumSelector = new QWidget(this);
75 }
76
77 setPageWidget(d->albumSelector);
78 setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-pictures")));
79 }
80
~VidSlideAlbumsPage()81 VidSlideAlbumsPage::~VidSlideAlbumsPage()
82 {
83 delete d;
84 }
85
validatePage()86 bool VidSlideAlbumsPage::validatePage()
87 {
88 if (!d->iface)
89 return false;
90
91 if (d->iface && d->iface->albumChooserItems().isEmpty())
92 return false;
93
94 d->wizard->settings()->inputImages.clear();
95
96 // update image list with album contents.
97 foreach (const QUrl& url, d->iface->albumsItems(d->iface->albumChooserItems()))
98 {
99 d->wizard->settings()->inputImages << url;
100 }
101
102 return true;
103 }
104
isComplete() const105 bool VidSlideAlbumsPage::isComplete() const
106 {
107 if (!d->iface)
108 return false;
109
110 return (!d->iface->albumChooserItems().isEmpty());
111 }
112
113 } // namespace DigikamGenericVideoSlideShowPlugin
114