Make it possible to assign shortcut to extract frame feature,

always suggest a name (and improve suggestion by adding 0 padding for better sorting)
BUG: 381325
parent e20cb65f
......@@ -1602,6 +1602,11 @@ void MainWindow::setupActions()
}
transitionActions->addAction("transition_" + id, transAction);
}
// monitor actions
addAction(QStringLiteral("extract_frame"), i18n("Extract frame..."), pCore->monitorManager(), SLOT(slotExtractCurrentFrame()), KoIconUtils::themedIcon(QStringLiteral("insert-image")));
addAction(QStringLiteral("extract_frame_to_project"), i18n("Extract frame to project..."), pCore->monitorManager(), SLOT(slotExtractCurrentFrameToProject()), KoIconUtils::themedIcon(QStringLiteral("insert-image")));
}
void MainWindow::saveOptions()
......
......@@ -482,11 +482,9 @@ 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()));
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);
m_contextMenu->addAction(m_monitorManager->getAction(QStringLiteral("extract_frame")));
m_contextMenu->addAction(m_monitorManager->getAction(QStringLiteral("extract_frame_to_project")));
if (m_id == Kdenlive::ProjectMonitor) {
m_multitrackView = m_contextMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("view-split-left-right")), i18n("Multitrack view"), this, SIGNAL(multitrackView(bool)));
......@@ -999,14 +997,9 @@ ClipController *Monitor::currentController() const
return m_controller;
}
void Monitor::slotExtractCurrentFrameToProject()
{
slotExtractCurrentFrame(QString(), true);
}
void Monitor::slotExtractCurrentFrame(QString frameName, bool addToProject)
{
if (addToProject && QFileInfo(frameName).fileName().isEmpty()) {
if (QFileInfo(frameName).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,
......@@ -1020,7 +1013,7 @@ void Monitor::slotExtractCurrentFrame(QString frameName, bool addToProject)
: i18n("untitled")
).completeBaseName()
+ QStringLiteral("-f")
+ QString::number(render->seekFramePosition())
+ QString::number(render->seekFramePosition()).rightJustified(6, QLatin1Char('0'))
+ QStringLiteral(".png");
frameName = QFileInfo(frameName, suggestedImageName).fileName();
}
......
......@@ -154,6 +154,8 @@ public:
void clearDisplay();
/** @brief Seeks timeline without refreshing if monitor is not active **/
void silentSeek(int pos);
/** @brief Save monitor frame as image, and add image to current project if addToProject is set to true*/
void slotExtractCurrentFrame(QString frameName = QString(), bool addToProject = false);
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
......@@ -239,8 +241,6 @@ private:
private slots:
void seekCursor(int pos);
void rendererStopped(int pos);
void slotExtractCurrentFrame(QString frameName = QString(), bool addToProject = false);
void slotExtractCurrentFrameToProject();
void slotSetThumbFrame();
void slotSaveZone();
void slotSeek();
......
......@@ -590,3 +590,17 @@ QDir MonitorManager::getCacheFolder(CacheType type)
}
return QDir();
}
void MonitorManager::slotExtractCurrentFrame()
{
if (m_activeMonitor) {
static_cast<Monitor *>(m_activeMonitor)->slotExtractCurrentFrame();
}
}
void MonitorManager::slotExtractCurrentFrameToProject()
{
if (m_activeMonitor) {
static_cast<Monitor *>(m_activeMonitor)->slotExtractCurrentFrame(QString(), true);
}
}
......@@ -103,6 +103,10 @@ public slots:
* @param activateClip whether to activate the clip monitor */
void slotSwitchMonitors(bool activateClip);
void slotUpdateAudioMonitoring();
/** @brief Export the current monitor's frame to image file. */
void slotExtractCurrentFrame();
/** @brief Export the current monitor's frame to image file and add it to the current project */
void slotExtractCurrentFrameToProject();
private slots:
/** @brief Set MLT's consumer deinterlace method */
......
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