Commit ed9c7a4d authored by Sashmita Raghav's avatar Sashmita Raghav
Browse files

Enable deletion of subtitle clips from timeline by right clicking on them

parent 36a2cd5b
......@@ -48,7 +48,7 @@ std::shared_ptr<SubtitleModel> SubtitleModel::getModel()
void SubtitleModel::parseSubtitle()
{
qDebug()<<"Parsing started";
QString filePath= "path_to_subtitle_file.srt";
QString filePath; //"path_to_subtitle_file.srt";
m_subFilePath = filePath;
QString start,end,comment;
QString timeLine;
......@@ -394,7 +394,7 @@ void SubtitleModel::moveSubtitle(GenTime oldPos, GenTime newPos)
QString SubtitleModel::toJson()
{
qDebug()<< "to JSON";
//qDebug()<< "to JSON";
QJsonArray list;
for (const auto &subtitle : m_subtitleList) {
QJsonObject currentSubtitle;
......@@ -411,12 +411,12 @@ QString SubtitleModel::toJson()
void SubtitleModel::jsontoSubtitle(const QString &data)
{
QString outFile = "path_to_temp_Subtitle.ass";
QString outFile = "path_to_temp_Subtitle.srt"; // use srt format as default unless file is imported (m_subFilePath)
if (!outFile.contains(".ass"))
qDebug()<< "srt file import"; // if imported file isn't .ass, it is .srt format
QFile outF(outFile);
qDebug()<< "Import from JSON";
//qDebug()<< "Import from JSON";
QWriteLocker locker(&m_lock);
auto json = QJsonDocument::fromJson(data.toUtf8());
if (!json.isArray()) {
......
......@@ -1505,17 +1505,23 @@ Rectangle {
property double delta: -1
property double originalDuration: -1
property double oldDelta: 0
acceptedButtons: Qt.LeftButton
acceptedButtons: Qt.LeftButton | Qt.RightButton
cursorShape: (pressed ? Qt.ClosedHandCursor : Qt.PointingHandCursor);
drag.target: subtitleBase
drag.axis: Drag.XAxis
onPressed: {
console.log('IT IS PRESSED')
root.autoScrolling = false
oldStartX = mouseX
oldStartFrame = subtitleBase.x
originalDuration = subtitleBase.width/timeScale
console.log("originalDuration",originalDuration)
if (mouse.button == Qt.RightButton) {
console.log('RIGHT BUTTON CLICKED')
timeline.deleteSubtitle(subtitleBase.x / timeline.scaleFactor)
}
else {
root.autoScrolling = false
oldStartX = mouseX
oldStartFrame = subtitleBase.x
originalDuration = subtitleBase.width/timeScale
console.log("originalDuration",originalDuration)
}
}
onPositionChanged: {
if (pressed) {
......
......@@ -3709,3 +3709,11 @@ void TimelineController::addSubtitle()
QString text = "Add Text";
subtitleModel->addSubtitle(start, end, text);
}
void TimelineController::deleteSubtitle(int frame)
{
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
GenTime start(frame, pCore->getCurrentFps());
subtitleModel->removeSubtitle(start);
return;
}
\ No newline at end of file
......@@ -562,7 +562,10 @@ 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="");
/** @brief Add subtitle clip at cursor's position in timeline */
Q_INVOKABLE void addSubtitle();
/** @brief Delete subtitle clip with frame as start position*/
Q_INVOKABLE void deleteSubtitle(int frame);
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