Commit 92b4cd13 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Implement timecode parsing when pasting text in Project notes

CCBUG: 420843
parent f63e303a
Pipeline #19309 passed with stage
in 9 minutes and 52 seconds
......@@ -18,10 +18,12 @@
***************************************************************************/
#include "noteswidget.h"
#include "kdenlive_debug.h"
#include "core.h"
#include <QMenu>
#include <QMouseEvent>
#include <QMimeData>
#include <klocalizedstring.h>
NotesWidget::NotesWidget(QWidget *parent)
......@@ -76,3 +78,21 @@ void NotesWidget::addProjectNote()
}
emit insertNotesTimecode();
}
void NotesWidget::insertFromMimeData(const QMimeData *source)
{
QString pastedText = source->text();
// Check for timecodes
QStringList words = pastedText.split(QLatin1Char(' '));
QMap <QString, QString> replacementPatterns;
for (const QString &w : words) {
if (w.size() > 4 && w.size() < 13 && w.count(QLatin1Char(':')) > 1) {
// This is probably a timecode
int frames = pCore->timecode().getFrameCount(w);
if (frames > 0) {
pastedText.replace(w, QStringLiteral("<a href=\"") + QString::number(frames) + QStringLiteral("\">") + w + QStringLiteral("</a> "));
}
}
}
insertHtml(pastedText);
}
......@@ -40,6 +40,7 @@ public:
protected:
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void insertFromMimeData(const QMimeData *source) override;
private slots:
void slotFillNotesMenu(const QPoint &pos);
......
......@@ -11,11 +11,10 @@ the Free Software Foundation, either version 3 of the License, or
#include "notesplugin.h"
#include "core.h"
#include "dialogs/noteswidget.h"
#include "doc/kdenlivedoc.h"
#include "mainwindow.h"
#include "doc/kdenlivedoc.h"
#include "monitor/monitormanager.h"
#include "project/projectmanager.h"
#include "klocalizedstring.h"
NotesPlugin::NotesPlugin(ProjectManager *projectManager)
......@@ -44,7 +43,7 @@ void NotesPlugin::showDock()
void NotesPlugin::slotInsertTimecode()
{
int frames = pCore->monitorManager()->projectMonitor()->position();
QString position = pCore->projectManager()->current()->timecode().getTimecodeFromFrames(frames);
QString position = pCore->timecode().getTimecodeFromFrames(frames);
m_widget->insertHtml(QStringLiteral("<a href=\"") + QString::number(frames) + QStringLiteral("\">") + position + QStringLiteral("</a> "));
}
......
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