Commit b26de129 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Save track thumbnail format

https://phabricator.kde.org/T9283
parent 7299009d
......@@ -73,6 +73,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
int lockState = track->get_int("kdenlive:locked_track");
Mlt::Tractor local_tractor(*track);
ok = ok && constructTrackFromMelt(timeline, tid, local_tractor, binIdCorresp, undo, redo);
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:thumbs_format"), track->get("kdenlive:thumbs_format"));
if (lockState > 0) {
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:locked_track"), QString::number(lockState));
}
......@@ -92,6 +93,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
}
int lockState = local_playlist.get_int("kdenlive:locked_track");
ok = ok && constructTrackFromMelt(timeline, tid, local_playlist, binIdCorresp, undo, redo);
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:thumbs_format"), local_playlist.get("kdenlive:thumbs_format"));
if (lockState > 0) {
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:locked_track"), QString::number(lockState));
}
......
......@@ -201,6 +201,7 @@ QHash<int, QByteArray> TimelineItemModel::roleNames() const
roles[CanBeAudioRole] = "canBeAudio";
roles[CanBeVideoRole] = "canBeVideo";
roles[ReloadThumbRole] = "reloadThumb";
roles[ThumbsFormatRole] = "thumbsFormat";
return roles;
}
......@@ -325,6 +326,8 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
// qDebug() << "DATA yielding height" << height;
return (height > 0 ? height : 60);
}
case ThumbsFormatRole:
return getTrackById_const(id)->getProperty("kdenlive:thumbs_format").toInt();
case IsCompositeRole: {
return Qt::Unchecked;
}
......@@ -386,6 +389,8 @@ void TimelineItemModel::setTrackProperty(int trackId, const QString &name, const
roles.push_back(IsLockedRole);
} else if (name == QLatin1String("hide")) {
roles.push_back(IsDisabledRole);
} else if (name == QLatin1String("kdenlive:thumbs_format")) {
roles.push_back(ThumbsFormatRole);
}
if (!roles.isEmpty()) {
QModelIndex ix = makeTrackIndexFromID(trackId);
......
......@@ -151,7 +151,8 @@ public:
SpeedRole, /// clip only
ReloadThumbRole, /// clip only
ItemATrack, /// composition only
ItemIdRole
ItemIdRole,
ThumbsFormatRole /// track only
};
virtual ~TimelineModel();
......
......@@ -17,8 +17,9 @@ Row {
// switching the model allows to have different view modes:
// 2: will display start / end thumbs
// container.width / thumbRow.thumbWidth will display all frames showThumbnails
// 1: only show first thumbnail
// 0: will disable thumbnails
model: parentTrack.thumbsFormat == 0 ? 2 : parentTrack.thumbsFormat == 1 ? container.width / thumbRow.thumbWidth : 0
model: parentTrack.trackThumbsFormat == 0 ? 2 : parentTrack.trackThumbsFormat == 1 ? container.width / thumbRow.thumbWidth : parentTrack.trackThumbsFormat == 2 ? 1 : 0
property int startFrame: clipRoot.inPoint
property int endFrame: clipRoot.outPoint
property real imageWidth: container.width / thumbRepeater.count
......@@ -29,8 +30,8 @@ Row {
asynchronous: true
cache: false
property int currentFrame: Math.floor(clipRoot.inPoint + Math.round((index) * width / timeline.scaleFactor)* clipRoot.speed)
horizontalAlignment: thumbRepeater.count == 2 ? (index == 0 ? Image.AlignLeft : Image.AlignRight) : Image.AlignHCenter
source: thumbRepeater.count == 2 ? (index == 0 ? clipRoot.baseThumbPath + Math.floor(clipRoot.inPoint * clipRoot.speed) : clipRoot.baseThumbPath + Math.floor(clipRoot.outPoint * clipRoot.speed)) : (currentFrame + width / timeline.scaleFactor < thumbRow.scrollStart || currentFrame > thumbRow.scrollEnd) ? '' : clipRoot.baseThumbPath + currentFrame
horizontalAlignment: thumbRepeater.count < 3 ? (index == 0 ? Image.AlignLeft : Image.AlignRight) : Image.AlignLeft
source: thumbRepeater.count < 3 ? (index == 0 ? clipRoot.baseThumbPath + Math.floor(clipRoot.inPoint * clipRoot.speed) : clipRoot.baseThumbPath + Math.floor(clipRoot.outPoint * clipRoot.speed)) : (currentFrame + width / timeline.scaleFactor < thumbRow.scrollStart || currentFrame > thumbRow.scrollEnd) ? '' : clipRoot.baseThumbPath + currentFrame
}
}
}
......@@ -30,7 +30,7 @@ Column{
property bool isCurrentTrack: false
property bool isLocked: false
property int trackId : -42
property int thumbsFormat: 0
property int trackThumbsFormat
height: parent.height
SystemPalette { id: activePalette }
......
......@@ -36,6 +36,7 @@ Rectangle {
property int collapsedHeight: nameEdit.height + 2
property int iconSize: root.baseUnit * 2
property string trackTag
property int thumbsFormat: 0
border.width: 1
border.color: Qt.rgba(activePalette.windowText.r, activePalette.windowText.g, activePalette.windowText.b, 0.1)
signal clicked()
......@@ -209,8 +210,56 @@ Rectangle {
implicitHeight: trackHeadRoot.iconSize
implicitWidth: trackHeadRoot.iconSize
iconName: 'view-preview'
onClicked: root.cycleTrackThumbs(trackId)
tooltip: i18n('Thumbnails type')
onClicked: thumbsContextMenu.popup()
Menu {
id: thumbsContextMenu
ExclusiveGroup { id: thumbStyle }
MenuItem {
text: "In frame"
id: inFrame
onTriggered:controller.setTrackProperty(trackId, "kdenlive:thumbs_format", 2)
checkable: true
exclusiveGroup: thumbStyle
}
MenuItem {
text: "In / out frames"
id: inOutFrame
onTriggered:controller.setTrackProperty(trackId, "kdenlive:thumbs_format", 0)
checkable: true
checked: true
exclusiveGroup: thumbStyle
}
MenuItem {
text: "All frames"
id: allFrame
onTriggered:controller.setTrackProperty(trackId, "kdenlive:thumbs_format", 1)
checkable: true
exclusiveGroup: thumbStyle
}
MenuItem {
text: "No thumbnails"
id: noFrame
onTriggered:controller.setTrackProperty(trackId, "kdenlive:thumbs_format", 3)
checkable: true
exclusiveGroup: thumbStyle
}
onAboutToShow: {
switch(thumbsFormat) {
case 3:
noFrame.checked = true
break
case 2:
inFrame.checked = true
break
case 1:
allFrame.checked = true
break
default:
inOutFrame.checked = true
break
}
}
}
}
ToolButton {
id: muteButton
......
......@@ -157,11 +157,6 @@ Rectangle {
}
}
function cycleTrackThumbs(trackId) {
var track = Logic.getTrackById(trackId)
track.thumbsFormat = track.thumbsFormat < 2 ? track.thumbsFormat + 1 : 0
}
DropArea { //Drop area for compositions
width: root.width - headerWidth
height: root.height - ruler.height
......@@ -479,6 +474,7 @@ Rectangle {
model: multitrack
TrackHead {
trackName: model.name
thumbsFormat: model.thumbsFormat
trackTag: model.trackTag
isDisabled: model.disabled
isComposite: model.composite
......@@ -910,13 +906,14 @@ Rectangle {
DelegateModel {
id: trackDelegateModel
model: multitrack
Track {
delegate: Track {
model: multitrack
rootIndex: trackDelegateModel.modelIndex(index)
height: trackHeight
timeScale: timeline.scaleFactor
width: tracksContainerArea.width
isAudio: audio
trackThumbsFormat: thumbsFormat
isCurrentTrack: item === timeline.activeTrack
trackId: item
onClipClicked: {
......
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