Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
92b4cd13
Commit
92b4cd13
authored
May 01, 2020
by
Jean-Baptiste Mardelle
Browse files
Implement timecode parsing when pasting text in Project notes
CCBUG: 420843
parent
f63e303a
Pipeline
#19309
passed with stage
in 9 minutes and 52 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/project/dialogs/noteswidget.cpp
View file @
92b4cd13
...
...
@@ -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
);
}
src/project/dialogs/noteswidget.h
View file @
92b4cd13
...
...
@@ -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
);
...
...
src/project/notesplugin.cpp
View file @
92b4cd13
...
...
@@ -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> "
));
}
...
...
Eugen Mohr
@emohr
mentioned in issue
#666 (closed)
·
May 08, 2020
mentioned in issue
#666 (closed)
mentioned in issue #666
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment