Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Handle audio tracks in Qml view

parent 167a4eb6
......@@ -77,6 +77,11 @@ bool constructTimelineFromMelt(std::shared_ptr<TimelineItemModel> timeline, Mlt:
if (!trackName.isEmpty()) {
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:track_name"), trackName.toUtf8().constData());
}
int audioTrack = local_playlist.get_int("kdenlive:audio_track");
if (audioTrack == 1) {
// This is an audio track
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:audio_track"), QStringLiteral("1"));
}
break;
}
default:
......
......@@ -29,6 +29,7 @@
#include <mlt++/MltTractor.h>
#include <mlt++/MltProfile.h>
#include <QDebug>
#include <QFileInfo>
#include "macros.hpp"
TimelineItemModel::TimelineItemModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack> undo_stack) :
......@@ -202,7 +203,15 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
//TODO
case NameRole:
case Qt::DisplayRole:{
QString result = QString::fromUtf8("clip name");
QString result = clip->getProperty("kdenlive:clipname");
if (result.isEmpty()) {
result = clip->getProperty("resource");
if (!result.isEmpty()) {
result = QFileInfo(result).fileName();
} else {
result = clip->getProperty("mlt_service");
}
}
return result;
}
case ResourceRole: {
......@@ -260,7 +269,7 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
case IsHiddenRole:
return getTrackById_const(id)->getProperty("hide").toInt() & 1;
case IsAudioRole:
return false;
return getTrackById_const(id)->getProperty("kdenlive:audio_track").toInt() == 1;
case IsLockedRole:
return getTrackById_const(id)->getProperty("kdenlive:locked_track").toInt() == 1;
case HeightRole: {
......
......@@ -30,7 +30,7 @@ Rectangle {
property bool isHidden
property int isComposite
property bool isLocked
property bool isVideo
property bool isAudio
property bool selected: false
property bool current: false
property int myTrackHeight
......@@ -54,7 +54,7 @@ Rectangle {
when: trackHeadRoot.selected
PropertyChanges {
target: trackHeadRoot
//color: isVideo? root.shotcutBlue : 'darkseagreen'
//color: isAudio? root.shotcutBlue : 'darkseagreen'
}
},
State {
......@@ -70,7 +70,7 @@ Rectangle {
name: 'normal'
PropertyChanges {
target: trackHeadRoot
color: (index % 2)? activePalette.alternateBase : activePalette.base
color: getTrackColor(isAudio, index, true)
}
}
]
......@@ -224,7 +224,7 @@ Rectangle {
ToolButton {
id: hideButton
visible: isVideo
visible: !isAudio
implicitWidth: 20
implicitHeight: 20
iconName: isHidden ? 'kdenlive-hide-video' : 'kdenlive-show-video'
......
......@@ -50,6 +50,17 @@ Rectangle {
}
function getTrackColor(isAudio, index, header) {
var color = (index % 2)? Qt.darker(activePalette.alternateBase, 1.4) : activePalette.alternateBase
if (isAudio) {
color = Qt.tint(color, "#1000cc00")
}
if (header) {
color = Qt.lighter(color, 1.2)
}
return color
}
property int headerWidth: 140
property int baseUnit: fontMetrics.height * 0.6
property int currentTrack: 0
......@@ -189,7 +200,7 @@ Rectangle {
isHidden: model.hidden
isComposite: model.composite
isLocked: model.locked
isVideo: !model.audio
isAudio: model.audio
width: headerWidth
height: model.trackHeight
selected: false
......@@ -309,8 +320,7 @@ Rectangle {
delegate: Rectangle {
width: root.duration
//Layout.fillWidth: true
color: (index === currentTrack)? selectedTrackColor : (index % 2)? activePalette.alternateBase : activePalette.base
opacity: 0.3
color: (index === currentTrack)? selectedTrackColor : getTrackColor(tracksRepeater.itemAt(index).isAudio, index, false)
height: model.trackHeight
}
}
......
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