aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-11-29 21:35:14 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-11-29 21:35:14 +0100
commit1894b12d37d5a0e7b0329906d4604bdbcbc82e95 (patch)
tree996b0a14196e4e84303a24c5f9eb219b2ecb42a7
parent7f6eb982359ecaf2a4889955c110fa834cc933e2 (diff)
Warn before overwriting existing image file.
-rw-r--r--src/monitor/monitor.cpp33
-rw-r--r--src/monitor/monitor.h2
2 files changed, 21 insertions, 14 deletions
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 3b28232..24b0507 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -37,6 +37,7 @@
#include <KDualAction>
#include <KSelectAction>
#include <KMessageWidget>
+#include <KMessageBox>
#include <QDebug>
#include <QMouseEvent>
@@ -827,26 +828,32 @@ ClipController *Monitor::currentController() const
return m_controller;
}
-void Monitor::slotExtractCurrentFrame()
+void Monitor::slotExtractCurrentFrame(QString path)
{
- QImage frame;
- // check if we are using a proxy
- if (m_controller && !m_controller->property("kdenlive:proxy").isEmpty() && m_controller->property("kdenlive:proxy") != "-") {
- // using proxy, use original clip url to get frame
- frame = render->extractFrame(render->seekFramePosition(), m_controller->property("resource"));
- }
- else frame = render->extractFrame(render->seekFramePosition());
QString framesFolder = KRecentDirs::dir(":KdenliveFramesFolder");
if (framesFolder.isEmpty()) framesFolder = QDir::homePath();
-
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), framesFolder);
fs->setMimeTypeFilters(QStringList() << "image/png");
fs->setAcceptMode(QFileDialog::AcceptSave);
+ fs->selectFile(path);
if (fs->exec()) {
- QStringList path = fs->selectedFiles();
- if (!path.isEmpty()) {
- KRecentDirs::add(":KdenliveFramesFolder", fs->selectedUrls().first().adjusted(QUrl::RemoveFilename).path());
- frame.save(path.first());
+ if (!fs->selectedFiles().isEmpty()) {
+ QUrl savePath = fs->selectedUrls().first();
+ if (QFile::exists(savePath.toLocalFile()) && KMessageBox::warningYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", savePath.toLocalFile())) == KMessageBox::No) {
+ delete fs;
+ slotExtractCurrentFrame(savePath.fileName());
+ return;
+ }
+ // Create Qimage with frame
+ QImage frame;
+ // check if we are using a proxy
+ if (m_controller && !m_controller->property("kdenlive:proxy").isEmpty() && m_controller->property("kdenlive:proxy") != "-") {
+ // using proxy, use original clip url to get frame
+ frame = render->extractFrame(render->seekFramePosition(), m_controller->property("resource"));
+ }
+ else frame = render->extractFrame(render->seekFramePosition());
+ frame.save(savePath.toLocalFile());
+ KRecentDirs::add(":KdenliveFramesFolder", savePath.adjusted(QUrl::RemoveFilename).path());
}
}
delete fs;
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index 9198e3e..b3d8d8f 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -192,7 +192,7 @@ private:
private slots:
void seekCursor(int pos);
void rendererStopped(int pos);
- void slotExtractCurrentFrame();
+ void slotExtractCurrentFrame(QString path = QString());
void slotSetThumbFrame();
void slotSaveZone();
void slotSeek();