aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2016-05-25 10:05:02 +0200
committerJean-Baptiste Mardelle <[email protected]>2016-05-25 10:05:02 +0200
commitb6fd9fbc11a171ef8eaff860c84bcdb884abd221 (patch)
tree18d0d316c015ba2b0706068dfeb67098bdad896c
parent07b44df26b4f0267a38c72a10c8db419f5374a15 (diff)
integrate track hide/mute to undo system
Ref: T1949
-rw-r--r--src/timeline/customtrackview.cpp13
-rw-r--r--src/timeline/customtrackview.h2
-rw-r--r--src/timeline/headertrack.cpp16
-rw-r--r--src/timeline/headertrack.h2
-rw-r--r--src/timeline/timeline.cpp42
-rw-r--r--src/timeline/timeline.h9
-rw-r--r--src/timeline/timelinecommands.cpp28
-rw-r--r--src/timeline/timelinecommands.h15
8 files changed, 98 insertions, 29 deletions
diff --git a/src/timeline/customtrackview.cpp b/src/timeline/customtrackview.cpp
index 6959e15..1dd86be 100644
--- a/src/timeline/customtrackview.cpp
+++ b/src/timeline/customtrackview.cpp
@@ -3679,11 +3679,6 @@ void CustomTrackView::configTracks(const QList < TrackInfo > &trackInfos)
viewport()->update();
}
-void CustomTrackView::slotSwitchTrackAudio(int ix, bool enable)
-{
- m_timeline->switchTrackAudio(ix, enable);
-}
-
void CustomTrackView::slotSwitchTrackLock(int ix, bool enable, bool applyToAll)
{
QUndoCommand *command = NULL;
@@ -3776,14 +3771,6 @@ void CustomTrackView::lockTrack(int ix, bool lock, bool requestUpdate)
viewport()->update();
}
-void CustomTrackView::slotSwitchTrackVideo(int ix, bool enable)
-{
- m_timeline->switchTrackVideo(ix, enable);
- m_document->renderer()->doRefresh();
- //TODO: create undo/redo command for this
- setDocumentModified();
-}
-
QList<QGraphicsItem *> CustomTrackView::checkForGroups(const QRectF &rect, bool *ok)
{
// Check there is no group going over several tracks there, or that would result in timeline corruption
diff --git a/src/timeline/customtrackview.h b/src/timeline/customtrackview.h
index 0da67c5..896a5ef 100644
--- a/src/timeline/customtrackview.h
+++ b/src/timeline/customtrackview.h
@@ -278,8 +278,6 @@ public slots:
void slotAddTransition(ClipItem* clip, ItemInfo transitionInfo, int endTrack, QDomElement transition = QDomElement());
void slotAddTransitionToSelectedClips(QDomElement transition, QList<QGraphicsItem *> itemList = QList<QGraphicsItem *>());
void slotTransitionUpdated(Transition *, QDomElement);
- void slotSwitchTrackAudio(int ix, bool enable);
- void slotSwitchTrackVideo(int ix, bool enable);
void slotSwitchTrackLock(int ix, bool enable, bool applyToAll = false);
void slotUpdateClip(const QString &clipId, bool reload = true);
diff --git a/src/timeline/headertrack.cpp b/src/timeline/headertrack.cpp
index b4353a5..edc872f 100644
--- a/src/timeline/headertrack.cpp
+++ b/src/timeline/headertrack.cpp
@@ -271,6 +271,22 @@ void HeaderTrack::switchLock(bool enable)
emit switchTrackLock(m_parentTrack->index(), enable);
}
+void HeaderTrack::setVideoMute(bool mute)
+{
+ m_switchVideo->blockSignals(true);
+ m_switchVideo->setActive(mute);
+ m_switchVideo->blockSignals(false);
+ updateLed();
+}
+
+void HeaderTrack::setAudioMute(bool mute)
+{
+ m_switchVideo->blockSignals(true);
+ m_switchVideo->setActive(mute);
+ m_switchVideo->blockSignals(false);
+ updateLed();
+}
+
void HeaderTrack::setLock(bool lock)
{
m_switchLock->blockSignals(true);
diff --git a/src/timeline/headertrack.h b/src/timeline/headertrack.h
index 51b6c66..9421618 100644
--- a/src/timeline/headertrack.h
+++ b/src/timeline/headertrack.h
@@ -53,6 +53,8 @@ public:
void refreshPalette();
void switchTarget(bool enable);
void updateLed();
+ void setVideoMute(bool mute);
+ void setAudioMute(bool mute);
protected:
void mousePressEvent(QMouseEvent * event);
diff --git a/src/timeline/timeline.cpp b/src/timeline/timeline.cpp
index ded5da1..0b27dd8 100644
--- a/src/timeline/timeline.cpp
+++ b/src/timeline/timeline.cpp
@@ -316,8 +316,8 @@ int Timeline::getTracks() {
if (trackduration > duration) duration = trackduration;
tk->trackHeader->setSelectedIndex(m_trackview->selectedTrack());
connect(tk->trackHeader, &HeaderTrack::switchTrackComposite, this, &Timeline::slotSwitchTrackComposite);
- connect(tk->trackHeader, SIGNAL(switchTrackVideo(int,bool)), m_trackview, SLOT(slotSwitchTrackVideo(int,bool)));
- connect(tk->trackHeader, SIGNAL(switchTrackAudio(int,bool)), m_trackview, SLOT(slotSwitchTrackAudio(int,bool)));
+ connect(tk->trackHeader, SIGNAL(switchTrackVideo(int,bool)), this, SLOT(switchTrackVideo(int,bool)));
+ connect(tk->trackHeader, SIGNAL(switchTrackAudio(int,bool)), this, SLOT(switchTrackAudio(int,bool)));
connect(tk->trackHeader, SIGNAL(switchTrackLock(int,bool)), m_trackview, SLOT(slotSwitchTrackLock(int,bool)));
connect(tk->trackHeader, SIGNAL(selectTrack(int,bool)), m_trackview, SLOT(slotSelectTrack(int,bool)));
connect(tk->trackHeader, SIGNAL(renameTrack(int,QString)), this, SLOT(slotRenameTrack(int,QString)));
@@ -698,37 +698,53 @@ void Timeline::updateTrackState(int ix, int state)
QScopedPointer<Mlt::Producer> track(m_tractor->track(ix));
currentState = track->get_int("hide");
if (state == currentState) return;
+ bool processAudio = false;
+ bool hideAudio = false;
+ bool processVideo = false;
+ bool hideVideo = false;
if (state == 0) {
// Show all
if (currentState & 1) {
- switchTrackVideo(ix, false);
+ doSwitchTrackVideo(ix, false);
}
if (currentState & 2) {
- switchTrackAudio(ix, false);
+ doSwitchTrackAudio(ix, false);
}
}
else if (state == 1) {
// Mute video
if (currentState & 2) {
- switchTrackAudio(ix, false);
+ doSwitchTrackAudio(ix, false);
}
- switchTrackVideo(ix, true);
+ doSwitchTrackVideo(ix, true);
}
else if (state == 2) {
// Mute audio
if (currentState & 1) {
- switchTrackVideo(ix, false);
+ doSwitchTrackVideo(ix, false);
}
- switchTrackAudio(ix, true);
+ doSwitchTrackAudio(ix, true);
}
else {
- switchTrackVideo(ix, true);
- switchTrackAudio(ix, true);
+ doSwitchTrackVideo(ix, true);
+ doSwitchTrackAudio(ix, true);
}
}
void Timeline::switchTrackVideo(int ix, bool hide)
{
+ QUndoCommand *trackState = new ChangeTrackStateCommand(this, ix, false, true, false, hide);
+ m_doc->commandStack()->push(trackState);
+}
+
+void Timeline::switchTrackAudio(int ix, bool hide)
+{
+ QUndoCommand *trackState = new ChangeTrackStateCommand(this, ix, true, false, hide, false);
+ m_doc->commandStack()->push(trackState);
+}
+
+void Timeline::doSwitchTrackVideo(int ix, bool hide)
+{
Track* tk = track(ix);
if (tk == NULL) {
qWarning() << "Set Track effect outisde of range: "<<ix;
@@ -739,6 +755,7 @@ void Timeline::switchTrackVideo(int ix, bool hide)
// Video is already muted
return;
}
+ tk->trackHeader->setVideoMute(hide);
int newstate = 0;
if (hide) {
if (state & 2) {
@@ -759,6 +776,7 @@ void Timeline::switchTrackVideo(int ix, bool hide)
tk->setState(newstate);
invalidateTrack(ix);
refreshTractor();
+ m_doc->renderer()->doRefresh();
}
void Timeline::slotSwitchTrackComposite(int trackIndex, bool enable)
@@ -793,7 +811,7 @@ void Timeline::refreshTractor()
m_tractor->refresh();
}
-void Timeline::switchTrackAudio(int ix, bool mute)
+void Timeline::doSwitchTrackAudio(int ix, bool mute)
{
Track* tk = track(ix);
if (tk == NULL) {
@@ -805,6 +823,7 @@ void Timeline::switchTrackAudio(int ix, bool mute)
// audio is already muted
return;
}
+ tk->trackHeader->setAudioMute(mute);
if (mute && state < 2 ) {
// We mute a track with sound
/*if (ix == getLowestNonMutedAudioTrack())*/
@@ -1822,7 +1841,6 @@ void Timeline::updatePreviewSettings(const QString &profile)
if (profile.isEmpty()) return;
QString params = profile.section(";", 0, 0);
QString ext = profile.section(";", 1, 1);
- qDebug()<<" / / /NEW TP: "<<params<<"\nEXR: "<<ext;
if (params != m_doc->getDocumentProperty(QStringLiteral("previewparameters")) || ext != m_doc->getDocumentProperty(QStringLiteral("previewextension"))) {
// Timeline preview params changed, delete all existing previews.
invalidateRange(ItemInfo());
diff --git a/src/timeline/timeline.h b/src/timeline/timeline.h
index 386f2d9..82b2736 100644
--- a/src/timeline/timeline.h
+++ b/src/timeline/timeline.h
@@ -79,9 +79,9 @@ public:
void lockTrack(int ix, bool lock);
bool isTrackLocked(int ix);
/** @brief Dis / enable video for a track. */
- void switchTrackVideo(int ix, bool hide);
+ void doSwitchTrackVideo(int ix, bool hide);
/** @brief Dis / enable audio for a track. */
- void switchTrackAudio(int ix, bool mute);
+ void doSwitchTrackAudio(int ix, bool mute);
/** @brief Adjust audio transitions depending on tracks muted state. */
void fixAudioMixing();
@@ -255,6 +255,11 @@ private slots:
void slotUpdateTrackEffectState(int);
/** @brief Toggle use of timeline zone for editing.*/
void slotEnableZone(bool enable);
+ /** @brief Dis / enable video for a track. */
+ void switchTrackVideo(int ix, bool hide);
+ /** @brief Dis / enable audio for a track. */
+ void switchTrackAudio(int ix, bool mute);
+
signals:
void mousePosition(int);
diff --git a/src/timeline/timelinecommands.cpp b/src/timeline/timelinecommands.cpp
index 0bcfda0..b0ed428 100644
--- a/src/timeline/timelinecommands.cpp
+++ b/src/timeline/timelinecommands.cpp
@@ -804,3 +804,31 @@ void SplitAudioCommand::redo()
m_view->doSplitAudio(m_pos, m_track, m_destTrack, true);
}
+ChangeTrackStateCommand::ChangeTrackStateCommand(Timeline *timeline, const int track, bool changeAudio, bool changeVideo, bool hideAudio, bool hideVideo, QUndoCommand * parent) :
+ QUndoCommand(parent)
+ , m_timeline(timeline)
+ , m_track(track)
+ , m_audio(changeAudio)
+ , m_video(changeVideo)
+ , m_hideAudio(hideAudio)
+ , m_hideVideo(hideVideo)
+{
+ setText(i18n("Change track state"));
+}
+// virtual
+void ChangeTrackStateCommand::undo()
+{
+ if (m_audio)
+ m_timeline->doSwitchTrackAudio(m_track, !m_hideAudio);
+ if (m_video)
+ m_timeline->doSwitchTrackVideo(m_track, !m_hideVideo);
+}
+// virtual
+void ChangeTrackStateCommand::redo()
+{
+ if (m_audio)
+ m_timeline->doSwitchTrackAudio(m_track, m_hideAudio);
+ if (m_video)
+ m_timeline->doSwitchTrackVideo(m_track, m_hideVideo);
+}
+
diff --git a/src/timeline/timelinecommands.h b/src/timeline/timelinecommands.h
index c8d223d..a59b80d 100644
--- a/src/timeline/timelinecommands.h
+++ b/src/timeline/timelinecommands.h
@@ -438,5 +438,20 @@ private:
const int m_destTrack;
};
+class ChangeTrackStateCommand : public QUndoCommand
+{
+public:
+ ChangeTrackStateCommand(Timeline *timeline, const int track, bool changeAudio, bool changeVideo, bool hideAudio, bool hideVideo, QUndoCommand * parent = 0);
+ void undo();
+ void redo();
+private:
+ Timeline *m_timeline;
+ const int m_track;
+ bool m_audio;
+ bool m_video;
+ bool m_hideAudio;
+ bool m_hideVideo;
+};
+
#endif