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

Commit 559ad678 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix change fps on empty project. Fixes #39

parent 491d80de
......@@ -1700,6 +1700,13 @@ void MainWindow::slotEditProjectSettings()
if (pCore->getCurrentProfile()->path() != profile || project->profileChanged(profile)) {
if (!qFuzzyCompare(pCore->getCurrentProfile()->fps() - ProfileRepository::get()->getProfile(profile)->fps(), 0.)) {
// Fps was changed, we save the project to an xml file with updated profile and reload project
// Check if blank project
if (project->url().fileName().isEmpty() && !project->isModified()) {
// Trying to switch project profile from an empty project
pCore->setCurrentProfile(profile);
pCore->projectManager()->newFile(profile, false);
return;
}
pCore->projectManager()->saveWithUpdatedProfile(profile);
} else {
pCore->setCurrentProfile(profile);
......
......@@ -112,19 +112,23 @@ void ProjectManager::init(const QUrl &projectUrl, const QString &clipList)
m_loadClipsOnOpen = clipList;
}
void ProjectManager::newFile(bool showProjectSettings, bool force)
void ProjectManager::newFile(bool showProjectSettings)
{
QString profileName = KdenliveSettings::default_profile();
if (profileName.isEmpty()) {
profileName = pCore->getCurrentProfile()->path();
}
newFile(profileName, showProjectSettings);
}
void ProjectManager::newFile(QString profileName, bool showProjectSettings)
{
Q_UNUSED(force)
// fix mantis#3160
QUrl startFile = QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder() + QStringLiteral("/_untitled.kdenlive"));
if (checkForBackupFile(startFile, true)) {
return;
}
m_fileRevert->setEnabled(false);
QString profileName = KdenliveSettings::default_profile();
if (profileName.isEmpty()) {
profileName = pCore->getCurrentProfile()->path();
}
QString projectFolder;
QMap<QString, QString> documentProperties;
QMap<QString, QString> documentMetadata;
......@@ -879,10 +883,28 @@ std::shared_ptr<DocUndoStack> ProjectManager::undoStack()
void ProjectManager::saveWithUpdatedProfile(const QString updatedProfile)
{
// First backup current project with fps appended
const QString currentFile = m_project->url().toLocalFile();
if (!closeCurrentDocument()) {
QString message;
if (m_project && m_project->isModified()) {
switch (KMessageBox::warningYesNoCancel(pCore->window(), i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?", m_project->url().fileName().isEmpty() ? i18n("Untitled") : m_project->url().fileName()))) {
case KMessageBox::Yes:
// save document here. If saving fails, return false;
if (!saveFile()) {
pCore->displayBinMessage(i18n("Project profile change aborted"), KMessageWidget::Information);
return;
}
break;
default:
pCore->displayBinMessage(i18n("Project profile change aborted"), KMessageWidget::Information);
return;
break;
}
}
if (!m_project || m_project->isModified()) {
pCore->displayBinMessage(i18n("Project profile change aborted"), KMessageWidget::Information);
return;
}
const QString currentFile = m_project->url().toLocalFile();
// Now update to new profile
auto &newProfile = ProfileRepository::get()->getProfile(updatedProfile);
......@@ -928,4 +950,5 @@ void ProjectManager::saveWithUpdatedProfile(const QString updatedProfile)
}
file.close();
openFile(QUrl::fromLocalFile(convertedFile));
pCore->displayBinMessage(i18n("Project profile changed"), KMessageWidget::Information);
}
......@@ -87,7 +87,8 @@ public:
void saveWithUpdatedProfile(const QString updatedProfile);
public slots:
void newFile(bool showProjectSettings = true, bool force = false);
void newFile(QString profileName, bool showProjectSettings = true);
void newFile(bool showProjectSettings = true);
/** @brief Shows file open dialog. */
void openFile();
void openLastFile();
......
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