Show/hide track should create an undo/redo entry

parent 93dd9b7c
......@@ -449,6 +449,22 @@ void TimelineItemModel::setTrackName(int trackId, const QString &text)
PUSH_UNDO(undo_lambda, redo_lambda, i18n("Edit item"));
}
void TimelineItemModel::hideTrack(int trackId, const QString state)
{
QWriteLocker locker(&m_lock);
QString previousState = getTrackProperty(trackId, QStringLiteral("hide")).toString();
Fun undo_lambda = [this, trackId, previousState]() {
setTrackProperty(trackId, QStringLiteral("hide"), previousState);
return true;
};
Fun redo_lambda = [this, trackId, state]() {
setTrackProperty(trackId, QStringLiteral("hide"), state);
return true;
};
redo_lambda();
PUSH_UNDO(undo_lambda, redo_lambda, i18n("Edit item"));
}
void TimelineItemModel::setTrackProperty(int trackId, const QString &name, const QString &value)
{
std::shared_ptr<TrackModel> track = getTrackById(trackId);
......
......@@ -88,6 +88,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);
/** @brief returns the lower video track index in timeline.
**/
int getFirstVideoTrackIndex() const;
......
......@@ -320,7 +320,7 @@ Rectangle {
//icon.width: trackHeadRoot.iconSize
//icon.height: trackHeadRoot.iconSize
icon.name: isAudio ? (isDisabled ? 'kdenlive-hide-audio' : 'kdenlive-show-audio') : (isDisabled ? 'kdenlive-hide-video' : 'kdenlive-show-video')
onClicked: controller.setTrackProperty(trackId, "hide", isDisabled ? (isAudio ? '1' : '2') : '3')
onClicked: controller.hideTrack(trackId, isDisabled ? (isAudio ? '1' : '2') : '3')
ToolTip {
visible: muteButton.hovered
font: miniFont
......
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