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()));
43 m_view.image_type->addItem("JPG");
44 m_view.image_type->addItem("PNG");
45 m_view.image_type->addItem("BMP");
46 m_view.image_type->addItem("GIF");
47 m_view.clip_duration->setText("00:00:03:00");
48 m_view.folder_url->setUrl(QDir::homePath());
52 void SlideshowClip::parseFolder() {
53 m_view.icon_list->clear();
54 QDir dir(m_view.folder_url->url().path());
57 switch (m_view.image_type->currentIndex()) {
68 filters << "*.jpg" << "*.jpeg";
72 dir.setNameFilters(filters);
73 QStringList result = dir.entryList(QDir::Files);
74 m_count = result.count();
75 if (m_count == 0) m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
76 else m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
77 m_view.label_info->setText(i18n("%1 images found", m_count));
78 foreach(const QString &path, result) {
79 QIcon icon(dir.filePath(path));
80 QListWidgetItem *item = new QListWidgetItem(icon, KUrl(path).fileName());
81 m_view.icon_list->addItem(item);
85 QString SlideshowClip::selectedPath() const {
87 switch (m_view.image_type->currentIndex()) {
89 extension = "/.all.png";
92 extension = "/.all.bmp";
95 extension = "/.all.gif";
98 extension = "/.all.jpg";
101 return m_view.folder_url->url().path() + extension;
105 QString SlideshowClip::clipName() const {
106 return m_view.clip_name->text();
109 QString SlideshowClip::clipDuration() const {
110 return m_view.clip_duration->text();
113 int SlideshowClip::imageCount() const {
117 bool SlideshowClip::loop() const {
118 return m_view.slide_loop->isChecked();
120 #include "slideshowclip.moc"