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

Merge branch '2104'

parents dfe22e36 7333e5d3
Pipeline #56835 passed with stage
in 10 minutes and 58 seconds
...@@ -1986,6 +1986,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone, b ...@@ -1986,6 +1986,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone, b
if (activateMonitor) { if (activateMonitor) {
if (frame > -1) { if (frame > -1) {
m_monitor->slotSeek(frame); m_monitor->slotSeek(frame);
m_monitor->refreshMonitorIfActive();
} else { } else {
m_monitor->slotActivateMonitor(); m_monitor->slotActivateMonitor();
} }
......
...@@ -141,11 +141,7 @@ void Core::initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, con ...@@ -141,11 +141,7 @@ void Core::initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, con
connect(m_mixerWidget, &MixerManager::updateRecVolume, m_capture.get(), &MediaCapture::setAudioVolume); connect(m_mixerWidget, &MixerManager::updateRecVolume, m_capture.get(), &MediaCapture::setAudioVolume);
m_monitorManager = new MonitorManager(this); m_monitorManager = new MonitorManager(this);
connect(m_monitorManager, &MonitorManager::cleanMixer, m_mixerWidget, &MixerManager::clearMixers); connect(m_monitorManager, &MonitorManager::cleanMixer, m_mixerWidget, &MixerManager::clearMixers);
connect(m_subtitleWidget, &SubtitleEdit::addSubtitle, this, [this](const QString &text) { connect(m_subtitleWidget, &SubtitleEdit::addSubtitle, m_mainWindow, &MainWindow::slotAddSubtitle);
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) {
m_mainWindow->getCurrentTimeline()->controller()->addSubtitle(-1, text);
}
});
connect(m_subtitleWidget, &SubtitleEdit::cutSubtitle, this, [this](int id, int cursorPos) { connect(m_subtitleWidget, &SubtitleEdit::cutSubtitle, this, [this](int id, int cursorPos) {
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) { if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) {
m_mainWindow->getCurrentTimeline()->controller()->cutSubtitle(id, cursorPos); m_mainWindow->getCurrentTimeline()->controller()->cutSubtitle(id, cursorPos);
......
...@@ -3244,14 +3244,36 @@ void MainWindow::slotClipInProjectTree() ...@@ -3244,14 +3244,36 @@ void MainWindow::slotClipInProjectTree()
ObjectId id(ObjectType::TimelineClip, ids.constFirst()); ObjectId id(ObjectType::TimelineClip, ids.constFirst());
int start = pCore->getItemIn(id); int start = pCore->getItemIn(id);
int duration = pCore->getItemDuration(id); int duration = pCore->getItemDuration(id);
QPoint zone(start, start + duration);
qDebug() << " - - selecting clip on monitor, zone: " << zone;
int pos = m_projectMonitor->position(); int pos = m_projectMonitor->position();
int itemPos = pCore->getItemPosition(id); int itemPos = pCore->getItemPosition(id);
if (pos >= itemPos && pos < itemPos + duration) { bool containsPos = (pos >= itemPos && pos < itemPos + duration);
pos -= (itemPos - start); double speed = pCore->getClipSpeed(id.second);
} else { if (containsPos) {
pos = -1; pos -= itemPos - start;
}
if (!qFuzzyCompare(speed, 1.)) {
if (speed > 0.) {
// clip has a speed effect, adjust zone
start = qRound(start * speed);
duration = qRound(duration * speed);
if (containsPos) {
pos = qRound(pos * speed);
}
} else if (speed < 0.) {
int max = getMainTimeline()->controller()->clipMaxDuration(id.second);
if (max > 0) {
int invertedPos = itemPos + duration - m_projectMonitor->position();
start = qRound((max - (start + duration)) * -speed);
duration = qRound(duration * -speed);
if (containsPos) {
pos = start + qRound(invertedPos * -speed);
}
}
}
}
QPoint zone(start, start + duration);
if (!containsPos) {
pos = start;
} }
pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), true, pos, zone); pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), true, pos, zone);
} }
...@@ -4323,13 +4345,13 @@ void MainWindow::slotEditSubtitle(QMap<QString, QString> subProperties) ...@@ -4323,13 +4345,13 @@ void MainWindow::slotEditSubtitle(QMap<QString, QString> subProperties)
} }
} }
void MainWindow::slotAddSubtitle() void MainWindow::slotAddSubtitle(const QString &text)
{ {
if (pCore->getSubtitleModel() == nullptr || !KdenliveSettings::showSubtitles()) { if (pCore->getSubtitleModel() == nullptr || !KdenliveSettings::showSubtitles()) {
m_buttonSubtitleEditTool->setChecked(true); m_buttonSubtitleEditTool->setChecked(true);
slotEditSubtitle(); slotEditSubtitle();
} }
getCurrentTimeline()->controller()->addSubtitle(); getCurrentTimeline()->controller()->addSubtitle(-1, text);
} }
void MainWindow::slotDisableSubtitle() void MainWindow::slotDisableSubtitle()
......
...@@ -314,6 +314,8 @@ public slots: ...@@ -314,6 +314,8 @@ public slots:
void slotDownloadResources(); void slotDownloadResources();
void slotEditSubtitle(QMap<QString, QString> subProperties = {}); void slotEditSubtitle(QMap<QString, QString> subProperties = {});
void slotTranscode(const QStringList &urls = QStringList()); void slotTranscode(const QStringList &urls = QStringList());
/** @brief Add subtitle clip to timeline */
void slotAddSubtitle(const QString &text = QString());
private slots: private slots:
/** @brief Shows the shortcut dialog. */ /** @brief Shows the shortcut dialog. */
...@@ -527,8 +529,6 @@ private slots: ...@@ -527,8 +529,6 @@ private slots:
void slotActivateVideoTrackSequence(); void slotActivateVideoTrackSequence();
/** @brief Select target for current track */ /** @brief Select target for current track */
void slotActivateTarget(); void slotActivateTarget();
/** @brief Add subtitle clip to timeline */
void slotAddSubtitle();
/** @brief Enable/disable subtitle track */ /** @brief Enable/disable subtitle track */
void slotDisableSubtitle(); void slotDisableSubtitle();
/** @brief Lock / unlock subtitle track */ /** @brief Lock / unlock subtitle track */
......
...@@ -4286,3 +4286,10 @@ void TimelineController::updateMasterZones(QVariantList zones) ...@@ -4286,3 +4286,10 @@ void TimelineController::updateMasterZones(QVariantList zones)
emit masterZonesChanged(); emit masterZonesChanged();
} }
int TimelineController::clipMaxDuration(int cid)
{
if (!m_model->isClip(cid)) {
return -1;
}
return m_model->m_allClips[cid]->getMaxDuration();
}
...@@ -622,6 +622,8 @@ public: ...@@ -622,6 +622,8 @@ public:
void showRulerEffectZone(QPair <int, int>inOut, bool checked); void showRulerEffectZone(QPair <int, int>inOut, bool checked);
/** @brief Set the list of master effect zones */ /** @brief Set the list of master effect zones */
void updateMasterZones(QVariantList zones); void updateMasterZones(QVariantList zones);
/** @brief get Maximum duration of a clip */
int clipMaxDuration(int cid);
public slots: public slots:
void resetView(); void resetView();
......
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