]> git.sesse.net Git - kdenlive/blobdiff - src/clipproperties.cpp
Integrate with the required MLT hooks for getting Movit to work.
[kdenlive] / src / clipproperties.cpp
index a9e6afe6e9e235af49cd32ce18f1310540140f26..05984890d3cea096b4561ded8c86da18066e5fe8 100644 (file)
 #include <KRun>
 
 #ifdef USE_NEPOMUK
-#if KDE_IS_VERSION(4,6,0)
-#include <Nepomuk/Variant>
-#include <Nepomuk/Resource>
-#include <Nepomuk/ResourceManager>
-#include <Nepomuk/Vocabulary/NIE>
-#endif
+  #if KDE_IS_VERSION(4,6,0)
+    #include <Nepomuk/Variant>
+    #include <Nepomuk/Resource>
+    #include <Nepomuk/ResourceManager>
+    #include <Nepomuk/Vocabulary/NIE>
+  #endif
 #endif
 #ifdef USE_NEPOMUKCORE
-#include <Nepomuk2/Variant>
-#include <Nepomuk2/Resource>
-#include <Nepomuk2/ResourceManager>
-#include <Nepomuk2/Vocabulary/NIE>
+  #include <Nepomuk2/Variant>
+  #include <Nepomuk2/Resource>
+  #include <Nepomuk2/ResourceManager>
+  #include <Nepomuk2/Vocabulary/NIE>
 #endif
 
 
@@ -209,8 +209,9 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         QStringList values = i.value();
         QString parentName;
         QString iconName;
-        if (values.count() > 1 && !values.at(1).isEmpty()) parentName = values.at(1);
-        else {
+        if (values.count() > 1 && !values.at(1).isEmpty()) {
+            parentName = values.at(1);
+        } else {
             if (KdenliveSettings::ffmpegpath().endsWith("avconv")) {
                 parentName = i18n("Libav");
                 iconName = "meta_libav.png";
@@ -222,9 +223,11 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         }
         QTreeWidgetItem *parent = NULL;
         QList <QTreeWidgetItem *> matches = m_view.metadata_list->findItems(parentName, Qt::MatchExactly);
-        if (!matches.isEmpty()) parent = matches.at(0);
-        else {
-            if (parentName == "Magic Lantern") iconName = "meta_magiclantern.png";
+        if (!matches.isEmpty()) {
+            parent = matches.at(0);
+        } else {
+            if (parentName == "Magic Lantern")
+                iconName = "meta_magiclantern.png";
             parent = new QTreeWidgetItem(m_view.metadata_list, QStringList() << parentName);
             if (!iconName.isEmpty()) {
                 KIcon icon(KStandardDirs::locate("appdata", iconName));
@@ -262,7 +265,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
     
 
-    CLIPTYPE t = m_clip->clipType();
+    ClipType t = m_clip->clipType();
     
     if (props.contains("proxy") && props.value("proxy") != "-") {
         KFileItem f(KFileItem::Unknown, KFileItem::Unknown, KUrl(props.value("proxy")), true);
@@ -278,11 +281,11 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         l->addWidget(pb);
         connect(pb, SIGNAL(clicked()), this, SLOT(slotDeleteProxy()));
         m_proxyContainer->setLayout(l);
-        if (t == IMAGE) {
+        if (t == Image) {
             m_view.tab_image->layout()->addWidget(line);
             m_view.tab_image->layout()->addWidget(m_proxyContainer);
         }
-        else if (t == AUDIO) {
+        else if (t == Audio) {
             m_view.tab_audio->layout()->addWidget(line);
             m_view.tab_audio->layout()->addWidget(m_proxyContainer);
         }
@@ -292,18 +295,18 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         }
     }
     
-    if (t != AUDIO && t != AV) {
+    if (t != Audio && t != AV) {
         m_view.clip_force_aindex->setEnabled(false);
     }
 
-    if (t != VIDEO && t != AV) {
+    if (t != Video && t != AV) {
         m_view.clip_force_vindex->setEnabled(false);
     }
 
-    if (t == PLAYLIST)
+    if (t == Playlist)
         m_view.tabWidget->setTabText(VIDEOTAB, i18n("Playlist"));
 
-    if (t == IMAGE) {
+    if (t == Image) {
         m_view.tabWidget->removeTab(SLIDETAB);
         m_view.tabWidget->removeTab(COLORTAB);
         m_view.tabWidget->removeTab(AUDIOTAB);
@@ -314,9 +317,10 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
             m_view.image_transparency->setChecked(props.value("transparency").toInt());
         connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
         int width = 180.0 * KdenliveSettings::project_display_ratio();
-        if (width % 2 == 1) width++;
+        if (width % 2 == 1)
+            width++;
         m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
-    } else if (t == COLOR) {
+    } else if (t == Color) {
         m_view.clip_path->setEnabled(false);
         m_view.tabWidget->removeTab(METATAB);
         m_view.tabWidget->removeTab(IMAGETAB);
@@ -326,8 +330,8 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         m_view.clip_thumb->setHidden(true);
         m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
         connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
-    } else if (t == SLIDESHOW) {
-        if (url.fileName().startsWith(".all.")) {
+    } else if (t == SlideShow) {
+        if (url.fileName().startsWith(QLatin1String(".all."))) {
             // the image sequence is defined by mimetype
             m_view.clip_path->setText(url.directory());
         } else {
@@ -437,7 +441,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
         connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
 
-    } else if (t != AUDIO) {
+    } else if (t != Audio) {
         m_view.tabWidget->removeTab(IMAGETAB);
         m_view.tabWidget->removeTab(SLIDETAB);
         m_view.tabWidget->removeTab(COLORTAB);
@@ -452,7 +456,8 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         
         m_view.clip_thumb->setMinimumSize(180 * KdenliveSettings::project_display_ratio(), 180);
         
-        if (t == IMAGE || t == VIDEO || t == PLAYLIST) m_view.tabWidget->removeTab(AUDIOTAB);
+        if (t == Image || t == Video || t == Playlist)
+            m_view.tabWidget->removeTab(AUDIOTAB);
     } else {
         m_view.tabWidget->removeTab(IMAGETAB);
         m_view.tabWidget->removeTab(SLIDETAB);
@@ -461,7 +466,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         m_view.clip_thumb->setHidden(true);
     }
 
-    if (t != SLIDESHOW && t != COLOR) {
+    if (t != SlideShow && t != Color) {
         KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
         m_view.clip_filesize->setText(KIO::convertSize(f.size()));
     } else {
@@ -470,8 +475,9 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
     }
     m_view.clip_duration->setInputMask(tc.mask());
     m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
-    if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
-    else {
+    if (t != Image && t != Color && t != Text) {
+        m_view.clip_duration->setReadOnly(true);
+    } else {
         connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
         connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
     }
@@ -496,8 +502,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
 
     // Check for Nepomuk metadata
 #ifdef USE_NEPOMUK
-
-#if KDE_IS_VERSION(4,6,0)
+  #if KDE_IS_VERSION(4,6,0)
     if (!url.isEmpty()) {
         Nepomuk::ResourceManager::instance()->init();
         Nepomuk::Resource res( url.path() );
@@ -513,13 +518,11 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         else m_view.clip_license->setHidden(true);
     }
     else m_view.clip_license->setHidden(true);
-#else
+  #else
     m_view.clip_license->setHidden(true);
-#endif
-
+  #endif
 #else
-
-#ifdef USE_NEPOMUKCORE
+  #ifdef USE_NEPOMUKCORE
 
     if (!url.isEmpty()) {
         Nepomuk2::ResourceManager::instance()->init();
@@ -536,10 +539,9 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
         else m_view.clip_license->setHidden(true);
     }
     else m_view.clip_license->setHidden(true);
-#else
+  #else
     m_view.clip_license->setHidden(true);
-#endif
-
+  #endif
 #endif
 
     slotFillMarkersList(m_clip);
@@ -702,7 +704,9 @@ ClipProperties::ClipProperties(const QList <DocClipBase *> &cliplist, const Time
         if (commonproperties.value("out").toInt() > 0) {
             m_view.clip_force_out->setChecked(true);
             m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
-        } else m_view.clip_out->setText(KdenliveSettings::image_duration());
+        } else {
+            m_view.clip_out->setText(KdenliveSettings::image_duration());
+        }
     } else {
         m_view.clip_force_out->setHidden(true);
         m_view.clip_out->setHidden(true);
@@ -752,7 +756,8 @@ void ClipProperties::loadVideoProperties(const QMap <QString, QString> &props)
 
 void ClipProperties::slotGotThumbnail(const QString &id, const QImage &img)
 {
-    if (id != m_clip->getId()) return;
+    if (id != m_clip->getId())
+        return;
     QPixmap framedPix(img.width(), img.height());
     framedPix.fill(Qt::transparent);
     QPainter p(&framedPix);
@@ -779,13 +784,15 @@ void ClipProperties::slotApplyProperties()
 
 void ClipProperties::slotReloadVideoProperties()
 {
-    if (m_clip == NULL) return;
+    if (m_clip == NULL)
+        return;
     loadVideoProperties(m_clip->properties());
 }
 
 void ClipProperties::slotReloadVideoThumb()
 {
-    if (m_clip == NULL) return;
+    if (m_clip == NULL)
+        return;
     emit requestThumb(QString('?' + m_clip->getId()), QList<int>() << m_clip->getClipThumbFrame());
 }
 
@@ -915,8 +922,9 @@ void ClipProperties::slotDeleteAnalysis()
 
 void ClipProperties::slotSaveAnalysis()
 {
-    QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
-    if (url.isEmpty()) return;
+    const QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
+    if (url.isEmpty())
+        return;
     KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
     KConfigGroup analysisConfig(config, "Analysis");
     QTreeWidgetItem *current = m_view.analysis_list->currentItem();
@@ -925,8 +933,9 @@ void ClipProperties::slotSaveAnalysis()
 
 void ClipProperties::slotLoadAnalysis()
 {
-    QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
-    if (url.isEmpty()) return;
+    const QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
+    if (url.isEmpty())
+        return;
     KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
     KConfigGroup transConfig(config, "Analysis");
     // read the entries
@@ -947,7 +956,7 @@ QMap <QString, QString> ClipProperties::properties()
 {
     QMap <QString, QString> props;
     QLocale locale;
-    CLIPTYPE t = UNKNOWN;
+    ClipType t = Unknown;
     if (m_clip != NULL) {
         t = m_clip->clipType();
         m_old_props = m_clip->properties();
@@ -1068,7 +1077,7 @@ QMap <QString, QString> ClipProperties::properties()
     if (m_old_props.value("description") != m_view.clip_description->text())
         props["description"] = m_view.clip_description->text();
 
-    if (t == COLOR) {
+    if (t == Color) {
         QString new_color = m_view.clip_color->color().name();
         if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
             m_clipNeedsRefresh = true;
@@ -1078,7 +1087,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (duration != m_clip->duration().frames(m_fps)) {
             props["out"] = QString::number(duration - 1);
         }
-    } else if (t == IMAGE) {
+    } else if (t == Image) {
         if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
             props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
             //m_clipNeedsRefresh = true;
@@ -1087,7 +1096,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (duration != m_clip->duration().frames(m_fps)) {
             props["out"] = QString::number(duration - 1);
         }
-    } else if (t == SLIDESHOW) {
+    } else if (t == SlideShow) {
         QString value = QString::number((int) m_view.slide_loop->isChecked());
         if (m_old_props.value("loop") != value) props["loop"] = value;
         value = QString::number((int) m_view.slide_crop->isChecked());
@@ -1240,8 +1249,9 @@ void ClipProperties::parseFolder(bool reloadThumb)
 
 void ClipProperties::slotCheckMaxLength()
 {
-    if (m_clip->maxDuration() == GenTime()) return;
-    int duration = m_tc.getFrameCount(m_view.clip_duration->text());
+    if (m_clip->maxDuration() == GenTime())
+        return;
+    const int duration = m_tc.getFrameCount(m_view.clip_duration->text());
     if (duration > m_clip->maxDuration().frames(m_fps)) {
         m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
     }
@@ -1249,7 +1259,7 @@ void ClipProperties::slotCheckMaxLength()
 
 void ClipProperties::slotUpdateDurationFormat(int ix)
 {
-    bool framesFormat = ix == 1;
+    bool framesFormat = (ix == 1);
     if (framesFormat) {
         // switching to frames count, update widget
         m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
@@ -1271,10 +1281,11 @@ void ClipProperties::slotUpdateDurationFormat(int ix)
 
 void ClipProperties::slotDeleteProxy()
 {
-    QString proxy = m_clip->getProperty("proxy");
-    if (proxy.isEmpty()) return;
+    const QString proxy = m_clip->getProperty("proxy");
+    if (proxy.isEmpty())
+        return;
     emit deleteProxy(proxy);
-    if (m_proxyContainer) delete m_proxyContainer;
+    delete m_proxyContainer;
 }
 
 void ClipProperties::slotOpenUrl(const QString &url)