Add option to sort audio tracks in reverse order

https://phabricator.kde.org/T11116
parent 0b7e2df7
Pipeline #4787 passed with stage
in 14 minutes and 6 seconds
......@@ -278,9 +278,9 @@
<default>0</default>
</entry>
<entry name="audiotracksbelow" type="Bool">
<entry name="audiotracksbelow" type="Int">
<label>Display audio tracks grouped below video tracks.</label>
<default>true</default>
<default>1</default>
</entry>
<entry name="raisepropsclips" type="Bool">
......
......@@ -952,17 +952,24 @@ void MainWindow::setupActions()
addAction(QStringLiteral("timeline_view_split"), splitView);
splitView->setData(QVariant::fromValue(1));
splitView->setCheckable(true);
splitView->setChecked(KdenliveSettings::audiotracksbelow());
splitView->setChecked(KdenliveSettings::audiotracksbelow() == 1);
QAction *splitView2 = new QAction(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")), i18n("Split Audio Tracks (reverse)"), this);
addAction(QStringLiteral("timeline_view_split_reverse"), splitView2);
splitView2->setData(QVariant::fromValue(2));
splitView2->setCheckable(true);
splitView2->setChecked(KdenliveSettings::audiotracksbelow() == 2);
QAction *mixedView = new QAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Mixed Audio tracks"), this);
addAction(QStringLiteral("timeline_mixed_view"), mixedView);
mixedView->setData(QVariant::fromValue(0));
mixedView->setCheckable(true);
mixedView->setChecked(!KdenliveSettings::audiotracksbelow());
mixedView->setChecked(KdenliveSettings::audiotracksbelow() == 0);
auto *clipTypeGroup = new QActionGroup(this);
clipTypeGroup->addAction(mixedView);
clipTypeGroup->addAction(splitView);
clipTypeGroup->addAction(splitView2);
connect(clipTypeGroup, &QActionGroup::triggered, this, &MainWindow::slotUpdateTimelineView);
auto tlsettings = new QMenu(this);
......@@ -970,6 +977,7 @@ void MainWindow::setupActions()
tlsettings->addAction(m_compositeAction);
tlsettings->addAction(mixedView);
tlsettings->addAction(splitView);
tlsettings->addAction(splitView2);
QToolButton *timelineSett = new QToolButton(this);
timelineSett->setPopupMode(QToolButton::InstantPopup);
......@@ -2954,7 +2962,7 @@ void MainWindow::slotUpdateClipType(QAction *action)
void MainWindow::slotUpdateTimelineView(QAction *action)
{
int viewMode = action->data().toInt();
KdenliveSettings::setAudiotracksbelow(viewMode == 1);
KdenliveSettings::setAudiotracksbelow(viewMode);
getMainTimeline()->controller()->getModel()->_resetView();
}
......
......@@ -326,11 +326,36 @@ int TimelineModel::getTrackMltIndex(int trackId) const
return getTrackPosition(trackId) + 1;
}
int TimelineModel::getTrackSortValue(int trackId, bool separated) const
int TimelineModel::getTrackSortValue(int trackId, int separated) const
{
if (separated) {
if (separated == 1) {
return getTrackPosition(trackId) + 1;
}
if (separated == 2) {
// Count audio/video tracks
auto it = m_allTracks.cbegin();
int aCount = 0;
int vCount = 0;
int refPos = 0;
bool isVideo = true;
while (it != m_allTracks.cend()) {
if ((*it)->isAudioTrack()) {
if ((*it)->getId() == trackId) {
refPos = aCount;
isVideo = false;
}
aCount++;
} else {
// video track
if ((*it)->getId() == trackId) {
refPos = vCount;
}
vCount++;
}
++it;
}
return isVideo ? aCount + refPos + 1 : aCount - refPos;
}
auto it = m_allTracks.cend();
int aCount = 0;
int vCount = 0;
......
......@@ -305,7 +305,7 @@ public:
* @param separated: if true, the tracks will be sorted like: V2,V1,A1,A2
* Otherwise, the tracks will be sorted like V2,A2,V1,A1
*/
int getTrackSortValue(int trackId, bool separated) const;
int getTrackSortValue(int trackId, int separated) const;
/* @brief Returns the ids of the tracks below the given track in the order of the tracks
Returns an empty list if no track available
......
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