Fix target track inconsistencies:

3 state button, hide when shouldn't be available
parent b264da55
......@@ -1791,6 +1791,7 @@ void Bin::showClipProperties(const std::shared_ptr<ProjectClip> &clip, bool forc
}
m_propertiesPanel->setProperty("clipId", QString());
m_propertiesPanel->setEnabled(false);
emit setupTargets(false, false);
return;
}
m_propertiesPanel->setEnabled(true);
......
......@@ -103,13 +103,14 @@ Rectangle {
}
ColumnLayout {
id: targetColumn
width: root.baseUnit / 1.2
width: root.baseUnit / 1.3
height: trackHeadRoot.height
Item {
width: parent.width
Layout.fillHeight: true
Layout.topMargin: 4
Layout.bottomMargin: 4
Layout.topMargin: 1
Layout.bottomMargin: 1
Layout.leftMargin: 1
Layout.alignment: Qt.AlignVCenter
Rectangle {
id: trackTarget
......@@ -117,6 +118,7 @@ Rectangle {
anchors.fill: parent
width: height
border.width: 0
visible: trackHeadRoot.isAudio ? timeline.hasAudioTarget : timeline.hasVideoTarget
MouseArea {
id: targetArea
anchors.fill: parent
......@@ -162,12 +164,21 @@ Rectangle {
color: 'green'
}
},
State {
name: 'inactiveTarget'
when: (trackHeadRoot.isAudio && trackHeadRoot.trackId == timeline.lastAudioTarget) || (!trackHeadRoot.isAudio && trackHeadRoot.trackId == timeline.lastVideoTarget)
PropertyChanges {
target: trackTarget
opacity: 0.3
color: activePalette.text
}
},
State {
name: 'noTarget'
when: !trackHeadRoot.isLocked && !trackHeadRoot.isDisabled
PropertyChanges {
target: trackTarget
color: 'grey'
color: activePalette.base
}
}
]
......@@ -202,12 +213,14 @@ Rectangle {
Item {
width: trackTag.contentWidth + 4
height: width
Layout.topMargin: 1
Rectangle {
id: trackLed
color: Qt.darker(trackHeadRoot.color, 0.45)
anchors.fill: parent
width: height
border.width: 0
radius: 2
Text {
id: trackTag
text: trackHeadRoot.trackTag
......
......@@ -109,12 +109,16 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
void TimelineController::setTargetTracks(QPair<int, int> targets)
{
//setVideoTarget(targets.first >= 0 && targets.first < m_model->getTracksCount() ? m_model->getTrackIndexFromPosition(targets.first) : -1);
//setAudioTarget(targets.second >= 0 && targets.second < m_model->getTracksCount() ? m_model->getTrackIndexFromPosition(targets.second) : -1);
m_hasVideoTarget = targets.first >= 0;
m_hasAudioTarget = targets.second >= 0;
setVideoTarget(m_hasVideoTarget && (m_lastVideoTarget > -1) ? m_lastVideoTarget : targets.first);
setAudioTarget(m_hasAudioTarget && (m_lastAudioTarget > -1) ? m_lastAudioTarget : targets.second);
emit hasAudioTargetChanged();
emit hasVideoTargetChanged();
if (m_videoTargetActive) {
setVideoTarget(m_hasVideoTarget && (m_lastVideoTarget > -1) ? m_lastVideoTarget : targets.first);
}
if (m_audioTargetActive) {
setAudioTarget(m_hasAudioTarget && (m_lastAudioTarget > -1) ? m_lastAudioTarget : targets.second);
}
}
std::shared_ptr<TimelineItemModel> TimelineController::getModel() const
......@@ -574,6 +578,14 @@ void TimelineController::deleteTrack(int tid)
if (m_model->m_videoTarget == selectedTrackIx) {
setVideoTarget(-1);
}
if (m_lastAudioTarget == selectedTrackIx) {
m_lastAudioTarget = -1;
emit lastAudioTargetChanged();
}
if (m_lastVideoTarget == selectedTrackIx) {
m_lastVideoTarget = -1;
emit lastVideoTargetChanged();
}
m_model->requestTrackDeletion(selectedTrackIx);
m_model->buildTrackCompositing(true);
if (m_activeTrack == -1) {
......@@ -917,7 +929,7 @@ void TimelineController::setPosition(int position)
void TimelineController::setAudioTarget(int track)
{
if (track > -1 && !m_model->isTrack(track)) {
if (track > -1 && !m_model->isTrack(track) || !m_hasAudioTarget) {
return;
}
m_model->m_audioTarget = track;
......@@ -926,7 +938,7 @@ void TimelineController::setAudioTarget(int track)
void TimelineController::setVideoTarget(int track)
{
if (track > -1 && !m_model->isTrack(track)) {
if (track > -1 && !m_model->isTrack(track) || !m_hasVideoTarget) {
return;
}
m_model->m_videoTarget = track;
......@@ -2569,6 +2581,7 @@ void TimelineController::updateVideoTarget()
if (videoTarget() > -1) {
m_lastVideoTarget = videoTarget();
m_videoTargetActive = true;
emit lastVideoTargetChanged();
} else {
m_videoTargetActive = false;
}
......@@ -2579,6 +2592,7 @@ void TimelineController::updateAudioTarget()
if (audioTarget() > -1) {
m_lastAudioTarget = audioTarget();
m_audioTargetActive = true;
emit lastAudioTargetChanged();
} else {
m_audioTargetActive = false;
}
......
......@@ -67,8 +67,12 @@ class TimelineController : public QObject
Q_PROPERTY(int activeTrack READ activeTrack WRITE setActiveTrack NOTIFY activeTrackChanged)
Q_PROPERTY(int audioTarget READ audioTarget WRITE setAudioTarget NOTIFY audioTargetChanged)
Q_PROPERTY(int videoTarget READ videoTarget WRITE setVideoTarget NOTIFY videoTargetChanged)
Q_PROPERTY(bool hasAudioTarget READ hasAudioTarget)
Q_PROPERTY(bool hasVideoTarget READ hasVideoTarget)
Q_PROPERTY(int lastAudioTarget MEMBER m_lastAudioTarget NOTIFY lastAudioTargetChanged)
Q_PROPERTY(int lastVideoTarget MEMBER m_lastVideoTarget NOTIFY lastVideoTargetChanged)
Q_PROPERTY(bool hasAudioTarget READ hasAudioTarget NOTIFY hasAudioTargetChanged)
Q_PROPERTY(bool hasVideoTarget READ hasVideoTarget NOTIFY hasVideoTargetChanged)
Q_PROPERTY(QColor videoColor READ videoColor NOTIFY colorsChanged)
Q_PROPERTY(QColor audioColor READ audioColor NOTIFY colorsChanged)
Q_PROPERTY(QColor lockedColor READ lockedColor NOTIFY colorsChanged)
......@@ -533,6 +537,10 @@ signals:
void seekPositionChanged();
void audioTargetChanged();
void videoTargetChanged();
void hasAudioTargetChanged();
void hasVideoTargetChanged();
void lastAudioTargetChanged();
void lastVideoTargetChanged();
void activeTrackChanged();
void colorsChanged();
void showThumbnailsChanged();
......
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