]> git.sesse.net Git - kdenlive/commitdiff
Make it easier to save render scripts with custom names: http://www.kdenlive.org...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 30 Dec 2012 16:00:03 +0000 (17:00 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 30 Dec 2012 16:00:03 +0000 (17:00 +0100)
src/mainwindow.cpp
src/renderwidget.cpp
src/renderwidget.h

index 95b00560e59af1460bff02229bc44c301b66b738..5e6d4ded95af442802fab649748b4109771d7dd2 100644 (file)
@@ -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)
index 690e36e5e19ed4c7b6c63cc3777368122dad4218..512583ab467c0239dfb519297f17ab5ebd0fdcdc 100644 (file)
@@ -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 <QString, QString> 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;
 }
index 3b4b644271d7f76f4fd44bf06244b9290a60b32e..c832c46e3e940cef8928b0a1c03c1e4dfdc4b058 100644 (file)
@@ -125,7 +125,7 @@ public:
     void reloadProfiles();
     void setRenderProfile(QMap <QString, QString> 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. */