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
d906769b
Commit
d906769b
authored
Jun 05, 2020
by
Jean-Baptiste Mardelle
Browse files
Fix loop clip always disabled.
Fixes
#251
parent
c77cb396
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/mainwindow.cpp
View file @
d906769b
...
...
@@ -287,7 +287,10 @@ void MainWindow::init()
connect
(
m_projectMonitor
,
&
Monitor
::
deleteMarker
,
this
,
&
MainWindow
::
slotDeleteGuide
);
connect
(
m_projectMonitor
,
&
Monitor
::
seekToPreviousSnap
,
this
,
&
MainWindow
::
slotSnapRewind
);
connect
(
m_projectMonitor
,
&
Monitor
::
seekToNextSnap
,
this
,
&
MainWindow
::
slotSnapForward
);
connect
(
m_loopClip
,
&
QAction
::
triggered
,
m_projectMonitor
,
&
Monitor
::
slotLoopClip
);
connect
(
m_loopClip
,
&
QAction
::
triggered
,
[
&
]()
{
QPoint
inOut
=
getMainTimeline
()
->
controller
()
->
selectionInOut
();
m_projectMonitor
->
slotLoopClip
(
inOut
);
});
pCore
->
monitorManager
()
->
initMonitors
(
m_clipMonitor
,
m_projectMonitor
);
connect
(
m_clipMonitor
,
&
Monitor
::
addMasterEffect
,
pCore
->
bin
(),
&
Bin
::
slotAddEffect
);
...
...
@@ -2118,8 +2121,10 @@ void MainWindow::connectDocument()
m_projectMonitor
->
slotLoadClipZone
(
project
->
zone
());
connect
(
m_projectMonitor
,
&
Monitor
::
multitrackView
,
getMainTimeline
()
->
controller
(),
&
TimelineController
::
slotMultitrackView
,
Qt
::
UniqueConnection
);
connect
(
m_projectMonitor
,
&
Monitor
::
activateTrack
,
getMainTimeline
()
->
controller
(),
&
TimelineController
::
activateTrackAndSelect
,
Qt
::
UniqueConnection
);
connect
(
getMainTimeline
()
->
controller
(),
&
TimelineController
::
timelineClipSelected
,
pCore
->
library
(),
&
LibraryWidget
::
enableAddSelection
,
Qt
::
UniqueConnection
);
connect
(
getMainTimeline
()
->
controller
(),
&
TimelineController
::
timelineClipSelected
,
[
&
]
(
bool
selected
)
{
m_loopClip
->
setEnabled
(
selected
);
pCore
->
library
()
->
enableAddSelection
(
selected
);
});
connect
(
pCore
->
library
(),
&
LibraryWidget
::
saveTimelineSelection
,
getMainTimeline
()
->
controller
(),
&
TimelineController
::
saveTimelineSelection
,
Qt
::
UniqueConnection
);
connect
(
pCore
->
monitorManager
(),
&
MonitorManager
::
frameDisplayed
,
[
&
](
const
SharedFrame
&
frame
)
{
...
...
src/monitor/glwidget.cpp
View file @
d906769b
...
...
@@ -91,6 +91,7 @@ GLWidget::GLWidget(int id, QObject *parent)
,
m_sendFrame
(
false
)
,
m_isZoneMode
(
false
)
,
m_isLoopMode
(
false
)
,
m_loopIn
(
0
)
,
m_offset
(
QPoint
(
0
,
0
))
,
m_fbo
(
nullptr
)
,
m_shareContext
(
nullptr
)
...
...
@@ -690,14 +691,14 @@ bool GLWidget::checkFrameNumber(int pos, int offset, bool isPlaying)
{
const
double
speed
=
m_producer
->
get_speed
();
m_proxy
->
positionFromConsumer
(
pos
,
isPlaying
);
int
maxPos
=
(
m_isZoneMode
||
m_isLoopMode
)
?
m_proxy
->
zoneOut
()
:
m_producer
->
get_int
(
"out"
);
int
maxPos
=
m_producer
->
get_int
(
"out"
);
if
(
m_isLoopMode
||
m_isZoneMode
)
{
if
(
isPlaying
&&
pos
>=
maxPos
)
{
m_consumer
->
purge
();
if
(
!
m_isLoopMode
)
{
return
false
;
}
m_producer
->
seek
(
m_proxy
->
zoneIn
());
m_producer
->
seek
(
m_isZoneMode
?
m_proxy
->
zoneIn
()
:
m_loopIn
);
m_producer
->
set_speed
(
1.0
);
m_consumer
->
set
(
"refresh"
,
1
);
return
true
;
...
...
@@ -1624,7 +1625,7 @@ void GLWidget::switchPlay(bool play, double speed)
if
(
!
m_producer
||
!
m_consumer
)
{
return
;
}
if
(
m_isZoneMode
)
{
if
(
m_isZoneMode
||
m_isLoopMode
)
{
resetZoneMode
();
}
if
(
play
)
{
...
...
@@ -1669,23 +1670,24 @@ bool GLWidget::playZone(bool loop)
return
true
;
}
bool
GLWidget
::
loopClip
()
bool
GLWidget
::
loopClip
(
QPoint
inOut
)
{
if
(
!
m_producer
||
m_proxy
->
zone
Out
()
<=
m_proxy
->
zoneIn
())
{
pCore
->
displayMessage
(
i18n
(
"Select a
zone
to play"
),
InformationMessage
,
500
);
if
(
!
m_producer
||
in
Out
.
y
()
<=
inOut
.
x
())
{
pCore
->
displayMessage
(
i18n
(
"Select a
clip
to play"
),
InformationMessage
,
500
);
return
false
;
}
m_producer
->
seek
(
0
);
m_loopIn
=
inOut
.
x
();
m_producer
->
seek
(
inOut
.
x
());
m_producer
->
set_speed
(
0
);
m_consumer
->
purge
();
m_producer
->
set
(
"out"
,
m_producer
->
get_playtime
());
m_producer
->
set
(
"out"
,
inOut
.
y
());
m_producer
->
set_speed
(
1.0
);
if
(
m_consumer
->
is_stopped
())
{
m_consumer
->
start
();
}
m_consumer
->
set
(
"scrub_audio"
,
0
);
m_consumer
->
set
(
"refresh"
,
1
);
m_isZoneMode
=
tru
e
;
m_isZoneMode
=
fals
e
;
m_isLoopMode
=
true
;
return
true
;
}
...
...
@@ -1696,6 +1698,7 @@ void GLWidget::resetZoneMode()
return
;
}
m_producer
->
set
(
"out"
,
m_producer
->
get_length
());
m_loopIn
=
0
;
m_isZoneMode
=
false
;
m_isLoopMode
=
false
;
}
...
...
@@ -1745,7 +1748,7 @@ void GLWidget::stop()
// why this lock?
QMutexLocker
locker
(
&
m_mltMutex
);
if
(
m_producer
)
{
if
(
m_isZoneMode
)
{
if
(
m_isZoneMode
||
m_isLoopMode
)
{
resetZoneMode
();
}
m_producer
->
set_speed
(
0.0
);
...
...
src/monitor/glwidget.h
View file @
d906769b
...
...
@@ -123,7 +123,7 @@ public:
void
setRulerInfo
(
int
duration
,
const
std
::
shared_ptr
<
MarkerListModel
>
&
model
=
nullptr
);
MonitorProxy
*
getControllerProxy
();
bool
playZone
(
bool
loop
=
false
);
bool
loopClip
();
bool
loopClip
(
QPoint
inOut
);
void
startConsumer
();
void
stop
();
int
rulerHeight
()
const
;
...
...
@@ -231,6 +231,7 @@ private:
bool
m_sendFrame
;
bool
m_isZoneMode
;
bool
m_isLoopMode
;
int
m_loopIn
;
QPoint
m_offset
;
MonitorProxy
*
m_proxy
;
std
::
shared_ptr
<
Mlt
::
Producer
>
m_blackClip
;
...
...
src/monitor/monitor.cpp
View file @
d906769b
...
...
@@ -1373,10 +1373,10 @@ void Monitor::slotLoopZone()
}
}
void
Monitor
::
slotLoopClip
()
void
Monitor
::
slotLoopClip
(
QPoint
inOut
)
{
slotActivateMonitor
();
bool
ok
=
m_glMonitor
->
loopClip
();
bool
ok
=
m_glMonitor
->
loopClip
(
inOut
);
if
(
ok
)
{
m_playAction
->
setActive
(
true
);
}
...
...
src/monitor/monitor.h
View file @
d906769b
...
...
@@ -289,7 +289,7 @@ public slots:
void
slotPlayZone
();
void
slotLoopZone
();
/** @brief Loops the selected item (clip or transition). */
void
slotLoopClip
();
void
slotLoopClip
(
QPoint
inOut
);
void
slotForward
(
double
speed
=
0
,
bool
allowNormalPlay
=
false
)
override
;
void
slotRewind
(
double
speed
=
0
)
override
;
void
slotRewindOneFrame
(
int
diff
=
1
);
...
...
src/timeline2/view/qml/timeline.qml
View file @
d906769b
...
...
@@ -789,7 +789,7 @@ Rectangle {
}
onPressed
:
{
focus
=
true
shiftPress
=
(
mouse
.
modifiers
&
Qt
.
ShiftModifier
)
&&
(
mouse
.
y
>
ruler
.
height
)
shiftPress
=
(
mouse
.
modifiers
&
Qt
.
ShiftModifier
)
&&
(
mouse
.
y
>
ruler
.
height
)
&&
!
(
mouse
.
modifiers
&
Qt
.
AltModifier
)
if
(
mouse
.
buttons
===
Qt
.
MidButton
||
(
root
.
activeTool
==
0
&&
(
mouse
.
modifiers
&
Qt
.
ControlModifier
)
&&
!
shiftPress
))
{
clickX
=
mouseX
clickY
=
mouseY
...
...
@@ -1060,7 +1060,7 @@ Rectangle {
enabled
:
root
.
activeTool
==
0
onPressed
:
{
console
.
log
(
'
+++++++++++++++++++ DRAG CLICKED +++++++++++++
'
)
if
(
mouse
.
modifiers
&
Qt
.
ControlModifier
||
mouse
.
modifiers
&
Qt
.
ShiftModifier
)
{
if
(
mouse
.
modifiers
&
Qt
.
ControlModifier
||
(
mouse
.
modifiers
&
Qt
.
ShiftModifier
&&
!
(
mouse
.
modifiers
&
Qt
.
AltModifier
))
)
{
mouse
.
accepted
=
false
console
.
log
(
'
+++++++++++++++++++ Shift abort+++++++++++++
'
)
return
...
...
@@ -1071,7 +1071,7 @@ Rectangle {
return
}
dragFrame
=
-
1
moveMirrorTracks
=
!
(
mouse
.
modifiers
&
Qt
.
MetaModifier
)
moveMirrorTracks
=
!
(
mouse
.
modifiers
&
Qt
.
MetaModifier
)
&&
!
(
mouse
.
modifiers
==
(
Qt
.
ShiftModifier
|
Qt
.
AltModifier
))
timeline
.
activeTrack
=
dragProxy
.
sourceTrack
if
(
timeline
.
selection
.
indexOf
(
dragProxy
.
draggedItem
)
==
-
1
)
{
controller
.
requestAddToSelection
(
dragProxy
.
draggedItem
,
/*clear=*/
true
)
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
d906769b
...
...
@@ -2656,6 +2656,35 @@ void TimelineController::editItemDuration(int id)
}
}
QPoint
TimelineController
::
selectionInOut
()
const
{
std
::
unordered_set
<
int
>
ids
=
m_model
->
getCurrentSelection
();
std
::
unordered_set
<
int
>
items_list
;
for
(
int
i
:
ids
)
{
if
(
m_model
->
isGroup
(
i
))
{
std
::
unordered_set
<
int
>
children
=
m_model
->
m_groups
->
getLeaves
(
i
);
items_list
.
insert
(
children
.
begin
(),
children
.
end
());
}
else
{
items_list
.
insert
(
i
);
}
}
int
in
=
-
1
;
int
out
=
-
1
;
for
(
int
id
:
items_list
)
{
if
(
m_model
->
isClip
(
id
)
||
m_model
->
isComposition
(
id
))
{
int
itemIn
=
m_model
->
getItemPosition
(
id
);
int
itemOut
=
itemIn
+
m_model
->
getItemPlaytime
(
id
);
if
(
in
<
0
||
itemIn
<
in
)
{
in
=
itemIn
;
}
if
(
itemOut
>
out
)
{
out
=
itemOut
;
}
}
}
return
QPoint
(
in
,
out
);
}
void
TimelineController
::
updateClipActions
()
{
if
(
m_model
->
getCurrentSelection
().
empty
())
{
...
...
src/timeline2/view/timelinecontroller.h
View file @
d906769b
...
...
@@ -528,6 +528,8 @@ public:
void
collapseActiveTrack
();
/** @brief Expand MLT playlist to its contained clips/compositions */
void
expandActiveClip
();
/** @brief Get in/out of currently selected items */
QPoint
selectionInOut
()
const
;
public
slots
:
void
resetView
();
...
...
Write
Preview
Supports
Markdown
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