Auto rename new track when switching from audio to video

parent 7c19c614
......@@ -2452,37 +2452,19 @@ void MainWindow::slotRemoveAllSpace()
void MainWindow::slotInsertTrack()
{
pCore->monitorManager()->activateMonitor(Kdenlive::ProjectMonitor);
// TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
int ix = pCore->projectManager()->currentTimeline()->projectView()->selectedTrack();
pCore->projectManager()->currentTimeline()->projectView()->slotInsertTrack(ix);
}
*/
getMainTimeline()->controller()->addTrack(-1);
}
void MainWindow::slotDeleteTrack()
{
pCore->monitorManager()->activateMonitor(Kdenlive::ProjectMonitor);
// TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
int ix = pCore->projectManager()->currentTimeline()->projectView()->selectedTrack();
pCore->projectManager()->currentTimeline()->projectView()->slotDeleteTrack(ix);
}
*/
getMainTimeline()->controller()->addTrack(-1);
}
void MainWindow::slotConfigTrack()
{
pCore->monitorManager()->activateMonitor(Kdenlive::ProjectMonitor);
// TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
int ix = pCore->projectManager()->currentTimeline()->projectView()->selectedTrack();
pCore->projectManager()->currentTimeline()->projectView()->slotConfigTracks(ix);
}
*/
getMainTimeline()->controller()->deleteTrack(-1);
}
void MainWindow::slotSelectTrack()
......
......@@ -25,6 +25,8 @@
TrackDialog::TrackDialog(std::shared_ptr<TimelineItemModel> model, int trackIndex, QWidget *parent, bool deleteMode) :
QDialog(parent)
, m_audioCount(1)
, m_videoCount(1)
{
//setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QIcon videoIcon = QIcon::fromTheme(QStringLiteral("kdenlive-show-video"));
......@@ -34,6 +36,11 @@ TrackDialog::TrackDialog(std::shared_ptr<TimelineItemModel> model, int trackInde
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");
if (audioTrack) {
m_audioCount++;
} else {
m_videoCount++;
}
const QString trackName = model->getTrackProperty(tid, QStringLiteral("kdenlive:track_name")).toString();
existingTrackNames << trackName;
// Track index in in MLT, so add + 1 to compensate black track
......@@ -59,8 +66,17 @@ TrackDialog::TrackDialog(std::shared_ptr<TimelineItemModel> model, int trackInde
}
track_name->setText(proposedName);
}
connect(audio_track, &QRadioButton::toggled, this, &TrackDialog::updateName);
}
void TrackDialog::updateName(bool audioTrack)
{
QString proposedName = i18n(audioTrack ? "Audio %1" : "Video %1", audioTrack ? m_audioCount : m_videoCount);
track_name->setText(proposedName);
}
int TrackDialog::selectedTrack() const
{
if (comboTracks->count() > 0) {
......
......@@ -38,6 +38,13 @@ public:
/** @brief: returns the newly created track name
*/
const QString trackName() const;
private slots:
void updateName(bool audioTrack);
private:
int m_audioCount;
int m_videoCount;
};
#endif
......@@ -479,6 +479,9 @@ bool TimelineController::showWaveforms() const
void TimelineController::addTrack(int tid)
{
if (tid == -1) {
tid = m_activeTrack;
}
QPointer<TrackDialog> d = new TrackDialog(m_model, m_model->getTrackMltIndex(tid), qApp->activeWindow());
if (d->exec() == QDialog::Accepted) {
int mltIndex = d->selectedTrack();
......@@ -489,6 +492,9 @@ void TimelineController::addTrack(int tid)
void TimelineController::deleteTrack(int tid)
{
if (tid == -1) {
tid = m_activeTrack;
}
QPointer<TrackDialog> d = new TrackDialog(m_model, m_model->getTrackMltIndex(tid), qApp->activeWindow(), true);
if (d->exec() == QDialog::Accepted) {
int mltIndex = d->selectedTrack();
......
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