From d9369573d19f25b13afad8cc0647a98b9cf6a94b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 30 Dec 2012 17:00:03 +0100 Subject: [PATCH] Make it easier to save render scripts with custom names: http://www.kdenlive.org/mantis/view.php?id=2913 --- src/mainwindow.cpp | 9 ++++----- src/renderwidget.cpp | 10 ++++++---- src/renderwidget.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 95b00560..5e6d4ded 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4086,12 +4086,11 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS QString scriptPath; QString playlistPath; if (scriptExport) { - bool ok; QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/"; - QString path = m_renderWidget->getFreeScriptName(); - scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok); - if (!ok || scriptPath.isEmpty()) return; - scriptPath.prepend(scriptsFolder); + QString path = m_renderWidget->getFreeScriptName(m_activeDocument->url()); + KUrl finalPath = KUrlRequesterDialog::getUrl(path, m_renderWidget, i18n("Create Render Script")); + if (finalPath.isEmpty()) return; + scriptPath = finalPath.path(); QFile f(scriptPath); if (f.exists()) { if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes) diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index 690e36e5..512583ab 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -1551,7 +1551,6 @@ void RenderWidget::parseFile(QString exportFile, bool editable) bool replaceLibfaacCodec = false; if (!acodecsList.contains("aac") && acodecsList.contains("libfaac")) replaceLibfaacCodec = true; - if (editable || groups.count() == 0) { QDomElement profiles = doc.documentElement(); if (editable && profiles.attribute("version", 0).toInt() < 1) { @@ -2077,7 +2076,7 @@ void RenderWidget::setRenderProfile(QMap props) bool RenderWidget::startWaitingRenderJobs() { m_blockProcessing = true; - QString autoscriptFile = getFreeScriptName("auto"); + QString autoscriptFile = getFreeScriptName(KUrl(), "auto"); QFile file(autoscriptFile); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { kWarning() << "////// ERROR writing to file: " << autoscriptFile; @@ -2115,15 +2114,18 @@ bool RenderWidget::startWaitingRenderJobs() return true; } -QString RenderWidget::getFreeScriptName(const QString &prefix) +QString RenderWidget::getFreeScriptName(const KUrl &projectName, const QString &prefix) { int ix = 0; QString scriptsFolder = m_projectFolder + "scripts/"; KStandardDirs::makeDir(scriptsFolder); QString path; + QString fileName; + if (projectName.isEmpty()) fileName = i18n("script"); + else fileName = projectName.fileName().section('.', 0, -2) + "_"; while (path.isEmpty() || QFile::exists(path)) { ix++; - path = scriptsFolder + prefix + i18n("script") + QString::number(ix).rightJustified(3, '0', false) + ".sh"; + path = scriptsFolder + prefix + fileName + QString::number(ix).rightJustified(3, '0', false) + ".sh"; } return path; } diff --git a/src/renderwidget.h b/src/renderwidget.h index 3b4b6442..c832c46e 100644 --- a/src/renderwidget.h +++ b/src/renderwidget.h @@ -125,7 +125,7 @@ public: void reloadProfiles(); void setRenderProfile(QMap props); int waitingJobsCount() const; - QString getFreeScriptName(const QString &prefix = QString()); + QString getFreeScriptName(const KUrl &projectName = KUrl(), const QString &prefix = QString()); bool startWaitingRenderJobs(); void missingClips(bool hasMissing); /** @brief Returns true if the export audio checkbox is set to automatic. */ -- 2.39.2