Save last used rendering profile in Kdenlive document

svn path=/trunk/kdenlive/; revision=3597
parent 9922eeca
......@@ -51,7 +51,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
QObject(parent),
m_autosave(NULL),
m_url(url),
m_zoom(7),
m_startPos(0),
m_render(render),
m_commandStack(new QUndoStack(undoGroup)),
......@@ -59,14 +58,18 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
m_projectFolder(projectFolder),
m_documentLoadingStep(0.0),
m_documentLoadingProgress(0),
m_abortLoading(false),
m_zoneStart(0),
m_zoneEnd(100)
m_abortLoading(false)
{
m_clipManager = new ClipManager(this);
m_autoSaveTimer = new QTimer(this);
m_autoSaveTimer->setSingleShot(true);
bool success = false;
// init default document properties
m_documentProperties["zoom"] = "7";
m_documentProperties["zonein"] = "0";
m_documentProperties["zoneout"] = "100";
if (!url.isEmpty()) {
QString tmpFile;
success = KIO::NetAccess::download(url.path(), tmpFile, parent);
......@@ -99,11 +102,13 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
profileName = infoXml.attribute("profile");
m_projectFolder = infoXml.attribute("projectfolder");
m_startPos = infoXml.attribute("position").toInt();
m_zoom = infoXml.attribute("zoom", "7").toInt();
m_zoneStart = infoXml.attribute("zonein", "0").toInt();
m_zoneEnd = infoXml.attribute("zoneout", "100").toInt();
QDomElement docproperties = infoXml.firstChildElement("documentproperties");
QDomNamedNodeMap props = docproperties.attributes();
for (int i = 0; i < props.count(); i++) {
m_documentProperties.insert(props.item(i).nodeName(), props.item(i).nodeValue());
}
// Build tracks
QDomElement e;
......@@ -387,23 +392,23 @@ void KdenliveDoc::slotAutoSave()
void KdenliveDoc::setZoom(int factor)
{
m_zoom = factor;
m_documentProperties["zoom"] = QString::number(factor);
}
int KdenliveDoc::zoom() const
{
return m_zoom;
return m_documentProperties.value("zoom").toInt();
}
void KdenliveDoc::setZone(int start, int end)
{
m_zoneStart = start;
m_zoneEnd = end;
m_documentProperties["zonein"] = QString::number(start);
m_documentProperties["zoneout"] = QString::number(end);
}
QPoint KdenliveDoc::zone() const
{
return QPoint(m_zoneStart, m_zoneEnd);
return QPoint(m_documentProperties.value("zonein").toInt(), m_documentProperties.value("zoneout").toInt());
}
bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
......@@ -419,10 +424,15 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
addedXml.setAttribute("kdenliveversion", VERSION);
addedXml.setAttribute("profile", profilePath());
addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
addedXml.setAttribute("zonein", m_zoneStart);
addedXml.setAttribute("zoneout", m_zoneEnd);
addedXml.setAttribute("projectfolder", m_projectFolder.path());
addedXml.setAttribute("zoom", m_zoom);
QDomElement docproperties = sceneList.createElement("documentproperties");
QMapIterator<QString, QString> i(m_documentProperties);
while (i.hasNext()) {
i.next();
docproperties.setAttribute(i.key(), i.value());
}
addedXml.appendChild(docproperties);
// Add profile info
QDomElement profileinfo = sceneList.createElement("profileinfo");
......@@ -1186,6 +1196,15 @@ bool KdenliveDoc::checkDocumentClips(QDomNodeList infoproducers)
return (d.exec() == QDialog::Accepted);
}
void KdenliveDoc::setDocumentProperty(const QString &name, const QString &value)
{
m_documentProperties[name] = value;
}
const QString KdenliveDoc::getDocumentProperty(const QString &name) const
{
return m_documentProperties.value(name);
}
#include "kdenlivedoc.moc"
......@@ -113,12 +113,13 @@ Q_OBJECT public:
void setSceneList();
void updatePreviewSettings();
bool isTrackLocked(int ix) const;
void setDocumentProperty(const QString &name, const QString &value);
const QString getDocumentProperty(const QString &name) const;
private:
KUrl m_url;
QDomDocument m_document;
double m_fps;
int m_zoom;
/** Cursor position at document opening */
int m_startPos;
int m_width;
......@@ -137,8 +138,7 @@ private:
double m_documentLoadingStep;
double m_documentLoadingProgress;
bool m_abortLoading;
int m_zoneStart;
int m_zoneEnd;
QMap <QString, QString> m_documentProperties;
QList <TrackInfo> m_tracksList;
......
......@@ -1592,17 +1592,20 @@ void MainWindow::slotRenderProject()
QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
m_renderWidget = new RenderWidget(projectfolder, this);
connect(m_renderWidget, SIGNAL(doRender(const QStringList&, const QStringList&)), this, SLOT(slotDoRender(const QStringList&, const QStringList&)));
connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &)));
connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
if (m_activeDocument) {
m_renderWidget->setProfile(m_activeDocument->mltProfile());
m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"));
}
}
/*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
if (currentTab) m_renderWidget->setTimeline(currentTab);
m_renderWidget->setDocument(m_activeDocument);*/
m_renderWidget->show();
m_renderWidget->showNormal();
}
void MainWindow::slotDoRender(const QStringList args, const QStringList overlay_args)
......@@ -1915,6 +1918,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
if (m_renderWidget) {
m_renderWidget->setProfile(doc->mltProfile());
m_renderWidget->setDocumentPath(doc->projectFolder().path());
m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"));
}
//doc->setRenderer(m_projectMonitor->render);
m_commandStack->setActiveStack(doc->commandStack());
......@@ -2800,4 +2804,12 @@ void MainWindow::slotTranscodeClip()
slotTranscode(urls);
}
void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name)
{
if (m_activeDocument == NULL) return;
m_activeDocument->setDocumentProperty("renderdestination", dest);
m_activeDocument->setDocumentProperty("renderprofile", name);
m_activeDocument->setModified(true);
}
#include "mainwindow.moc"
......@@ -301,6 +301,7 @@ private slots:
void slotMaximizeCurrent(bool show);
void slotTranscode(KUrl::List urls = KUrl::List());
void slotTranscodeClip();
void slotSetDocumentRenderProfile(const QString &dest, const QString &name);
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -688,6 +688,9 @@ void RenderWidget::slotExport(bool scriptExport)
renderParameters << scriptName;
m_view.tabWidget->setCurrentIndex(1);
// Save rendering profile to document
emit selectedRenderProfile(m_view.size_list->currentItem()->data(MetaGroupRole).toString(), m_view.size_list->currentItem()->text());
// insert item in running jobs list
QTreeWidgetItem *renderItem;
QList<QTreeWidgetItem *> existing = m_view.running_jobs->findItems(dest, Qt::MatchExactly, 1);
......@@ -835,7 +838,7 @@ void RenderWidget::refreshView()
for (int i = 0; i < m_view.size_list->count(); i++) {
sizeItem = m_view.size_list->item(i);
if ((sizeItem->data(GroupRole) == group || sizeItem->data(GroupRole).toString().isEmpty()) && sizeItem->data(MetaGroupRole) == destination) {
if ((sizeItem->data(GroupRole).toString() == group || sizeItem->data(GroupRole).toString().isEmpty()) && sizeItem->data(MetaGroupRole).toString() == destination) {
std = sizeItem->data(StandardRole).toString();
if (!std.isEmpty()) {
if (std.contains("PAL", Qt::CaseInsensitive)) sizeItem->setHidden(m_view.format_selection->currentIndex() != 0);
......@@ -1422,3 +1425,34 @@ void RenderWidget::slotHideLog()
{
m_view.error_box->setVisible(false);
}
void RenderWidget::setRenderProfile(const QString &dest, const QString &name)
{
m_view.destination_list->blockSignals(true);
m_view.format_list->blockSignals(true);
m_view.size_list->blockSignals(true);
for (int i = 0; i < m_view.destination_list->count(); i++) {
if (m_view.destination_list->itemData(i, Qt::UserRole) == dest) {
m_view.destination_list->setCurrentIndex(i);
break;
}
}
QList<QListWidgetItem *> childs = m_view.size_list->findItems(name, Qt::MatchExactly);
if (!childs.isEmpty()) {
QListWidgetItem *profile = childs.at(0);
if (profile->isHidden()) {
QString group = profile->data(GroupRole).toString();
childs = m_view.format_list->findItems(group, Qt::MatchExactly);
if (!childs.isEmpty()) {
m_view.format_list->setCurrentItem(childs.at(0));
}
}
refreshView();
m_view.size_list->blockSignals(false);
m_view.size_list->setCurrentItem(profile);
} else m_view.size_list->blockSignals(false);
m_view.destination_list->blockSignals(false);
m_view.format_list->blockSignals(false);
}
......@@ -146,6 +146,7 @@ public:
void setRenderStatus(const QString &dest, int status, const QString &error);
void setDocumentPath(const QString path);
void reloadProfiles();
void setRenderProfile(const QString &dest, const QString &name);
private slots:
void slotUpdateButtons(KUrl url);
......@@ -185,6 +186,7 @@ signals:
void doRender(const QStringList&, const QStringList&);
void abortProcess(const QString &url);
void openDvdWizard(const QString &url, const QString &profile);
void selectedRenderProfile(const QString &category, const QString &name);
};
......
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