Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix lock track and set target track

parent d24e3e9b
......@@ -779,20 +779,17 @@ void ProjectManager::slotDisableTimelineEffects(bool disable)
void ProjectManager::slotSwitchTrackLock()
{
// TODO refac
// m_trackView->projectView()->switchTrackLock();
pCore->window()->getMainTimeline()->controller()->switchTrackLock();
}
void ProjectManager::slotSwitchAllTrackLock()
{
// TODO refac
// m_trackView->projectView()->switchAllTrackLock();
pCore->window()->getMainTimeline()->controller()->switchTrackLock(true);
}
void ProjectManager::slotSwitchTrackTarget()
{
// TODO refac
// m_trackView->switchTrackTarget();
pCore->window()->getMainTimeline()->controller()->switchTargetTrack();
}
QString ProjectManager::getDefaultProjectFormat()
......
......@@ -370,7 +370,7 @@ bool TimelineFunctions::changeClipState(std::shared_ptr<TimelineItemModel> timel
return result;
}
bool TimelineFunctions::requestSplitAudio(std::shared_ptr<TimelineItemModel> timeline, int clipId)
bool TimelineFunctions::requestSplitAudio(std::shared_ptr<TimelineItemModel> timeline, int clipId, int audioTarget)
{
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
......@@ -380,7 +380,7 @@ bool TimelineFunctions::requestSplitAudio(std::shared_ptr<TimelineItemModel> tim
int position = timeline->getClipPosition(cid);
int duration = timeline->getClipPlaytime(cid);
int track = timeline->getClipTrackId(cid);
int newTrack = timeline->getLowerTrackId(track, TrackType::AudioTrack);
int newTrack = audioTarget >= 0 ? audioTarget : timeline->getLowerTrackId(track, TrackType::AudioTrack);
if (newTrack == -1) {
// No available audio track for splitting, abort
undo();
......
......@@ -62,7 +62,7 @@ struct TimelineFunctions
static void showClipKeyframes(std::shared_ptr<TimelineItemModel> timeline, int clipId, bool value);
static void showCompositionKeyframes(std::shared_ptr<TimelineItemModel> timeline, int compoId, bool value);
static bool changeClipState(std::shared_ptr<TimelineItemModel> timeline, int clipId, PlaylistState::ClipState status);
static bool requestSplitAudio(std::shared_ptr<TimelineItemModel> timeline, int clipId);
static bool requestSplitAudio(std::shared_ptr<TimelineItemModel> timeline, int clipId, int audioTarget);
};
#endif
......@@ -751,7 +751,7 @@ QStringList TimelineController::extractCompositionLumas() const
void TimelineController::addEffectToCurrentClip(const QStringList &effectData)
{
QList<int> activeClips;
for (int track = m_model->getTracksCount() - 1; track > 0; track--) {
for (int track = m_model->getTracksCount() - 1; track >= 0; track--) {
int trackIx = m_model->getTrackIndexFromPosition(track);
int cid = m_model->getClipByPosition(trackIx, timelinePosition());
if (cid > -1) {
......@@ -1216,5 +1216,48 @@ void TimelineController::setClipStatus(int clipId, int status)
void TimelineController::splitAudio(int clipId)
{
TimelineFunctions::requestSplitAudio(m_model, clipId);
TimelineFunctions::requestSplitAudio(m_model, clipId, m_audioTarget);
}
void TimelineController::switchTrackLock(bool applyToAll)
{
if (!applyToAll) {
// apply to active track only
bool locked = m_model->getTrackById_const(m_activeTrack)->getProperty("kdenlive:locked_track").toInt() == 1;
m_model->setTrackProperty(m_activeTrack, QStringLiteral("kdenlive:locked_track"), locked ? QStringLiteral("0") : QStringLiteral("1"));
}
else {
// Invert track lock
// Get track states first
QMap<int, bool> trackLockState;
int unlockedTracksCount = 0;
int tracksCount = m_model->getTracksCount();
for (int track = tracksCount - 1; track >= 0; track--) {
int trackIx = m_model->getTrackIndexFromPosition(track);
bool isLocked = m_model->getTrackById_const(trackIx)->getProperty("kdenlive:locked_track").toInt() == 1;
if (!isLocked) {
unlockedTracksCount++;
}
trackLockState.insert(trackIx, isLocked);
}
if (unlockedTracksCount == tracksCount) {
// do not lock all tracks, leave active track unlocked
trackLockState.insert(m_activeTrack, true);
}
QMapIterator<int, bool> i(trackLockState);
while (i.hasNext()) {
i.next();
m_model->setTrackProperty(i.key(), QStringLiteral("kdenlive:locked_track"), i.value() ? QStringLiteral("0") : QStringLiteral("1"));
}
}
}
void TimelineController::switchTargetTrack()
{
bool isAudio = m_model->getTrackById_const(m_activeTrack)->getProperty("kdenlive:audio_track").toInt() == 1;
if (isAudio) {
setAudioTarget(m_audioTarget == m_activeTrack ? -1 : m_activeTrack);
} else {
setVideoTarget(m_videoTarget == m_activeTrack ? -1 : m_activeTrack);
}
}
......@@ -236,6 +236,8 @@ public:
Q_INVOKABLE void extract(int clipId);
Q_INVOKABLE void splitAudio(int clipId);
void switchTrackLock(bool applyToAll = false);
void switchTargetTrack();
const QString getTrackNameFromIndex(int trackIndex);
/* @brief Seeks to selected clip start / end
......
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