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 "clipproperties.h"
41 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent): QDialog(parent), m_tc(tc), m_clip(clip), m_fps(fps) {
42 setFont(KGlobalSettings::toolBarFont());
44 KUrl url = m_clip->fileURL();
45 m_view.clip_path->setText(url.path());
46 m_view.clip_description->setText(m_clip->description());
47 QMap <QString, QString> props = m_clip->properties();
49 if (props.contains("audiocodec"))
50 m_view.clip_acodec->setText(props.value("audiocodec"));
51 if (props.contains("frequency"))
52 m_view.clip_frequency->setText(props.value("frequency"));
53 if (props.contains("channels"))
54 m_view.clip_channels->setText(props.value("channels"));
56 CLIPTYPE t = m_clip->clipType();
58 m_view.clip_path->setEnabled(false);
59 m_view.tabWidget->removeTab(SLIDETAB);
60 m_view.tabWidget->removeTab(AUDIOTAB);
61 m_view.tabWidget->removeTab(VIDEOTAB);
62 m_view.clip_thumb->setHidden(true);
63 m_view.clip_color->setColor(QColor("#" + props.value("colour").right(8).left(6)));
65 else if (t == SLIDESHOW) {
66 m_view.tabWidget->removeTab(COLORTAB);
67 m_view.tabWidget->removeTab(AUDIOTAB);
68 m_view.tabWidget->removeTab(VIDEOTAB);
70 types << "JPG" << "PNG" << "BMP" << "GIF";
71 m_view.image_type->addItems(types);
72 m_view.slide_loop->setChecked(props.value("loop").toInt());
73 QString path = props.value("resource");
74 if (path.endsWith("png")) m_view.image_type->setCurrentIndex(TYPE_PNG);
75 else if (path.endsWith("bmp")) m_view.image_type->setCurrentIndex(TYPE_BMP);
76 else if (path.endsWith("gif")) m_view.image_type->setCurrentIndex(TYPE_GIF);
77 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
79 else if (t != AUDIO) {
80 m_view.tabWidget->removeTab(SLIDETAB);
81 m_view.tabWidget->removeTab(COLORTAB);
82 if (props.contains("frame_size"))
83 m_view.clip_size->setText(props.value("frame_size"));
84 if (props.contains("videocodec"))
85 m_view.clip_vcodec->setText(props.value("videocodec"));
86 if (props.contains("fps"))
87 m_view.clip_fps->setText(props.value("fps"));
88 if (props.contains("aspect_ratio"))
89 m_view.clip_ratio->setText(props.value("aspect_ratio"));
91 QPixmap pix = m_clip->thumbProducer()->getImage(url, 240, 180);
92 m_view.clip_thumb->setPixmap(pix);
93 if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
95 m_view.tabWidget->removeTab(SLIDETAB);
96 m_view.tabWidget->removeTab(COLORTAB);
97 m_view.tabWidget->removeTab(VIDEOTAB);
98 m_view.clip_thumb->setHidden(true);
100 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
102 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
103 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
104 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration(), m_fps));
108 int ClipProperties::clipId() {
109 return m_clip->getId();
113 QMap <QString, QString> ClipProperties::properties() {
114 QMap <QString, QString> props;
115 props["description"] = m_view.clip_description->text();
116 CLIPTYPE t = m_clip->clipType();
117 if (t == SLIDESHOW) {
118 props["loop"] = QString::number((int) m_view.slide_loop->isChecked());
120 else if (t == COLOR) {
121 QMap <QString, QString> old_props = m_clip->properties();
122 QString new_color = m_view.clip_color->color().name();
123 if (new_color != QString("#" + old_props.value("colour").right(8).left(6)))
124 props["colour"] = "0x" + new_color.right(6) + "ff";
129 #include "clipproperties.moc"