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

Project notes: when adding a timeline reference timecode, also include current...

Project notes: when adding a timeline reference timecode, also include current track info so we can make notes on specific tracks
parent 2bc61984
......@@ -516,6 +516,20 @@ const QSize Core::getCompositionSizeOnTrack(const ObjectId &id)
return m_mainWindow->getCurrentTimeline()->controller()->getModel()->getCompositionSizeOnTrack(id);
}
QPair <int,QString> Core::currentTrackInfo() const
{
if (m_mainWindow->getCurrentTimeline()->controller()) {
int tid = m_mainWindow->getCurrentTimeline()->controller()->activeTrack();
if (tid >= 0) {
return {m_mainWindow->getCurrentTimeline()->controller()->getModel()->getTrackMltIndex(tid), m_mainWindow->getCurrentTimeline()->controller()->getModel()->getTrackTagById(tid)};
}
if (tid == -2) {
return {-2, i18n("Subtitles")};
}
}
return {-1,QString()};
}
int Core::getItemPosition(const ObjectId &id)
{
if (!m_guiConstructed) return 0;
......
......@@ -156,7 +156,8 @@ public:
void refreshProjectItem(const ObjectId &id);
/** @brief Returns a reference to a monitor (clip or project monitor) */
Monitor *getMonitor(int id);
/** @brief Returns timeline's active track info (position and tag) */
QPair <int,QString> currentTrackInfo() const;
/** @brief This function must be called whenever the profile used changes */
void profileChanged();
......
......@@ -152,7 +152,9 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_qmlManager = new QmlManager(m_glMonitor);
connect(m_qmlManager, &QmlManager::effectChanged, this, &Monitor::effectChanged);
connect(m_qmlManager, &QmlManager::effectPointsChanged, this, &Monitor::effectPointsChanged);
connect(m_qmlManager, &QmlManager::activateTrack, this, &Monitor::activateTrack);
connect(m_qmlManager, &QmlManager::activateTrack, this, [&](int ix) {
activateTrack(ix, false);
});
glayout->addWidget(m_videoWidget, 0, 0);
m_verticalScroll = new QScrollBar(Qt::Vertical);
......@@ -2642,3 +2644,21 @@ void Monitor::focusTimecode()
m_timePos->setFocus();
m_timePos->selectAll();
}
void Monitor::seekTimeline(const QString frameAndTrack)
{
int frame;
if (frameAndTrack.contains(QLatin1Char('?'))) {
// Track and timecode info
frame = frameAndTrack.section(QLatin1Char('?'), 0, 0).toInt();
int track = frameAndTrack.section(QLatin1Char('?'), 1, 1).toInt();
// Track uses MLT index, so remove 1 to discard black background track
if (track > 0) {
track--;
}
emit activateTrack(track, true);
} else {
frame = frameAndTrack.toInt();
}
requestSeek(frame);
}
......@@ -336,6 +336,7 @@ public slots:
void forceMonitorRefresh();
/** @brief Clear read ahead cache, to ensure up to date audio */
void purgeCache();
void seekTimeline(const QString frameAndTrack);
signals:
void screenChanged(int screenIndex);
......@@ -370,7 +371,7 @@ signals:
void seekToNextSnap();
void createSplitOverlay(std::shared_ptr<Mlt::Filter>);
void removeSplitOverlay();
void activateTrack(int);
void activateTrack(int, bool notesMode = false);
void autoKeyframeChanged();
};
......
......@@ -115,7 +115,7 @@ void NotesWidget::mousePressEvent(QMouseEvent *e)
// That's a Bin Clip reference.
pCore->selectBinClip(anchor.section(QLatin1Char('#'), 0, 0), true, anchor.section(QLatin1Char('#'), 1).toInt(), QPoint());
} else {
emit seekProject(anchor.toInt());
emit seekProject(anchor);
}
e->setAccepted(true);
}
......
......@@ -44,7 +44,7 @@ private:
signals:
void insertNotesTimecode();
void insertTextNote(const QString &text);
void seekProject(int);
void seekProject(const QString);
void reAssign(QStringList anchors, QList <QPoint> points);
};
......
......@@ -31,7 +31,6 @@ NotesPlugin::NotesPlugin(ProjectManager *projectManager)
container->setLayout(lay);
connect(m_widget, &NotesWidget::insertNotesTimecode, this, &NotesPlugin::slotInsertTimecode);
connect(m_widget, &NotesWidget::insertTextNote, this, &NotesPlugin::slotInsertText);
connect(m_widget, &NotesWidget::reAssign, this, &NotesPlugin::slotReAssign);
m_widget->setTabChangesFocus(true);
m_widget->setPlaceholderText(i18n("Enter your project notes here ..."));
......@@ -42,8 +41,8 @@ NotesPlugin::NotesPlugin(ProjectManager *projectManager)
void NotesPlugin::setProject(KdenliveDoc *document)
{
connect(m_widget, &NotesWidget::seekProject, pCore->monitorManager()->projectMonitor(), &Monitor::requestSeek);
connect(m_widget, SIGNAL(textChanged()), document, SLOT(setModified()));
connect(m_widget, &NotesWidget::seekProject, pCore->monitorManager()->projectMonitor(), &Monitor::seekTimeline, Qt::UniqueConnection);
if (m_tb->actions().isEmpty()) {
// initialize toolbar
m_tb->addAction(pCore->window()->action("add_project_note"));
......@@ -77,7 +76,13 @@ void NotesPlugin::slotInsertTimecode()
} else {
int frames = pCore->monitorManager()->projectMonitor()->position();
QString position = pCore->timecode().getTimecodeFromFrames(frames);
m_widget->insertHtml(QString("<a href=\"%1\">%2</a> ").arg(QString::number(frames), position));
QPair <int,QString>currentTrackInfo = pCore->currentTrackInfo();
if (currentTrackInfo.first != -1) {
// Insert timeline position with track reference
m_widget->insertHtml(QString("<a href=\"%1?%2\">%3 %4</a> ").arg(QString::number(frames), QString::number(currentTrackInfo.first), currentTrackInfo.second, position));
} else {
m_widget->insertHtml(QString("<a href=\"%1\">%2</a> ").arg(QString::number(frames), position));
}
}
}
......
......@@ -753,6 +753,8 @@ public:
std::shared_ptr<SubtitleModel> getSubtitleModel();
/** @brief Get the frame size of the clip above a composition */
const QSize getCompositionSizeOnTrack(const ObjectId &id);
/** @brief Get a track tag (A1, V1, V2,...) through its id */
const QString getTrackTagById(int trackId) const;
protected:
/** @brief Register a new track. This is a call-back meant to be called from TrackModel
......@@ -826,8 +828,6 @@ protected:
/** @brief Check tracks duration and update black track accordingly */
void updateDuration();
/** @brief Get a track tag (A1, V1, V2,...) through its id */
const QString getTrackTagById(int trackId) const;
/** @brief Attempt to make a clip move without ever updating the view */
bool requestClipMoveAttempt(int clipId, int trackId, int position);
......
......@@ -3959,15 +3959,20 @@ void TimelineController::updateMultiTrack()
pCore->monitorManager()->projectMonitor()->slotShowEffectScene(MonitorSplitTrack, false, QVariant(trackNames));
}
void TimelineController::activateTrackAndSelect(int trackPosition)
void TimelineController::activateTrackAndSelect(int trackPosition, bool notesMode)
{
int tid = -1;
int ix = 0;
if (notesMode && trackPosition == -2) {
m_activeTrack = -2;
emit activeTrackChanged();
return;
}
auto it = m_model->m_allTracks.cbegin();
while (it != m_model->m_allTracks.cend()) {
tid = (*it)->getId();
++it;
if (m_model->getTrackById_const(tid)->isAudioTrack() || m_model->getTrackById_const(tid)->isHidden()) {
if (!notesMode && (m_model->getTrackById_const(tid)->isAudioTrack() || m_model->getTrackById_const(tid)->isHidden())) {
continue;
}
if (trackPosition == ix) {
......@@ -3978,7 +3983,7 @@ void TimelineController::activateTrackAndSelect(int trackPosition)
if (tid > -1) {
m_activeTrack = tid;
emit activeTrackChanged();
if (pCore->window()->getCurrentTimeline()->activeTool() != ToolType::MulticamTool) {
if (!notesMode && pCore->window()->getCurrentTimeline()->activeTool() != ToolType::MulticamTool) {
selectCurrentItem(ObjectType::TimelineClip, true);
}
}
......
......@@ -662,7 +662,7 @@ public slots:
/** @brief Dis / enable multi track view. */
void slotMultitrackView(bool enable = true, bool refresh = true);
/** @brief Activate a video track by its position (0 = topmost). */
void activateTrackAndSelect(int trackPosition);
void activateTrackAndSelect(int trackPosition, bool notesMode = false);
/** @brief Save timeline selected clips to target folder. */
void saveTimelineSelection(const QDir &targetDir);
/** @brief Restore timeline scroll pos on open. */
......
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