1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include <KStandardDirs>
26 #include "kdenlivesettings.h"
27 #include "slideshowclip.h"
34 SlideshowClip::SlideshowClip(QWidget * parent): QDialog(parent), m_count(0) {
35 setFont(KGlobalSettings::toolBarFont());
36 setWindowTitle(i18n("Add Slideshow Clip"));
38 m_view.clip_name->setText(i18n("Slideshow Clip"));
39 m_view.folder_url->setMode(KFile::Directory);
40 m_view.icon_list->setIconSize(QSize(50, 50));
41 connect(m_view.folder_url, SIGNAL(textChanged(const QString &)), this, SLOT(parseFolder()));
42 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
44 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
45 connect(m_view.luma_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
47 m_view.image_type->addItem("JPG");
48 m_view.image_type->addItem("PNG");
49 m_view.image_type->addItem("BMP");
50 m_view.image_type->addItem("GIF");
51 m_view.clip_duration->setText(KdenliveSettings::image_duration());
52 m_view.luma_duration->setText("00:00:00:24");
53 m_view.folder_url->setUrl(QDir::homePath());
56 QString profilePath = KdenliveSettings::mltpath();
57 profilePath = profilePath.section('/', 0, -3);
58 profilePath += "/lumas/PAL/";
60 QDir dir(profilePath);
63 const QStringList result = dir.entryList(filter, QDir::Files);
64 QStringList imagefiles;
65 QStringList imagenamelist;
66 foreach(const QString file, result) {
67 m_view.luma_file->addItem(KIcon(profilePath + file), file, profilePath + file);
73 void SlideshowClip::slotEnableLuma(int state) {
75 if (state == Qt::Checked) enable = true;
76 m_view.luma_duration->setEnabled(enable);
77 m_view.luma_fade->setEnabled(enable);
78 if (enable) m_view.luma_file->setEnabled(m_view.luma_fade->isChecked());
79 else m_view.luma_file->setEnabled(false);
82 void SlideshowClip::slotEnableLumaFile(int state) {
84 if (state == Qt::Checked) enable = true;
85 m_view.luma_file->setEnabled(enable);
86 m_view.luma_softness->setEnabled(enable);
87 m_view.label_softness->setEnabled(enable);
90 void SlideshowClip::parseFolder() {
91 m_view.icon_list->clear();
92 QDir dir(m_view.folder_url->url().path());
95 switch (m_view.image_type->currentIndex()) {
106 filters << "*.jpg" << "*.jpeg";
110 dir.setNameFilters(filters);
111 const QStringList result = dir.entryList(QDir::Files);
112 m_count = result.count();
113 if (m_count == 0) m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
114 else m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
115 m_view.label_info->setText(i18n("%1 images found", m_count));
116 foreach(const QString &path, result) {
117 QIcon icon(dir.filePath(path));
118 QListWidgetItem *item = new QListWidgetItem(icon, KUrl(path).fileName());
119 m_view.icon_list->addItem(item);
123 QString SlideshowClip::selectedPath() const {
125 switch (m_view.image_type->currentIndex()) {
127 extension = "/.all.png";
130 extension = "/.all.bmp";
133 extension = "/.all.gif";
136 extension = "/.all.jpg";
139 return m_view.folder_url->url().path() + extension;
143 QString SlideshowClip::clipName() const {
144 return m_view.clip_name->text();
147 QString SlideshowClip::clipDuration() const {
148 return m_view.clip_duration->text();
151 int SlideshowClip::imageCount() const {
155 int SlideshowClip::softness() const {
156 return m_view.luma_softness->value();
159 bool SlideshowClip::loop() const {
160 return m_view.slide_loop->isChecked();
163 bool SlideshowClip::fade() const {
164 return m_view.slide_fade->isChecked();
167 QString SlideshowClip::lumaDuration() const {
168 return m_view.luma_duration->text();
171 QString SlideshowClip::lumaFile() const {
172 if (!m_view.luma_fade->isChecked() || !m_view.luma_file->isEnabled()) return QString();
173 return m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
176 #include "slideshowclip.moc"