]> git.sesse.net Git - kdenlive/blob - src/slideshowclip.cpp
*Re-introduce slideshow clips
[kdenlive] / src / slideshowclip.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20 #include <QDir>
21
22 #include <KStandardDirs>
23 #include <KDebug>
24 #include <KFileItem>
25
26 #include "kdenlivesettings.h"
27 #include "slideshowclip.h"
28
29 #define TYPE_JPEG 0
30 #define TYPE_PNG 1
31 #define TYPE_BMP 2
32 #define TYPE_GIF 3
33
34 SlideshowClip::SlideshowClip(QWidget * parent): QDialog(parent), m_count(0) {
35     setFont(KGlobalSettings::toolBarFont());
36     //wsetCaption(i18n("Add Slideshow Clip"));
37     m_view.setupUi(this);
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     adjustSize();
49 }
50
51 void SlideshowClip::parseFolder() {
52     m_view.icon_list->clear();
53     QDir dir(m_view.folder_url->url().path());
54     QStringList filters;
55     switch (m_view.image_type->currentIndex()) {
56         case TYPE_PNG:
57             filters << "*.png"; 
58             break;
59         case TYPE_BMP:
60             filters << "*.bmp"; 
61             break;
62         case TYPE_GIF:
63             filters << "*.gif"; 
64             break;
65         default:
66             filters << "*.jpg" << "*.jpeg";     
67             break;
68     }
69
70     dir.setNameFilters(filters);
71     QStringList result = dir.entryList(QDir::Files);
72     m_count = result.count();
73     m_view.label_info->setText(i18n("%1 images found", m_count));
74     foreach (QString path, result) {
75         QIcon icon(dir.filePath(path));
76         QListWidgetItem *item = new QListWidgetItem(icon, KUrl(path).fileName());
77         m_view.icon_list->addItem(item);
78     }
79 }
80
81 QString SlideshowClip::selectedPath() const {
82     QString extension;
83     switch (m_view.image_type->currentIndex()) {
84         case TYPE_PNG:
85             extension = "/.all.png";    
86             break;
87         case TYPE_BMP:
88             extension = "/.all.bmp";    
89             break;
90         case TYPE_GIF:
91             extension = "/.all.gif";    
92             break;
93         default:
94             extension = "/.all.jpg";    
95             break;
96     }
97     return m_view.folder_url->url().path() + extension;
98 }
99
100
101 QString SlideshowClip::clipName() const {
102     return m_view.clip_name->text();
103 }
104
105 QString SlideshowClip::clipDuration() const {
106     return m_view.clip_duration->text();
107 }
108
109 int SlideshowClip::imageCount() const {
110     return m_count;
111 }
112
113 bool SlideshowClip::loop() const {
114     return m_view.slide_loop->isChecked();
115 }
116 #include "slideshowclip.moc"
117
118