Restore menu entry to enable timeline audio record in track headers

parent ce4d1763
Pipeline #16293 failed with stage
in 12 minutes and 9 seconds
......@@ -560,6 +560,7 @@ void MainWindow::init()
QMenu *timelineHeadersMenu = new QMenu(this);
timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("insert_track")));
timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("delete_track")));
timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("show_track_record")));
QMenu *thumbsMenu = new QMenu(i18n("Thumbnails"), this);
QActionGroup *thumbGroup = new QActionGroup(this);
QAction *inFrame = new QAction(i18n("In Frame"), thumbGroup);
......@@ -1601,6 +1602,12 @@ void MainWindow::setupActions()
timelineActions->addAction(QStringLiteral("delete_track"), deleteTrack);
deleteTrack->setData("delete_track");
QAction *showAudio = new QAction(QIcon(), i18n("Show Record Controls"), this);
connect(showAudio, &QAction::triggered, this, &MainWindow::slotShowTrackRec);
timelineActions->addAction(QStringLiteral("show_track_record"), showAudio);
showAudio->setCheckable(true);
showAudio->setData("show_track_record");
QAction *selectTrack = new QAction(QIcon(), i18n("Select All in Current Track"), this);
connect(selectTrack, &QAction::triggered, this, &MainWindow::slotSelectTrack);
timelineActions->addAction(QStringLiteral("select_track"), selectTrack);
......@@ -2562,6 +2569,11 @@ void MainWindow::slotDeleteTrack()
getCurrentTimeline()->controller()->deleteTrack(-1);
}
void MainWindow::slotShowTrackRec()
{
getCurrentTimeline()->controller()->switchTrackRecord();
}
void MainWindow::slotSelectTrack()
{
getCurrentTimeline()->controller()->selectCurrentTrack();
......
......@@ -382,6 +382,7 @@ private slots:
void configureNotifications();
void slotInsertTrack();
void slotDeleteTrack();
void slotShowTrackRec();
/** @brief Select all clips in active track. */
void slotSelectTrack();
/** @brief Select all clips in timeline. */
......
......@@ -30,7 +30,7 @@ Rectangle {
property bool isLocked: false
property bool isActive: false
property bool isAudio
property bool showAudioRecord
property bool showAudioRecord: false
property bool current: false
property int myTrackHeight
property int trackId : -42
......@@ -309,6 +309,7 @@ Rectangle {
width: childrenRect.width
x: Math.max(2 * trackHeadRoot.buttonSize + 2, parent.width - width - 4)
spacing: 0
id: buttonsRow
ToolButton {
id: effectButton
icon.name: 'tools-wizard'
......@@ -392,6 +393,22 @@ Rectangle {
}
}
}
Item {
id: recLayout
y: trackHeadRoot.buttonSize + 4
//width: trackHeadRoot.width
anchors.left: trackHeadColumn.left
anchors.right: trackHeadColumn.right
anchors.margins: 2
height: showAudioRecord ? trackHeadRoot.buttonSize : 0
Loader {
id: audioVuMeter
anchors.fill: parent
visible: showAudioRecord && (trackHeadRoot.height >= 2 * muteButton.height + resizer.height)
source: isAudio && showAudioRecord ? "AudioLevels.qml" : ""
onLoaded: item.trackId = trackId
}
}
Item {
anchors.bottom: trackHeadColumn.bottom
anchors.left: trackHeadColumn.left
......@@ -404,7 +421,7 @@ Rectangle {
radius: 2
anchors.fill: parent
border.color: trackNameMouseArea.containsMouse ? activePalette.highlight : 'transparent'
visible: (trackHeadRoot.height >= trackLabel.height + muteButton.height + resizer.height)
visible: (trackHeadRoot.height >= trackLabel.height + muteButton.height + resizer.height + recLayout.height)
MouseArea {
id: trackNameMouseArea
anchors.fill: parent
......
......@@ -610,6 +610,29 @@ void TimelineController::deleteTrack(int tid)
}
}
void TimelineController::switchTrackRecord(int tid)
{
if (tid == -1) {
tid = m_activeTrack;
}
if (!m_model->getTrackById_const(tid)->isAudioTrack()) {
pCore->displayMessage(i18n("Select an audio track to display record controls"), InformationMessage, 500);
}
int recDisplayed = m_model->getTrackProperty(tid, QStringLiteral("kdenlive:audio_rec")).toInt();
if (recDisplayed == 1) {
// Disable rec controls
m_model->setTrackProperty(tid, QStringLiteral("kdenlive:audio_rec"), QStringLiteral("0"));
} else {
// Enable rec controls
m_model->setTrackProperty(tid, QStringLiteral("kdenlive:audio_rec"), QStringLiteral("1"));
}
QModelIndex ix = m_model->makeTrackIndexFromID(tid);
if (ix.isValid()) {
m_model->dataChanged(ix, ix, {TimelineModel::AudioRecordRole});
}
}
void TimelineController::checkTrackDeletion(int selectedTrackIx)
{
if (m_activeTrack == selectedTrackIx) {
......@@ -2918,13 +2941,21 @@ void TimelineController::setActiveTrackProperty(const QString &name, const QStri
}
}
const QVariant TimelineController::getActiveTrackProperty(const QString &name)
bool TimelineController::isActiveTrackAudio() const
{
if (m_activeTrack > -1) {
if (m_model->getTrackById_const(m_activeTrack)->isAudioTrack()) {
return QVariant(-1);
return true;
}
}
return false;
}
const QVariant TimelineController::getActiveTrackProperty(const QString &name) const
{
if (m_activeTrack > -1) {
return m_model->getTrackProperty(m_activeTrack, name);
}
return QVariant();
}
......@@ -250,6 +250,9 @@ public:
/* @brief Remove a timeline track
*/
Q_INVOKABLE void deleteTrack(int tid);
/* @brief Show / hide audio rec controls in active track
*/
void switchTrackRecord(int tid = -1);
/* @brief Group selected items in timeline
*/
Q_INVOKABLE void groupSelection();
......@@ -411,7 +414,12 @@ public:
/* @brief Set a property on the active track
*/
void setActiveTrackProperty(const QString &name, const QString &value);
const QVariant getActiveTrackProperty(const QString &name);
/* @brief Get a property on the active track
*/
const QVariant getActiveTrackProperty(const QString &name) const;
/* @brief Is the active track audio
*/
bool isActiveTrackAudio() const;
/* @brief Returns a list of all luma files used in the project
*/
......
......@@ -205,8 +205,18 @@ void TimelineWidget::showCompositionMenu()
void TimelineWidget::showHeaderMenu()
{
int currentThumbs = m_proxy->getActiveTrackProperty(QStringLiteral("kdenlive:thumbs_format")).toInt();
if (currentThumbs >= 0) {
bool isAudio = m_proxy->isActiveTrackAudio();
QList <QAction *> menuActions = m_headerMenu->actions();
QAction *showRec = nullptr;
for (QAction *ac : menuActions) {
if (ac->data().toString() == QLatin1String("show_track_record")) {
showRec = ac;
break;
}
}
if (!isAudio) {
// Video track
int currentThumbs = m_proxy->getActiveTrackProperty(QStringLiteral("kdenlive:thumbs_format")).toInt();
QList <QAction *> actions = m_thumbsMenu->actions();
for (QAction *ac : actions) {
if (ac->data().toInt() == currentThumbs) {
......@@ -215,8 +225,16 @@ void TimelineWidget::showHeaderMenu()
}
}
m_thumbsMenu->menuAction()->setVisible(true);
if (showRec) {
showRec->setVisible(false);
}
} else {
// Audio track
m_thumbsMenu->menuAction()->setVisible(false);
if (showRec) {
showRec->setVisible(true);
showRec->setChecked(m_proxy->getActiveTrackProperty(QStringLiteral("kdenlive:audio_rec")).toInt() == 1);
}
}
m_headerMenu->popup(m_clickPos);
}
......
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