]> git.sesse.net Git - kdenlive/blob - src/clipproperties.cpp
9118efc54a0fc99b91f78ee084d6ee79267bb267
[kdenlive] / src / clipproperties.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 "clipproperties.h"
28 #include "kthumb.h"
29
30 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent): QDialog(parent), m_tc(tc), m_clip(clip), m_fps(fps) {
31     setFont(KGlobalSettings::toolBarFont());
32     m_view.setupUi(this);
33     KUrl url = m_clip->fileURL();
34     m_view.clip_path->setText(url.path());
35     m_view.clip_description->setText(m_clip->description());
36     QMap <QString, QString> props = m_clip->properties();
37
38     if (props.contains("audiocodec"))
39         m_view.clip_acodec->setText(props["audiocodec"]);
40     if (props.contains("frequency"))
41         m_view.clip_frequency->setText(props["frequency"]);
42     if (props.contains("channels"))
43         m_view.clip_channels->setText(props["channels"]);
44
45     CLIPTYPE t = m_clip->clipType();
46     if (t != AUDIO) {
47         if (props.contains("frame_size"))
48             m_view.clip_size->setText(props["frame_size"]);
49         if (props.contains("videocodec"))
50             m_view.clip_vcodec->setText(props["videocodec"]);
51         if (props.contains("fps"))
52             m_view.clip_fps->setText(props["fps"]);
53         if (props.contains("aspect_ratio"))
54             m_view.clip_ratio->setText(props["aspect_ratio"]);
55
56         QPixmap pix = m_clip->thumbProducer()->getImage(url, 240, 180);
57         m_view.clip_thumb->setPixmap(pix);
58         if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(1);
59     } else {
60         m_view.tabWidget->removeTab(0);
61         m_view.clip_thumb->setHidden(true);
62     }
63     if (t != IMAGE && t != COLOR) m_view.clip_duration->setReadOnly(true);
64
65     KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
66     m_view.clip_filesize->setText(KIO::convertSize(f.size()));
67     m_view.clip_duration->setText(tc.getTimecode(m_clip->duration(), m_fps));
68     adjustSize();
69 }
70
71 int ClipProperties::clipId() {
72     return m_clip->getId();
73 }
74
75 QMap <QString, QString> ClipProperties::properties() {
76     QMap <QString, QString> props;
77     props["description"] = m_view.clip_description->text();
78     return props;
79 }
80
81 #include "clipproperties.moc"
82
83