X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.cpp;h=8264afeec9aec3f7f37a8071e7d830c30aaf7f1a;hb=ad714e626d37b94307a43df649cc800e8dac9045;hp=35bec5148f529003227e6aca0013525cc869a47f;hpb=8cc84073a91a888c89cfeb5e3aa7e658354f683d;p=kdenlive diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 35bec514..8264afee 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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" @@ -63,19 +64,19 @@ #include 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))); } } @@ -1058,7 +1059,7 @@ QString ProjectList::getExtensions() << "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 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 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 (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());