Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Restore Project option "Switch project profile to current clip"

parent 468b99f7
......@@ -3094,3 +3094,17 @@ QString Bin::getCurrentFolder()
}
return parentFolder->clipId();
}
void Bin::adjustProjectProfileToItem()
{
QModelIndex current = m_proxyModel->selectionModel()->currentIndex();
if (current.isValid()) {
// User clicked in the icon, open clip properties
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(current));
auto clip = std::static_pointer_cast<ProjectClip>(item);
if (clip) {
QDomDocument doc;
LoadJob::checkProfile(clip->clipId(), clip->toXml(doc, false), clip->originalProducer());
}
}
}
......@@ -363,6 +363,8 @@ public slots:
int getClipDuration(int itemId) const;
/** @brief Returns the state of a given clip: AudioOnly, VideoOnly, Disabled (Disabled means it has audio and video capabilities */
PlaylistState::ClipState getClipState(int itemId) const;
/** @brief Adjust project profile to current clip. */
void adjustProjectProfileToItem();
protected:
/* This function is called whenever an item is selected to propagate signals
......
......@@ -141,15 +141,15 @@ std::shared_ptr<Mlt::Producer> LoadJob::loadPlaylist(QString &resource)
return std::make_shared<Mlt::Producer>(pCore->getCurrentProfile()->profile(), nullptr, resource.toUtf8().constData());
}
void LoadJob::checkProfile()
void LoadJob::checkProfile(const QString clipId, QDomElement xml, std::shared_ptr<Mlt::Producer> producer)
{
// Check if clip profile matches
QString service = m_producer->get("mlt_service");
QString service = producer->get("mlt_service");
// Check for image producer
if (service == QLatin1String("qimage") || service == QLatin1String("pixbuf")) {
// This is an image, create profile from image size
int width = m_producer->get_int("meta.media.width");
int height = m_producer->get_int("meta.media.height");
int width = producer->get_int("meta.media.width");
int height = producer->get_int("meta.media.height");
if (width > 100 && height > 100) {
std::unique_ptr<ProfileParam> projectProfile(new ProfileParam(pCore->getCurrentProfile().get()));
projectProfile->m_width = width;
......@@ -159,14 +159,14 @@ void LoadJob::checkProfile()
projectProfile->m_display_aspect_num = width;
projectProfile->m_display_aspect_den = height;
projectProfile->m_description.clear();
pCore->currentDoc()->switchProfile(projectProfile, m_clipId, m_xml);
pCore->currentDoc()->switchProfile(projectProfile, clipId, xml);
} else {
// Very small image, we probably don't want to use this as profile
}
} else if (service.contains(QStringLiteral("avformat"))) {
std::unique_ptr<Mlt::Profile> blankProfile(new Mlt::Profile());
blankProfile->set_explicit(0);
blankProfile->from_producer(*m_producer);
blankProfile->from_producer(*producer);
std::unique_ptr<ProfileParam> clipProfile(new ProfileParam(blankProfile.get()));
std::unique_ptr<ProfileParam> projectProfile(new ProfileParam(pCore->getCurrentProfile().get()));
clipProfile->adjustWidth();
......@@ -177,7 +177,7 @@ void LoadJob::checkProfile()
}
} else {
// Profiles do not match, propose profile adjustment
pCore->currentDoc()->switchProfile(clipProfile, m_clipId, m_xml);
pCore->currentDoc()->switchProfile(clipProfile, clipId, xml);
}
}
}
......@@ -527,7 +527,7 @@ bool LoadJob::commitResult(Fun &undo, Fun &redo)
return false;
}
if (m_xml.hasAttribute(QStringLiteral("_checkProfile")) && m_producer->get_int("video_index") > -1) {
checkProfile();
checkProfile(m_clipId, m_xml, m_producer);
}
if (m_video_list.size() > 1) {
processMultiStream();
......
......@@ -53,6 +53,9 @@ public:
By design, the job should store the result of the computation but not share it with the rest of the code. This happens when we call commitResult */
bool commitResult(Fun &undo, Fun &redo) override;
// Do some checks on the profile
static void checkProfile(const QString clipId, QDomElement xml, std::shared_ptr<Mlt::Producer> producer);
protected:
// helper to load some kind of resources such as color. This will modify resource if needs be (for eg., in the case of color, it will prepend "color:" if
// needed)
......@@ -60,9 +63,6 @@ protected:
std::shared_ptr<Mlt::Producer> loadPlaylist(QString &resource);
// Do some checks on the profile
void checkProfile();
// Create the required filter for a slideshow
void processSlideShow();
......
......@@ -1124,8 +1124,7 @@ void MainWindow::setupActions()
addAction(QStringLiteral("project_clean"), i18n("Clean Project"), this, SLOT(slotCleanProject()), QIcon::fromTheme(QStringLiteral("edit-clear")));
// TODO
// addAction("project_adjust_profile", i18n("Adjust Profile to Current Clip"), pCore->bin(), SLOT(adjustProjectProfileToItem()));
addAction("project_adjust_profile", i18n("Adjust Profile to Current Clip"), pCore->bin(), SLOT(adjustProjectProfileToItem()));
m_playZone = addAction(QStringLiteral("monitor_play_zone"), i18n("Play Zone"), pCore->monitorManager(), SLOT(slotPlayZone()),
QIcon::fromTheme(QStringLiteral("media-playback-start")), Qt::CTRL + Qt::Key_Space);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment