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

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
if (activateMonitor) {
if (frame > -1) {
m_monitor->slotSeek(frame);
m_monitor->refreshMonitorIfActive();
} else {
m_monitor->slotActivateMonitor();
}
......
......@@ -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);
m_monitorManager = new MonitorManager(this);
connect(m_monitorManager, &MonitorManager::cleanMixer, m_mixerWidget, &MixerManager::clearMixers);
connect(m_subtitleWidget, &SubtitleEdit::addSubtitle, this, [this](const QString &text) {
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) {
m_mainWindow->getCurrentTimeline()->controller()->addSubtitle(-1, text);
}
});
connect(m_subtitleWidget, &SubtitleEdit::addSubtitle, m_mainWindow, &MainWindow::slotAddSubtitle);
connect(m_subtitleWidget, &SubtitleEdit::cutSubtitle, this, [this](int id, int cursorPos) {
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) {
m_mainWindow->getCurrentTimeline()->controller()->cutSubtitle(id, cursorPos);
......
......@@ -3244,14 +3244,36 @@ void MainWindow::slotClipInProjectTree()
ObjectId id(ObjectType::TimelineClip, ids.constFirst());
int start = pCore->getItemIn(id);
int duration = pCore->getItemDuration(id);
QPoint zone(start, start + duration);
qDebug() << " - - selecting clip on monitor, zone: " << zone;
int pos = m_projectMonitor->position();
int itemPos = pCore->getItemPosition(id);
if (pos >= itemPos && pos < itemPos + duration) {
pos -= (itemPos - start);
} else {
pos = -1;
bool containsPos = (pos >= itemPos && pos < itemPos + duration);
double speed = pCore->getClipSpeed(id.second);
if (containsPos) {
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);
}
......@@ -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()) {
m_buttonSubtitleEditTool->setChecked(true);
slotEditSubtitle();
}
getCurrentTimeline()->controller()->addSubtitle();
getCurrentTimeline()->controller()->addSubtitle(-1, text);
}
void MainWindow::slotDisableSubtitle()
......
......@@ -314,6 +314,8 @@ public slots:
void slotDownloadResources();
void slotEditSubtitle(QMap<QString, QString> subProperties = {});
void slotTranscode(const QStringList &urls = QStringList());
/** @brief Add subtitle clip to timeline */
void slotAddSubtitle(const QString &text = QString());
private slots:
/** @brief Shows the shortcut dialog. */
......@@ -527,8 +529,6 @@ private slots:
void slotActivateVideoTrackSequence();
/** @brief Select target for current track */
void slotActivateTarget();
/** @brief Add subtitle clip to timeline */
void slotAddSubtitle();
/** @brief Enable/disable subtitle track */
void slotDisableSubtitle();
/** @brief Lock / unlock subtitle track */
......
......@@ -4286,3 +4286,10 @@ void TimelineController::updateMasterZones(QVariantList zones)
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:
void showRulerEffectZone(QPair <int, int>inOut, bool checked);
/** @brief Set the list of master effect zones */
void updateMasterZones(QVariantList zones);
/** @brief get Maximum duration of a clip */
int clipMaxDuration(int cid);
public slots:
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