Commit 24801001 authored by Sashmita Raghav's avatar Sashmita Raghav

Add timeline ruler menu item to create subtitle clip

parent 46a5c8af
......@@ -581,6 +581,7 @@ void MainWindow::init()
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("edit_guide")));
timelineRulerMenu->addMenu(guideMenu);
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_project_note")));
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_subtitle")));
// Timeline headers menu
QMenu *timelineHeadersMenu = new QMenu(this);
......@@ -1682,6 +1683,7 @@ void MainWindow::setupActions()
addAction(QStringLiteral("edit_guide"), i18n("Edit Guide"), this, SLOT(slotEditGuide()), QIcon::fromTheme(QStringLiteral("document-properties")));
addAction(QStringLiteral("delete_all_guides"), i18n("Delete All Guides"), this, SLOT(slotDeleteAllGuides()),
QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("add_subtitle"), i18n("Add Subtitle"), this, SLOT(slotAddSubtitle()), QIcon::fromTheme(QStringLiteral("list-add")), Qt::SHIFT +Qt::Key_S);
m_saveAction = KStandardAction::save(pCore->projectManager(), SLOT(saveFile()), actionCollection());
m_saveAction->setIcon(QIcon::fromTheme(QStringLiteral("document-save")));
......@@ -4139,6 +4141,11 @@ void MainWindow::slotEditSubtitle()
pCore->currentDoc()->initializeSubtitles(m_subtitleModel);
}
void MainWindow::slotAddSubtitle()
{
getCurrentTimeline()->controller()->addSubtitle();
}
#ifdef DEBUG_MAINW
#undef DEBUG_MAINW
#endif
......@@ -500,6 +500,7 @@ private slots:
/** @brief Select target for current track */
void slotActivateTarget();
void slotEditSubtitle();
void slotAddSubtitle();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -3697,3 +3697,15 @@ void TimelineController::shiftSubtitle(int oldStartFrame, int newStartFrame, int
subtitleModel->removeSubtitle(oldStartPos); //first delete subtitle at old start position
subtitleModel->addSubtitle(newStartPos,endPos,text); //next, add a new subtitle at new start position
}
void TimelineController::addSubtitle()
{
int startframe = pCore->getTimelinePosition();
int endframe = startframe + 50; //create basic subtitle clip of default width
GenTime start(startframe, pCore->getCurrentFps());
GenTime end(endframe, pCore->getCurrentFps());
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
QString text = "Add Text";
subtitleModel->addSubtitle(start, end, text);
}
......@@ -562,6 +562,7 @@ public:
Q_INVOKABLE void moveSubtitle(int oldStartFrame, int newStartFrame);
/** @brief Shift subtitle clips without changing the clip duration */
Q_INVOKABLE void shiftSubtitle(int oldStartFrame, int newStartFrame, int endFrame=0, QString text="");
Q_INVOKABLE void addSubtitle();
public slots:
void resetView();
......
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