Commit dc6568b9 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Add action to popup the target stream menu (in menu Timeline > Tracks > Switch...

Add action to popup the target stream menu (in menu Timeline > Tracks > Switch Target Track Audio Stream)
to enable shortcut activation
parent 5c6913c7
Pipeline #20739 canceled with stage
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="180" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="181" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="dvd_wizard" />
......@@ -136,6 +136,7 @@
<Action name="master_effects" />
<Action name="insert_track" />
<Action name="delete_track" />
<Action name="switch_target_stream" />
<Separator />
<Action name="select_track" />
<Action name="select_all_tracks" />
......
......@@ -1633,6 +1633,10 @@ void MainWindow::setupActions()
});
timelineActions->addAction(QStringLiteral("master_effects"), masterEffectStack);
QAction *switchTrackTarget = new QAction(QIcon(), i18n("Switch Track Target Audio Stream"), this);
connect(switchTrackTarget, &QAction::triggered, this, &MainWindow::slotSwitchTrackAudioStream);
timelineActions->addAction(QStringLiteral("switch_target_stream"), switchTrackTarget);
QAction *deleteTrack = new QAction(QIcon(), i18n("Delete Track"), this);
connect(deleteTrack, &QAction::triggered, this, &MainWindow::slotDeleteTrack);
timelineActions->addAction(QStringLiteral("delete_track"), deleteTrack);
......@@ -2618,6 +2622,11 @@ void MainWindow::slotDeleteTrack()
getCurrentTimeline()->controller()->deleteTrack(-1);
}
void MainWindow::slotSwitchTrackAudioStream()
{
getCurrentTimeline()->showTargetMenu();
}
void MainWindow::slotShowTrackRec()
{
getCurrentTimeline()->controller()->switchTrackRecord();
......
......@@ -384,6 +384,8 @@ private slots:
void slotSeparateAudioChannel();
void slotInsertTrack();
void slotDeleteTrack();
/** @brief Show context menu to switch current track target audio stream. */
void slotSwitchTrackAudioStream();
void slotShowTrackRec();
/** @brief Select all clips in active track. */
void slotSelectTrack();
......
......@@ -58,6 +58,10 @@ Rectangle {
mainItemId = -1
}
}
function getActiveTrackStreamPos() {
return Logic.getTrackYFromId(timeline.activeTrack) + rulercontainer.height
}
function updatePalette() {
root.color = activePalette.window
......
......@@ -264,10 +264,24 @@ void TimelineWidget::showHeaderMenu()
m_headerMenu->popup(m_clickPos);
}
void TimelineWidget::showTargetMenu(int ix)
void TimelineWidget::showTargetMenu(int tid)
{
int currentTargetStream;
QMap<int, QString> possibleTargets = m_proxy->getCurrentTargets(ix, currentTargetStream);
if (tid == -1) {
// Called through shortcut
tid = m_proxy->activeTrack();
if (tid == -1) {
return;
}
if (m_proxy->clipTargets() < 2 || !model()->isAudioTrack(tid)) {
pCore->displayMessage(i18n("No available stream"), MessageType::InformationMessage);
return;
}
QVariant returnedValue;
QMetaObject::invokeMethod(rootObject(), "getActiveTrackStreamPos", Q_RETURN_ARG(QVariant, returnedValue));
m_clickPos = QPoint(5, mapToGlobal(QPoint(0, y())).y() + returnedValue.toInt());
}
QMap<int, QString> possibleTargets = m_proxy->getCurrentTargets(tid, currentTargetStream);
m_targetsMenu->clear();
if (m_targetsGroup) {
delete m_targetsGroup;
......@@ -284,9 +298,9 @@ void TimelineWidget::showTargetMenu(int ix)
ac->setChecked(true);
}
}
connect(m_targetsGroup, &QActionGroup::triggered, [this, ix] (QAction *action) {
connect(m_targetsGroup, &QActionGroup::triggered, [this, tid] (QAction *action) {
int targetStream = action->data().toInt();
m_proxy->assignAudioTarget(ix, targetStream);
m_proxy->assignAudioTarget(tid, targetStream);
});
if (m_targetsMenu->isEmpty() || possibleTargets.isEmpty()) {
m_headerMenu->popup(m_clickPos);
......
......@@ -72,6 +72,8 @@ public slots:
void updateTransitionFavorites();
/* @brief Bin clip drag ended, make sure we correctly processed the drop */
void endDrag();
/* @brief Show menu to switch track target audio stream */
void showTargetMenu(int tid = -1);
private slots:
void slotUngrabHack();
......@@ -80,7 +82,6 @@ private slots:
void showTimelineMenu();
void showRulerMenu();
void showHeaderMenu();
void showTargetMenu(int ix);
private:
TimelineController *m_proxy;
......
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