summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-18 15:06:11 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-18 15:06:11 (GMT)
commite31ec9285daedbfd7cbdb0c2616b3e64c006a5fc (patch)
treed3322d5022f9191778c0bb1c94a7c2ad7d7255c4
parent305376d2b07132e9bba690b0314739e7e3b6e0ff (diff)
New: Extract frame to project, patch by Harald Albrecht
REVIEW: 128929
-rw-r--r--src/monitor/monitor.cpp48
-rw-r--r--src/monitor/monitor.h3
2 files changed, 45 insertions, 6 deletions
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 8d77d8b..9d452aa 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -34,6 +34,11 @@
#include "doc/kthumb.h"
#include "utils/KoIconUtils.h"
#include "timeline/transitionhandler.h"
+#include "core.h"
+#include "bin/bin.h"
+#include "project/projectmanager.h"
+#include "doc/kdenlivedoc.h"
+#include "mainwindow.h"
#include "klocalizedstring.h"
#include <KRecentDirs>
@@ -445,9 +450,12 @@ void Monitor::setupMenu(QMenu *goMenu, QMenu *overlayMenu, QAction *playZone, QA
QAction *extractZone = m_configMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("document-new")), i18n("Extract Zone"), this, SLOT(slotExtractCurrentZone()));
m_contextMenu->addAction(extractZone);
}
- QAction *extractFrame = m_configMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("document-new")), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
+ QAction *extractFrame = m_configMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("document-new")), i18n("Extract frame..."), this, SLOT(slotExtractCurrentFrame()));
m_contextMenu->addAction(extractFrame);
+ QAction *extractFrameToProject = m_configMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("document-new")), i18n("Extract frame to project..."), this, SLOT(slotExtractCurrentFrameToProject()));
+ m_contextMenu->addAction (extractFrameToProject);
+
if (m_id == Kdenlive::ProjectMonitor) {
m_multitrackView = m_contextMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("view-split-left-right")), i18n("Multitrack view"), this, SIGNAL(multitrackView(bool)));
m_multitrackView->setCheckable(true);
@@ -932,11 +940,35 @@ ClipController *Monitor::currentController() const
return m_controller;
}
-void Monitor::slotExtractCurrentFrame(QString path)
+void Monitor::slotExtractCurrentFrameToProject()
{
+ slotExtractCurrentFrame(QString(), true);
+}
+
+void Monitor::slotExtractCurrentFrame(QString path, bool addToProject)
+{
+ if (addToProject && QFileInfo(path).fileName().isEmpty()) {
+ // convenience: when extracting an image to be added to the project,
+ // suggest a suitable image file name. In the project monitor, this
+ // suggestion bases on the project file name; in the clip monitor,
+ // the suggestion bases on the clip file name currently shown.
+ // Finally, the frame number is added to this suggestion, prefixed
+ // with "-f", so we get something like clip-f#.png.
+ QString suggestedImageName = QFileInfo(currentController()
+ ? currentController()->clipName()
+ : pCore->projectManager()->current()->url().isValid()
+ ? pCore->projectManager()->current()->url().fileName()
+ : i18n("untitled")
+ ).completeBaseName()
+ + QStringLiteral("-f")
+ + QString::number(render->seekFramePosition())
+ + ".png";
+ path = QFileInfo(path, suggestedImageName).absoluteFilePath();
+ }
+
QString framesFolder = KRecentDirs::dir(":KdenliveFramesFolder");
if (framesFolder.isEmpty()) framesFolder = QDir::homePath();
- QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), framesFolder);
+ QPointer<QFileDialog> fs = new QFileDialog(this, addToProject ? i18n("Save Image") : i18n("Save Image to Project"), framesFolder);
fs->setMimeTypeFilters(QStringList() << QStringLiteral("image/png"));
fs->setAcceptMode(QFileDialog::AcceptSave);
fs->setDefaultSuffix(QStringLiteral("png"));
@@ -946,7 +978,7 @@ void Monitor::slotExtractCurrentFrame(QString path)
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());
+ slotExtractCurrentFrame(savePath.fileName(), addToProject);
return;
}
// Create Qimage with frame
@@ -955,10 +987,16 @@ void Monitor::slotExtractCurrentFrame(QString path)
if (m_controller && !m_controller->property(QStringLiteral("kdenlive:proxy")).isEmpty() && m_controller->property(QStringLiteral("kdenlive:proxy")) != QLatin1String("-")) {
// using proxy, use original clip url to get frame
frame = render->extractFrame(render->seekFramePosition(), m_controller->property(QStringLiteral("resource")));
+ } else {
+ frame = render->extractFrame(render->seekFramePosition());
}
- else frame = render->extractFrame(render->seekFramePosition());
frame.save(savePath.toLocalFile());
KRecentDirs::add(QStringLiteral(":KdenliveFramesFolder"), savePath.adjusted(QUrl::RemoveFilename).path());
+
+ if (addToProject) {
+ QStringList folderInfo = pCore->bin()->getFolderInfo();
+ pCore->bin()->droppedUrls(QList<QUrl>() << savePath, folderInfo);
+ }
}
}
delete fs;
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index 39679d8..3e933e6 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -239,7 +239,8 @@ private:
private slots:
void seekCursor(int pos);
void rendererStopped(int pos);
- void slotExtractCurrentFrame(QString path = QString());
+ void slotExtractCurrentFrame(QString path = QString(), bool addToProject = false);
+ void slotExtractCurrentFrameToProject();
void slotSetThumbFrame();
void slotSaveZone();
void slotSeek();