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 "vidslidewizard.h"
24
25 // Qt includes
26
27 #include <QCheckBox>
28 #include <QLabel>
29 #include <QMenu>
30 #include <QApplication>
31 #include <QComboBox>
32 #include <QListWidget>
33 #include <QTextBrowser>
34
35 // KDE includes
36
37 #include <klocalizedstring.h>
38 #include <ksharedconfig.h>
39 #include <kconfiggroup.h>
40
41 // Local includes
42
43 #include "dwizardpage.h"
44 #include "digikam_debug.h"
45 #include "vidslideintropage.h"
46 #include "vidslidealbumspage.h"
47 #include "vidslideimagespage.h"
48 #include "vidslidevideopage.h"
49 #include "vidslideoutputpage.h"
50 #include "vidslidefinalpage.h"
51
52 namespace DigikamGenericVideoSlideShowPlugin
53 {
54
55 class Q_DECL_HIDDEN VidSlideWizard::Private
56 {
57 public:
58
Private()59 explicit Private()
60 : iface(nullptr),
61 introPage(nullptr),
62 albumsPage(nullptr),
63 imagesPage(nullptr),
64 videoPage(nullptr),
65 outputPage(nullptr),
66 finalPage(nullptr),
67 settings(nullptr)
68 {
69 }
70
71 DInfoInterface* iface;
72 VidSlideIntroPage* introPage;
73 VidSlideAlbumsPage* albumsPage;
74 VidSlideImagesPage* imagesPage;
75 VidSlideVideoPage* videoPage;
76 VidSlideOutputPage* outputPage;
77 VidSlideFinalPage* finalPage;
78 VidSlideSettings* settings;
79 };
80
VidSlideWizard(QWidget * const parent,DInfoInterface * const iface)81 VidSlideWizard::VidSlideWizard(QWidget* const parent, DInfoInterface* const iface)
82 : DWizardDlg(parent, QLatin1String("Video SlideShow Dialog")),
83 d(new Private)
84 {
85 setOption(QWizard::NoCancelButtonOnLastPage);
86 setWindowTitle(i18n("Create a Video Slideshow"));
87
88 d->iface = iface;
89 d->settings = new VidSlideSettings;
90
91 KSharedConfigPtr config = KSharedConfig::openConfig();
92 KConfigGroup group = config->group("Video SlideShow Dialog Settings");
93 d->settings->readSettings(group);
94
95 d->introPage = new VidSlideIntroPage(this, i18n("Welcome to Video Slideshow Tool"));
96 d->albumsPage = new VidSlideAlbumsPage(this, i18n("Albums Selection"));
97 d->imagesPage = new VidSlideImagesPage(this, i18n("Images List"));
98 d->videoPage = new VidSlideVideoPage(this, i18n("Video Settings"));
99 d->outputPage = new VidSlideOutputPage(this, i18n("Output Settings"));
100 d->finalPage = new VidSlideFinalPage(this, i18n("Generating Video Slideshow"));
101
102 connect(this, SIGNAL(currentIdChanged(int)),
103 this, SLOT(slotCurrentIdChanged(int)));
104 }
105
~VidSlideWizard()106 VidSlideWizard::~VidSlideWizard()
107 {
108 KSharedConfigPtr config = KSharedConfig::openConfig();
109 KConfigGroup group = config->group("Video SlideShow Dialog Settings");
110 d->settings->writeSettings(group);
111
112 delete d;
113 }
114
setItemsList(const QList<QUrl> & urls)115 void VidSlideWizard::setItemsList(const QList<QUrl>& urls)
116 {
117 d->imagesPage->setItemsList(urls);
118 }
119
iface() const120 DInfoInterface* VidSlideWizard::iface() const
121 {
122 return d->iface;
123 }
124
settings() const125 VidSlideSettings* VidSlideWizard::settings() const
126 {
127 return d->settings;
128 }
129
validateCurrentPage()130 bool VidSlideWizard::validateCurrentPage()
131 {
132 if (!DWizardDlg::validateCurrentPage())
133 return false;
134
135 return true;
136 }
137
nextId() const138 int VidSlideWizard::nextId() const
139 {
140 if (d->settings->selMode == VidSlideSettings::ALBUMS)
141 {
142 if (currentPage() == d->introPage)
143 return d->albumsPage->id();
144 }
145 else
146 {
147 if (currentPage() == d->introPage)
148 return d->imagesPage->id();
149 }
150
151 return DWizardDlg::nextId();
152 }
153
slotCurrentIdChanged(int id)154 void VidSlideWizard::slotCurrentIdChanged(int id)
155 {
156 if (page(id) == d->videoPage)
157 {
158 d->videoPage->slotTransitionChanged();
159 d->videoPage->slotEffectChanged();
160 }
161 }
162
163 } // namespace DigikamGenericVideoSlideShowPlugin
164