Fix several issues when changing project's fps

parent 66eea0af
......@@ -1549,10 +1549,11 @@ void KdenliveDoc::updateProjectProfile()
KdenliveSettings::setProject_fps(fps);
m_width = m_profile.width;
m_height = m_profile.height;
bool fpsChanged = m_timecode.fps() != fps;
m_timecode.setFormat(fps);
KdenliveSettings::setCurrent_profile(m_profile.path);
pCore->monitorManager()->resetProfiles(m_profile, m_timecode);
emit updateFps();
emit updateFps(fpsChanged);
}
void KdenliveDoc::resetProfile()
......
......@@ -239,7 +239,7 @@ signals:
/** @brief Current doc created effects, reload list */
void reloadEffects();
/** @brief Fps was changed, update timeline */
void updateFps();
void updateFps(bool changed);
};
#endif
......
......@@ -1662,7 +1662,7 @@ void MainWindow::connectDocument()
connect(m_effectStack->transitionConfig(), SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(seekCursorPos(int)));
connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
connect(project, &KdenliveDoc::updateFps, trackView, &Timeline::updateProjectFps);
connect(project, &KdenliveDoc::updateFps, trackView, &Timeline::updateProfile);
connect(trackView, SIGNAL(zoneMoved(int,int)), this, SLOT(slotZoneMoved(int,int)));
trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container(QStringLiteral("marker_menu"), this)));
if (m_renderWidget) {
......@@ -1682,7 +1682,7 @@ void MainWindow::connectDocument()
m_normalEditTool->setChecked(true);
connect(m_projectMonitor, SIGNAL(durationChanged(int)), this, SLOT(slotUpdateProjectDuration(int)));
pCore->monitorManager()->setDocument(project);
trackView->updateProjectFps();
trackView->updateProfile(false);
if (m_recMonitor) {
m_recMonitor->slotUpdateCaptureFolder(project->projectFolder().path() + QDir::separator());
}
......
......@@ -302,9 +302,9 @@ void CustomRuler::updateRuler(int pos)
update(min * m_factor - offset() - 3, BIG_MARK_X, (max - min) * m_factor + 6, MAX_HEIGHT - BIG_MARK_X);
}
void CustomRuler::setPixelPerMark(int rate)
void CustomRuler::setPixelPerMark(int rate, bool force)
{
if (rate == m_rate) return;
if (rate == m_rate && !force) return;
int scale = comboScale[rate];
m_rate = rate;
m_factor = 1.0 / (double) scale * FRAME_SIZE;
......
......@@ -40,7 +40,7 @@ class CustomRuler : public QWidget
public:
CustomRuler(const Timecode &tc, CustomTrackView *parent);
void setPixelPerMark(int rate);
void setPixelPerMark(int rate, bool force = false);
static const int comboScale[];
int outPoint() const;
int inPoint() const;
......
......@@ -264,15 +264,19 @@ int CustomTrackView::getFrameWidth() const
return (int) (m_tracksHeight * m_document->dar() + 0.5);
}
void CustomTrackView::updateSceneFrameWidth()
void CustomTrackView::updateSceneFrameWidth(bool fpsChanged)
{
int frameWidth = getFrameWidth();
QList<QGraphicsItem *> itemList = items();
ClipItem *item;
for (int i = 0; i < itemList.count(); ++i) {
if (itemList.at(i)->type() == AVWidget) {
item = static_cast<ClipItem*>(itemList.at(i));
item->resetFrameWidth(frameWidth);
if (fpsChanged && m_projectDuration > 0) {
reloadTimeline();
} else {
QList<QGraphicsItem *> itemList = items();
ClipItem *item;
for (int i = 0; i < itemList.count(); ++i) {
if (itemList.at(i)->type() == AVWidget) {
item = static_cast<ClipItem*>(itemList.at(i));
item->resetFrameWidth(frameWidth);
}
}
}
}
......
......@@ -103,7 +103,7 @@ public:
void cutSelectedClips();
void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup, QMenu *markermenu);
bool checkTrackHeight(bool force = false);
void updateSceneFrameWidth();
void updateSceneFrameWidth(bool fpsChanged = false);
void setTool(ProjectTool tool);
ClipItem *cutClip(const ItemInfo &info, const GenTime &cutTime, bool cut, const EffectsList &oldStack = EffectsList(), bool execute = true);
void slotSeekToPreviousSnap();
......
......@@ -1119,15 +1119,6 @@ void Timeline::slotVerticalZoomUp()
m_trackview->verticalScrollBar()->setValue(headers_area->verticalScrollBar()->value());
}
void Timeline::updateProjectFps()
{
qDebug()<<"Requesting FPS UPDATE: "<<m_doc->timecode().fps();
m_ruler->updateFrameSize();
m_ruler->updateProjectFps(m_doc->timecode());
m_trackview->updateProjectFps();
slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
}
void Timeline::slotRenameTrack(int ix, const QString &name)
{
QString currentName = track(ix)->getProperty(QStringLiteral("kdenlive:track_name"));
......@@ -1182,12 +1173,14 @@ void Timeline::slotSaveTimelinePreview(const QString &path)
img.save(path);
}
void Timeline::updateProfile()
void Timeline::updateProfile(bool fpsChanged)
{
m_ruler->updateFrameSize();
m_trackview->updateSceneFrameWidth();
m_ruler->updateProjectFps(m_doc->timecode());
m_ruler->setPixelPerMark(m_doc->zoom().x(), true);
slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
slotSetZone(m_doc->zone(), false);
m_trackview->updateSceneFrameWidth(fpsChanged);
}
void Timeline::checkTrackHeight(bool force)
......
......@@ -94,7 +94,6 @@ public:
void loadGuides(QMap <double, QString> guidesData);
void checkTrackHeight(bool force = false);
void updateProfile();
void updatePalette();
void refreshIcons();
/** @brief Returns a kdenlive effect xml description from an effect tag / id */
......@@ -156,7 +155,7 @@ public slots:
void slotSaveTimelinePreview(const QString &path);
void checkDuration(int duration);
void slotShowTrackEffects(int);
void updateProjectFps();
void updateProfile(bool fpsChanged);
private:
Mlt::Tractor *m_tractor;
......
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