Commit 8e5c0861 authored by Julius Künzel's avatar Julius Künzel
Browse files

Make it possible to enable/disable track with a shortcut

The default shortcut is Shift+H

BUG: 440181
parent ad714c87
Pipeline #98602 passed with stage
in 8 minutes and 42 seconds
......@@ -1861,6 +1861,8 @@ void MainWindow::setupActions()
disableEffects->setCheckable(true);
disableEffects->setChecked(false);
addAction(QStringLiteral("switch_track_disabled"), i18n("Toggle Track Disabled"), pCore->projectManager(), SLOT(slotSwitchTrackDisabled()), QIcon(),
Qt::SHIFT + Qt::Key_H);
addAction(QStringLiteral("switch_track_lock"), i18n("Toggle Track Lock"), pCore->projectManager(), SLOT(slotSwitchTrackLock()), QIcon(),
Qt::SHIFT + Qt::Key_L);
addAction(QStringLiteral("switch_all_track_lock"), i18n("Toggle All Track Lock"), pCore->projectManager(), SLOT(slotSwitchAllTrackLock()), QIcon(),
......
......@@ -834,6 +834,11 @@ void ProjectManager::slotDisableTimelineEffects(bool disable)
pCore->monitorManager()->refreshProjectMonitor();
}
void ProjectManager::slotSwitchTrackDisabled()
{
pCore->window()->getMainTimeline()->controller()->switchTrackDisabled();
}
void ProjectManager::slotSwitchTrackLock()
{
pCore->window()->getMainTimeline()->controller()->switchTrackLock();
......
......@@ -142,6 +142,8 @@ public slots:
/** @brief Dis/enable all timeline effects */
void slotDisableTimelineEffects(bool disable);
/** @brief Mute/Unmute or Hide/Show current timeline track */
void slotSwitchTrackDisabled();
/** @brief Un/Lock current timeline track */
void slotSwitchTrackLock();
void slotSwitchAllTrackLock();
......
......@@ -475,9 +475,11 @@ void TimelineItemModel::setTrackName(int trackId, const QString &text)
PUSH_UNDO(undo_lambda, redo_lambda, i18n("Rename Track"));
}
void TimelineItemModel::hideTrack(int trackId, const QString state)
void TimelineItemModel::hideTrack(int trackId, bool hide)
{
QWriteLocker locker(&m_lock);
bool isAudio = isAudioTrack(trackId);
QString state = hide ? (isAudio ? "1" : "2") : "3";
QString previousState = getTrackProperty(trackId, QStringLiteral("hide")).toString();
Fun undo_lambda = [this, trackId, previousState]() {
setTrackProperty(trackId, QStringLiteral("hide"), previousState);
......
......@@ -72,7 +72,7 @@ public:
@param text is the new track name.
*/
Q_INVOKABLE void setTrackName(int trackId, const QString &text);
Q_INVOKABLE void hideTrack(int trackId, const QString state);
Q_INVOKABLE void hideTrack(int trackId, bool hide);
/** @brief returns the lower video track index in timeline.
**/
int getFirstVideoTrackIndex() const;
......
......@@ -428,7 +428,7 @@ Rectangle {
}
width: root.collapsedHeight
height: root.collapsedHeight
onClicked: controller.hideTrack(trackId, isDisabled ? (isAudio ? '1' : '2') : '3')
onClicked: controller.hideTrack(trackId, isDisabled)
ToolTip {
visible: muteButton.hovered
font: miniFont
......
......@@ -3217,6 +3217,18 @@ void TimelineController::makeAllTrackActive()
m_activeSnaps.clear();
}
void TimelineController::switchTrackDisabled()
{
if (m_activeTrack == -2) {
// Subtitle track
switchSubtitleDisable();
} else {
bool isAudio = m_model->getTrackById_const(m_activeTrack)->isAudioTrack();
bool enabled = isAudio ? m_model->getTrackById_const(m_activeTrack)->isMute() : m_model->getTrackById_const(m_activeTrack)->isHidden();
m_model->hideTrack(m_activeTrack, enabled);
}
}
void TimelineController::switchTrackLock(bool applyToAll)
{
if (!applyToAll) {
......
......@@ -459,6 +459,7 @@ public:
void switchAllTrackActive();
/** @brief Make all tracks active or inactive */
void makeAllTrackActive();
void switchTrackDisabled();
void switchTrackLock(bool applyToAll = false);
void switchTargetTrack();
......
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