Commit 3b5b1d4f authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Update render target when saving project under a new name.

related to #607
parent ed5c91d5
......@@ -1926,7 +1926,7 @@ QUrl RenderWidget::filenameWithExtension(QUrl url, const QString &extension)
}
QString ext;
if (extension.at(0) == '.') {
if (extension.startsWith(QLatin1Char('.'))) {
ext = extension;
} else {
ext = '.' + extension;
......@@ -1988,15 +1988,6 @@ void RenderWidget::refreshParams()
}
QUrl url = filenameWithExtension(m_view.out_file->url(), extension);
m_view.out_file->setUrl(url);
// if (!url.isEmpty()) {
// QString path = url.path();
// int pos = path.lastIndexOf('.') + 1;
// if (pos == 0) path.append('.' + extension);
// else path = path.left(pos) + extension;
// m_view.out_file->setUrl(QUrl(path));
// } else {
// m_view.out_file->setUrl(QUrl(QDir::homePath() + QStringLiteral("/untitled.") + extension));
// }
m_view.out_file->setFilter("*." + extension);
QString edit = item->data(0, EditableRole).toString();
if (edit.isEmpty() || !edit.endsWith(QLatin1String("customprofiles.xml"))) {
......@@ -3192,3 +3183,23 @@ void RenderWidget::prepareMenu(const QPoint &pos)
menu.exec(m_view.running_jobs->mapToGlobal(pos));
}
void RenderWidget::resetRenderPath(const QString &path)
{
QTreeWidgetItem *item = m_view.formats->currentItem();
QString extension;
if (item && item->parent()) { // categories have no parent
extension = item->data(0, ExtensionRole).toString();
} else {
extension = m_view.out_file->url().toLocalFile().section(QLatin1Char('.'), -1);
}
QString fileName = QDir(pCore->currentDoc()->projectDataFolder()).absoluteFilePath(path + extension);
QString url = filenameWithExtension(QUrl::fromLocalFile(fileName), extension).toLocalFile();
if (QFileInfo(url).isRelative()) {
url.prepend(pCore->currentDoc()->documentRoot());
}
m_view.out_file->setUrl(QUrl::fromLocalFile(url));
QMap<QString, QString> renderProps;
renderProps.insert(QStringLiteral("renderurl"), url);
emit selectedRenderProfile(renderProps);
}
......@@ -125,9 +125,9 @@ public:
void focusFirstVisibleItem(const QString &profile = QString());
void setRenderJob(const QString &dest, int progress = 0, int frame = 0);
void setRenderStatus(const QString &dest, int status, const QString &error);
void updateDocumentPath();
void reloadProfiles();
void setRenderProfile(const QMap<QString, QString> &props);
void updateDocumentPath();
int waitingJobsCount() const;
QString getFreeScriptName(const QUrl &projectName = QUrl(), const QString &prefix = QString());
bool startWaitingRenderJobs();
......@@ -155,6 +155,9 @@ public slots:
void slotPrepareExport(bool scriptExport = false, const QString &scriptPath = QString());
void adjustViewToProfile();
void reloadGuides();
/** @brief Adjust render file name to current project name. */
void resetRenderPath(const QString &path);
private slots:
void slotUpdateButtons(const QUrl &url);
......
......@@ -988,7 +988,7 @@ void MainWindow::createSplitOverlay(std::shared_ptr<Mlt::Filter> filter)
getMainTimeline()->controller()->createSplitOverlay(m_assetPanel->effectStackOwner().second, filter);
m_projectMonitor->activateSplit();
} else {
pCore->displayMessage(i18n("Select a clip to compare effect"), InformationMessage);
pCore->displayMessage(i18n("Select a clip to compare effect"), ErrorMessage);
}
}
......@@ -2078,6 +2078,7 @@ void MainWindow::slotRenderProject()
connect(m_renderWidget, &RenderWidget::abortProcess, this, &MainWindow::abortRenderJob);
connect(m_renderWidget, &RenderWidget::openDvdWizard, this, &MainWindow::slotDvdWizard);
connect(this, &MainWindow::updateRenderWidgetProfile, m_renderWidget, &RenderWidget::adjustViewToProfile);
connect(this, &MainWindow::updateProjectPath, m_renderWidget, &RenderWidget::resetRenderPath);
m_renderWidget->setGuides(project->getGuideModel());
m_renderWidget->updateDocumentPath();
m_renderWidget->setRenderProfile(project->getRenderProperties());
......@@ -2776,7 +2777,7 @@ void MainWindow::slotInsertClipInsert()
const QString &binId = m_clipMonitor->activeClipId();
if (binId.isEmpty()) {
// No clip in monitor
pCore->displayMessage(i18n("No clip selected in project bin"), InformationMessage);
pCore->displayMessage(i18n("No clip selected in project bin"), ErrorMessage);
return;
}
getMainTimeline()->controller()->insertZone(binId, m_clipMonitor->getZoneInfo(), false);
......@@ -2934,10 +2935,10 @@ void MainWindow::addEffect(const QString &effectId)
pCore->window()->getMainTimeline()->controller()->addAsset(effectData);
} else if (m_assetPanel->effectStackOwner().first == ObjectType::TimelineTrack || m_assetPanel->effectStackOwner().first == ObjectType::BinClip || m_assetPanel->effectStackOwner().first == ObjectType::Master) {
if (!m_assetPanel->addEffect(effectId)) {
pCore->displayMessage(i18n("Cannot add effect to clip"), InformationMessage);
pCore->displayMessage(i18n("Cannot add effect to clip"), ErrorMessage);
}
} else {
pCore->displayMessage(i18n("Select an item to add effect"), InformationMessage);
pCore->displayMessage(i18n("Select an item to add effect"), ErrorMessage);
}
}
......@@ -4290,7 +4291,7 @@ void MainWindow::slotImportSubtitle()
void MainWindow::slotExportSubtitle()
{
if (pCore->getSubtitleModel() == nullptr) {
pCore->displayMessage(i18n("No subtitles in current project"), InformationMessage);
pCore->displayMessage(i18n("No subtitles in current project"), ErrorMessage);
return;
}
getCurrentTimeline()->controller()->exportSubtitle();
......
......@@ -541,6 +541,7 @@ signals:
/** @brief Enable or disable the undo stack. For example undo/redo should not be enabled when dragging a clip in timeline or we risk corruption. */
void enableUndo(bool enable);
bool focusTimeline(bool focus, bool highlight);
void updateProjectPath(const QString &path);
};
#endif
......@@ -299,6 +299,10 @@ bool ProjectManager::saveFileAs(const QString &outputFileName, bool saveACopy)
{
pCore->monitorManager()->pauseActiveMonitor();
// Sync document properties
if (!saveACopy && outputFileName != m_project->url().toLocalFile()) {
// Project filename changed
pCore->window()->updateProjectPath(outputFileName);
}
prepareSave();
QString saveFolder = QFileInfo(outputFileName).absolutePath();
m_project->updateSubtitle(outputFileName);
......
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