Check frameworks version to decide if we need to handle file overwrite by ourselves

parent 02fbeb71
......@@ -30,8 +30,10 @@
#include <QLabel>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <KRecentDirs>
#include <KMessageBox>
#include "kxmlgui_version.h"
Generators::Generators(Monitor *monitor, const QString &path, QWidget *parent) :
QDialog(parent)
......@@ -161,11 +163,15 @@ QUrl Generators::getSavedClip(QString clipFolder)
}
QUrl url = QFileDialog::getSaveFileUrl(this, i18n("Save clip"), QUrl::fromLocalFile(clipFolder), i18n("MLT playlist (*.mlt)"));
if (url.isValid()) {
#if KXMLGUI_VERSION_MINOR < 23 && KXMLGUI_VERSION_MAJOR == 5
// Since Plasma 5.7 (release at same time as KF 5.23,
// the file dialog manages the overwrite check
if (QFile::exists(url.path())) {
if (KMessageBox::warningYesNo(this, i18n("Output file already exists. Do you want to overwrite it?")) != KMessageBox::Yes) {
return getSavedClip(url.path());
}
}
#endif
Mlt::Tractor trac(*m_producer->profile());
m_producer->set("length", m_timePos->getValue());
m_producer->set_in_and_out(0, m_timePos->getValue() - 1);
......
......@@ -321,7 +321,6 @@ bool ProjectManager::saveFileAs()
fd.setMimeTypeFilters(QStringList()<<QStringLiteral("application/x-kdenlive"));
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setFileMode(QFileDialog::AnyFile);
fd.setOption(QFileDialog::DontConfirmOverwrite, false);
fd.setDefaultSuffix(QStringLiteral("kdenlive"));
if (fd.exec() != QDialog::Accepted) {
return false;
......@@ -331,12 +330,17 @@ bool ProjectManager::saveFileAs()
}
QString outputFile = fd.selectedFiles().at(0);
/*if (QFile::exists(outputFile)) {
#if KXMLGUI_VERSION_MINOR < 23 && KXMLGUI_VERSION_MAJOR == 5
// Since Plasma 5.7 (release at same time as KF 5.23,
// the file dialog manages the overwrite check
if (QFile::exists(outputFile)) {
// Show the file dialog again if the user does not want to overwrite the file
if (KMessageBox::questionYesNo(pCore->window(), i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No) {
return saveFileAs();
}
}*/
}
#endif
bool ok = false;
QDir cacheDir = m_project->getCacheDir(CacheBase, &ok);
if (ok) {
......
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