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

Suggest same track type when adding a track

Based on a patch by Clint Moyer: https://phabricator.kde.org/D16026
parent 8efa0276
......@@ -2131,6 +2131,14 @@ bool TimelineModel::requestCompositionMove(int compoId, int trackId, int positio
return res;
}
bool TimelineModel::isAudioTrack(int trackId) const
{
READ_LOCK();
Q_ASSERT(isTrack(trackId));
auto it = m_iteratorTable.at(trackId);
return (*it)->isAudioTrack();
}
bool TimelineModel::requestCompositionMove(int compoId, int trackId, int compositionTrack, int position, bool updateView, Fun &undo, Fun &redo)
{
QWriteLocker locker(&m_lock);
......
......@@ -178,6 +178,9 @@ public:
/* @brief returns the track index (id) from its position */
int getTrackIndexFromPosition(int pos) const;
/* @brief returns the track index (id) from its position */
bool isAudioTrack(int trackId) const;
/* @brief returns the number of clips */
int getClipsCount() const;
......
......@@ -28,6 +28,7 @@ TrackDialog::TrackDialog(std::shared_ptr<TimelineItemModel> model, int trackInde
, m_audioCount(1)
, m_videoCount(1)
{
setWindowTitle(deleteMode ? i18n("Delete Track") : i18n("Add Track"));
// setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QIcon videoIcon = QIcon::fromTheme(QStringLiteral("kdenlive-show-video"));
QIcon audioIcon = QIcon::fromTheme(QStringLiteral("kdenlive-show-audio"));
......@@ -35,7 +36,7 @@ TrackDialog::TrackDialog(std::shared_ptr<TimelineItemModel> model, int trackInde
QStringList existingTrackNames;
for (int i = model->getTracksCount() - 1; i >= 0; i--) {
int tid = model->getTrackIndexFromPosition(i);
bool audioTrack = model->getTrackProperty(tid, QStringLiteral("kdenlive:audio_track")) == QLatin1String("1");
bool audioTrack = model->isAudioTrack(tid);
if (audioTrack) {
m_audioCount++;
} else {
......@@ -50,6 +51,9 @@ TrackDialog::TrackDialog(std::shared_ptr<TimelineItemModel> model, int trackInde
if (trackIndex > -1) {
int ix = comboTracks->findData(trackIndex);
comboTracks->setCurrentIndex(ix);
if (model->isAudioTrack(trackIndex)) {
audio_track->setChecked(true);
}
}
trackIndex--;
if (deleteMode) {
......
......@@ -484,11 +484,17 @@ Rectangle {
id: headerMenu
OLD.MenuItem {
text: i18n('Add Track')
onTriggered: timeline.addTrack(timeline.activeTrack);
onTriggered: {
timeline.addTrack(timeline.activeTrack)
timeline.ungrabHack()
}
}
OLD.MenuItem {
text: i18n('Delete Track')
onTriggered: timeline.deleteTrack(timeline.activeTrack);
onTriggered: {
timeline.deleteTrack(timeline.activeTrack)
timeline.ungrabHack()
}
}
}
......
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