Skip to content
GitLab
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
6007d573
Commit
6007d573
authored
Feb 07, 2020
by
Jean-Baptiste Mardelle
Browse files
*Use menu position for insert/remove space when necessary
*Show warning when paste cannot be performed
parent
25daf0c1
Pipeline
#14623
passed with stage
in 23 minutes and 45 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/timelinefunctions.cpp
View file @
6007d573
...
...
@@ -1460,32 +1460,37 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
if
(
res
)
{
std
::
shared_ptr
<
EffectStackModel
>
destStack
=
timeline
->
getClipEffectStackModel
(
newId
);
destStack
->
fromXml
(
prod
.
firstChildElement
(
QStringLiteral
(
"effects"
)),
undo
,
redo
);
}
else
{
break
;
}
}
// Compositions
for
(
int
i
=
0
;
res
&&
i
<
compositions
.
count
();
i
++
)
{
QDomElement
prod
=
compositions
.
at
(
i
).
toElement
();
QString
originalId
=
prod
.
attribute
(
QStringLiteral
(
"composition"
));
int
in
=
prod
.
attribute
(
QStringLiteral
(
"in"
)).
toInt
();
int
out
=
prod
.
attribute
(
QStringLiteral
(
"out"
)).
toInt
();
int
curTrackId
=
tracksMap
.
value
(
prod
.
attribute
(
QStringLiteral
(
"track"
)).
toInt
());
int
aTrackId
=
prod
.
attribute
(
QStringLiteral
(
"a_track"
)).
toInt
();
if
(
aTrackId
>
0
)
{
aTrackId
=
timeline
->
getTrackPosition
(
tracksMap
.
value
(
aTrackId
));
}
int
pos
=
prod
.
attribute
(
QStringLiteral
(
"position"
)).
toInt
()
-
offset
;
int
newId
;
auto
transProps
=
std
::
make_unique
<
Mlt
::
Properties
>
();
QDomNodeList
props
=
prod
.
elementsByTagName
(
QStringLiteral
(
"property"
));
for
(
int
j
=
0
;
j
<
props
.
count
();
j
++
)
{
transProps
->
set
(
props
.
at
(
j
).
toElement
().
attribute
(
QStringLiteral
(
"name"
)).
toUtf8
().
constData
(),
if
(
res
)
{
for
(
int
i
=
0
;
res
&&
i
<
compositions
.
count
();
i
++
)
{
QDomElement
prod
=
compositions
.
at
(
i
).
toElement
();
QString
originalId
=
prod
.
attribute
(
QStringLiteral
(
"composition"
));
int
in
=
prod
.
attribute
(
QStringLiteral
(
"in"
)).
toInt
();
int
out
=
prod
.
attribute
(
QStringLiteral
(
"out"
)).
toInt
();
int
curTrackId
=
tracksMap
.
value
(
prod
.
attribute
(
QStringLiteral
(
"track"
)).
toInt
());
int
aTrackId
=
prod
.
attribute
(
QStringLiteral
(
"a_track"
)).
toInt
();
if
(
aTrackId
>
0
)
{
aTrackId
=
timeline
->
getTrackPosition
(
tracksMap
.
value
(
aTrackId
));
}
int
pos
=
prod
.
attribute
(
QStringLiteral
(
"position"
)).
toInt
()
-
offset
;
int
newId
;
auto
transProps
=
std
::
make_unique
<
Mlt
::
Properties
>
();
QDomNodeList
props
=
prod
.
elementsByTagName
(
QStringLiteral
(
"property"
));
for
(
int
j
=
0
;
j
<
props
.
count
();
j
++
)
{
transProps
->
set
(
props
.
at
(
j
).
toElement
().
attribute
(
QStringLiteral
(
"name"
)).
toUtf8
().
constData
(),
props
.
at
(
j
).
toElement
().
text
().
toUtf8
().
constData
());
}
res
=
res
&&
timeline
->
requestCompositionInsertion
(
originalId
,
curTrackId
,
aTrackId
,
position
+
pos
,
out
-
in
+
1
,
std
::
move
(
transProps
),
newId
,
undo
,
redo
);
}
res
=
timeline
->
requestCompositionInsertion
(
originalId
,
curTrackId
,
aTrackId
,
position
+
pos
,
out
-
in
+
1
,
std
::
move
(
transProps
),
newId
,
undo
,
redo
);
}
if
(
!
res
)
{
undo
();
pCore
->
displayMessage
(
i18n
(
"Could not paste items in timeline"
),
InformationMessage
,
500
);
return
false
;
}
// Rebuild groups
...
...
src/timeline2/view/qml/timeline.qml
View file @
6007d573
...
...
@@ -134,7 +134,11 @@ Rectangle {
}
function
getMousePos
()
{
return
(
scrollView
.
contentX
+
tracksArea
.
mouseX
)
/
timeline
.
scaleFactor
if
(
tracksArea
.
containsMouse
)
{
return
(
scrollView
.
contentX
+
tracksArea
.
mouseX
)
/
timeline
.
scaleFactor
}
else
{
return
-
1
;
}
}
function
getScrollPos
()
{
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
6007d573
...
...
@@ -200,7 +200,7 @@ QMap<int, QString> TimelineController::getTrackNames(bool videoOnly)
void
TimelineController
::
setScaleFactorOnMouse
(
double
scale
,
bool
zoomOnMouse
)
{
if
(
m_root
)
{
m_root
->
setProperty
(
"zoomOnMouse"
,
zoomOnMouse
?
q
Min
(
getMousePos
(),
duration
())
:
-
1
);
m_root
->
setProperty
(
"zoomOnMouse"
,
zoomOnMouse
?
q
Bound
(
0
,
getMousePos
(),
duration
())
:
-
1
);
m_scale
=
scale
;
emit
scaleFactorChanged
();
}
else
{
...
...
@@ -1147,10 +1147,10 @@ void TimelineController::seekToClip(int cid, bool seekToEnd)
void
TimelineController
::
seekToMouse
()
{
QVariant
returnedValue
;
QMetaObject
::
invokeMethod
(
m_root
,
"getMousePos"
,
Q_RETURN_ARG
(
QVariant
,
returnedValue
));
int
mou
sePos
=
returnedValue
.
toInt
(
);
setPosition
(
mousePos
);
int
mousePos
=
getMousePos
()
;
if
(
mousePos
>
-
1
)
{
se
t
Pos
ition
(
mousePos
);
}
}
int
TimelineController
::
getMousePos
()
...
...
@@ -1526,11 +1526,20 @@ QMap<QString, QString> TimelineController::documentProperties()
return
props
;
}
void
TimelineController
::
insertSpace
(
int
trackId
,
int
frame
)
int
TimelineController
::
getMenuOrTimelinePos
()
const
{
int
frame
=
m_root
->
property
(
"mainFrame"
).
toInt
();
if
(
frame
==
-
1
)
{
frame
=
pCore
->
getTimelinePosition
();
}
return
frame
;
}
void
TimelineController
::
insertSpace
(
int
trackId
,
int
frame
)
{
if
(
frame
==
-
1
)
{
frame
=
getMenuOrTimelinePos
();
}
if
(
trackId
==
-
1
)
{
trackId
=
m_activeTrack
;
}
...
...
@@ -1553,7 +1562,7 @@ void TimelineController::insertSpace(int trackId, int frame)
void
TimelineController
::
removeSpace
(
int
trackId
,
int
frame
,
bool
affectAllTracks
)
{
if
(
frame
==
-
1
)
{
frame
=
pCore
->
get
TimelinePos
ition
();
frame
=
getMenuOr
TimelinePos
();
}
if
(
trackId
==
-
1
)
{
trackId
=
m_activeTrack
;
...
...
src/timeline2/view/timelinecontroller.h
View file @
6007d573
...
...
@@ -547,6 +547,7 @@ private:
void
initializePreview
();
bool
darkBackground
()
const
;
int
getMenuOrTimelinePos
()
const
;
signals:
void
selected
(
Mlt
::
Producer
*
producer
);
...
...
src/timeline2/view/timelinewidget.cpp
View file @
6007d573
...
...
@@ -326,6 +326,10 @@ void TimelineWidget::slotUngrabHack()
// https://phabricator.kde.org/D5515
if
(
quickWindow
()
&&
quickWindow
()
->
mouseGrabberItem
())
{
quickWindow
()
->
mouseGrabberItem
()
->
ungrabMouse
();
// Reset menu position
QTimer
::
singleShot
(
200
,
this
,
[
this
]()
{
rootObject
()
->
setProperty
(
"mainFrame"
,
-
1
);
});
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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