]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Fix indentation mess from my previous commit. Improve detection of matching profile...
[kdenlive] / src / projectlist.cpp
index 9899268e50b9a3b8a55f38ea5d620d49ed3b65f8..8264afeec9aec3f7f37a8071e7d830c30aaf7f1a 100644 (file)
@@ -32,6 +32,7 @@
 #include "kthumb.h"
 #include "projectlistview.h"
 #include "timecodedisplay.h"
+#include "profilesdialog.h"
 #include "editclipcommand.h"
 #include "editclipcutcommand.h"
 #include "editfoldercommand.h"
 #include <QInputDialog>
 
 ProjectList::ProjectList(QWidget *parent) :
-        QWidget(parent),
-        m_render(NULL),
-        m_fps(-1),
-        m_commandStack(NULL),
-        m_editAction(NULL),
-        m_deleteAction(NULL),
-        m_openAction(NULL),
-        m_reloadAction(NULL),
-        m_transcodeAction(NULL),
-        m_doc(NULL),
-        m_refreshed(false),
-        m_infoQueue(),
-        m_thumbnailQueue()
+    QWidget(parent),
+    m_render(NULL),
+    m_fps(-1),
+    m_commandStack(NULL),
+    m_editAction(NULL),
+    m_deleteAction(NULL),
+    m_openAction(NULL),
+    m_reloadAction(NULL),
+    m_transcodeAction(NULL),
+    m_doc(NULL),
+    m_refreshed(false),
+    m_infoQueue(),
+    m_thumbnailQueue()
 {
 
     m_listView = new ProjectListView(this);;
@@ -559,9 +560,9 @@ void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
         if (data.count() > 2) {
             condition = data.at(2);
             if (condition.startsWith("vcodec"))
-                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
+                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section('=', 1, 1)));
             else if (condition.startsWith("acodec"))
-                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
+                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section('=', 1, 1)));
         }
     }
 
@@ -1054,11 +1055,11 @@ QString ProjectList::getExtensions()
     // Build list of mime types
     QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"
                             << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime"
-                            << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg"
+                            << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg" << "application/mxf"
                             << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
 
     QString allExtensions;
-    foreach(const QString& mimeType, mimeTypes) {
+    foreach(const QString & mimeType, mimeTypes) {
         KMimeType::Ptr mime(KMimeType::mimeType(mimeType));
         if (mime) {
             allExtensions.append(mime->patterns().join(" "));
@@ -1092,7 +1093,7 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
                 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
                 if (item.mimetype().startsWith("image")) {
                     int count = 0;
-                    // import as sequence if we found at least 5 images in the sequence
+                    // import as sequence if we found more than one image in the sequence
                     QString pattern = SlideshowClip::selectedPath(url.path(), false, QString(), &count);
                     if (count > 1) {
                         delete d;
@@ -1118,7 +1119,7 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
             list << givenList.at(i);
     }
 
-    foreach(const KUrl &file, list) {
+    foreach(const KUrl & file, list) {
         // Check there is no folder here
         KMimeType::Ptr type = KMimeType::findByUrl(file);
         if (type->is("inode/directory")) {
@@ -1475,6 +1476,32 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         if (item->parent()) {
             if (item->parent()->type() == PROJECTFOLDERTYPE)
                 static_cast <FolderProjectItem *>(item->parent())->switchIcon();
+        } else if (KdenliveSettings::checkfirstprojectclip() &&  m_listView->topLevelItemCount() == 1) {
+            // this is the first clip loaded in project, check if we want to adjust project settings to the clip
+            int width = properties.value("frame_size").section('x', 0, 0).toInt();
+            int height = properties.value("frame_size").section('x', -1).toInt();
+            double fps = properties.value("fps").toDouble();
+            int renderWidth = -1;
+            int renderHeight = -1;
+            double renderFps = -1;
+            if (item->clipType() == IMAGE) {
+                renderWidth = m_doc->renderer()->renderWidth();
+                renderHeight = m_doc->height();
+            } else if (item->clipType() == AV || item->clipType() == VIDEO) {
+                renderWidth = m_doc->width();
+                renderHeight = m_doc->height();
+                renderFps = m_doc->fps();
+            }
+            if ((renderWidth > 0 && width != renderWidth) || (renderHeight > 0 && height != renderHeight) || (renderFps > 0 && qAbs(fps - renderFps) > 0.5)) {
+                QString suggestedProfile = ProfilesDialog::getPathFromProperties(width, height, fps, item->clipType() == IMAGE);
+                if (!suggestedProfile.isEmpty()) {
+                    QString description = ProfilesDialog::getSettingsFromFile(suggestedProfile).value("description");
+                    if (KMessageBox::questionYesNo(this, i18n("Your clip does not match current project's profile.\nDo you want to adjust the profile (clip size: %1, fps: %2)?\nSuggested profile is %3", properties.value("frame_size"), fps, description)) == KMessageBox::Yes) {
+                        //Change project profile
+                        emit updateProfile(suggestedProfile);
+                    }
+                } else KMessageBox::information(this, i18n("Your clip does not match current project's profile.\nNo existing profile found to match the clip's properties.\nClip size: %1\nFps: %2\n", properties.value("frame_size"), fps));
+            }
         }
         emit clipSelected(item->referencedClip());
     } else {
@@ -1621,9 +1648,9 @@ KUrl::List ProjectList::getConditionalUrls(const QString &condition) const
             continue;
         DocClipBase *clip = item->referencedClip();
         if (!condition.isEmpty()) {
-            if (condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section("=", 1, 1)))
+            if (condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section('=', 1, 1)))
                 continue;
-            else if (condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section("=", 1, 1)))
+            else if (condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section('=', 1, 1)))
                 continue;
         }
         result.append(item->clipUrl());