Commit 8af30d4e authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix monitor overlay not updating on profile change.

Related to #538
parent 61a3d1e3
Pipeline #15709 passed with stage
in 14 minutes and 4 seconds
......@@ -82,7 +82,7 @@ AnimationWidget::AnimationWidget(std::shared_ptr<AssetParameterModel> model, QMo
}
m_monitorSize = pCore->getCurrentFrameSize();
m_monitor = pCore->getMonitor(m_model->monitorId);
m_timePos = new TimecodeDisplay(m_monitor->timecode(), this);
m_timePos = new TimecodeDisplay(pCore->timecode(), this);
m_ruler = new AnimKeyframeRuler(0, m_outPoint - m_inPoint, this);
connect(m_ruler, &AnimKeyframeRuler::addKeyframe, this, &AnimationWidget::slotAddKeyframe);
connect(m_ruler, &AnimKeyframeRuler::removeKeyframe, this, &AnimationWidget::slotDeleteKeyframe);
......
......@@ -97,7 +97,7 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
m_toolbar = new QToolBar(this);
Monitor *monitor = pCore->getMonitor(m_model->monitorId);
m_time = new TimecodeDisplay(monitor->timecode(), this);
m_time = new TimecodeDisplay(pCore->timecode(), this);
m_time->setRange(0, duration - 1);
m_toolbar->addWidget(m_buttonPrevious);
......
......@@ -36,7 +36,7 @@ PositionEditWidget::PositionEditWidget(std::shared_ptr<AssetParameterModel> mode
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
m_display = new TimecodeDisplay(pCore->monitorManager()->timecode(), this);
m_display = new TimecodeDisplay(pCore->timecode(), this);
m_display->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
layout->addWidget(label);
......
......@@ -68,7 +68,7 @@ Generators::Generators(Monitor *monitor, const QString &path, QWidget *parent)
m_preview->setPixmap(m_pixmap.scaledToWidth(m_preview->width()));
auto *hlay = new QHBoxLayout;
hlay->addWidget(new QLabel(i18n("Duration")));
m_timePos = new TimecodeDisplay(monitor->timecode(), this);
m_timePos = new TimecodeDisplay(pCore->timecode(), this);
if (base.hasAttribute(QStringLiteral("updateonduration"))) {
connect(m_timePos, &TimecodeDisplay::timeCodeEditingFinished, this, &Generators::updateDuration);
}
......
......@@ -353,8 +353,10 @@ bool Core::setCurrentProfile(const QString &profilePath)
m_projectProfile->set_explicit(true);
}
// inform render widget
m_timecode.setFormat(getCurrentProfile()->fps());
profileChanged();
m_mainWindow->updateRenderWidgetProfile();
pCore->monitorManager()->resetProfiles();
pCore->monitorManager()->updatePreviewScaling();
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()->getModel()) {
m_mainWindow->getCurrentTimeline()->controller()->getModel()->updateProfile(getProjectProfile());
......@@ -391,6 +393,7 @@ double Core::getCurrentFps() const
return getCurrentProfile()->fps();
}
QSize Core::getCurrentFrameDisplaySize() const
{
return {(int)(getCurrentProfile()->height() * getCurrentDar() + 0.5), getCurrentProfile()->height()};
......@@ -578,6 +581,11 @@ KdenliveDoc *Core::currentDoc()
return m_projectManager->current();
}
Timecode Core::timecode() const
{
return m_timecode;
}
void Core::setDocumentModified()
{
m_projectManager->current()->setModified();;
......
......@@ -19,6 +19,8 @@ the Free Software Foundation, either version 3 of the License, or
#include <QUrl>
#include <memory>
#include <QPoint>
#include "timecode.h"
class Bin;
class DocUndoStack;
class EffectStackModel;
......@@ -93,6 +95,8 @@ public:
ProjectManager *projectManager();
/** @brief Returns a pointer to the current project. */
KdenliveDoc *currentDoc();
/** @brief Returns project's timecode. */
Timecode timecode() const;
/** @brief Set current project modified. */
void setDocumentModified();
/** @brief Returns a pointer to the monitor manager. */
......@@ -228,6 +232,7 @@ private:
QString m_currentProfile;
QString m_profile;
Timecode m_timecode;
std::unique_ptr<Mlt::Profile> m_thumbProfile;
/** @brief Mlt profile used in the consumer 's monitors */
std::unique_ptr<Mlt::Profile> m_projectProfile;
......
......@@ -1361,7 +1361,6 @@ void KdenliveDoc::updateProjectProfile(bool reloadProducers)
double fps = pCore->getCurrentFps();
double fpsChanged = m_timecode.fps() / fps;
m_timecode.setFormat(fps);
pCore->monitorManager()->resetProfiles(m_timecode);
if (!reloadProducers) {
return;
}
......
......@@ -1590,7 +1590,7 @@ void GLWidget::refreshSceneLayout()
return;
}
QSize s = pCore->getCurrentFrameSize();
rootObject()->setProperty("profile", s);
m_proxy->profileChanged();
rootObject()->setProperty("scalex", (double)m_rect.width() / s.width() * m_zoom);
rootObject()->setProperty("scaley", (double)m_rect.height() / s.height() * m_zoom);
}
......
......@@ -372,7 +372,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_toolbar->addAction(m_sceneVisibilityAction);
m_toolbar->addSeparator();
m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this);
m_timePos = new TimecodeDisplay(pCore->timecode(), this);
m_toolbar->addWidget(m_timePos);
auto *configButton = new QToolButton(m_toolbar);
......@@ -605,20 +605,6 @@ void Monitor::slotForceSize(QAction *a)
updateGeometry();
}
QString Monitor::getTimecodeFromFrames(int pos)
{
return m_monitorManager->timecode().getTimecodeFromFrames(pos);
}
double Monitor::fps() const
{
return m_monitorManager->timecode().fps();
}
Timecode Monitor::timecode() const
{
return m_monitorManager->timecode();
}
void Monitor::updateMarkers()
{
......@@ -627,8 +613,8 @@ void Monitor::updateMarkers()
QList<CommentedTime> markers = m_controller->getMarkerModel()->getAllMarkers();
if (!markers.isEmpty()) {
for (int i = 0; i < markers.count(); ++i) {
int pos = (int)markers.at(i).time().frames(m_monitorManager->timecode().fps());
QString position = m_monitorManager->timecode().getTimecode(markers.at(i).time()) + QLatin1Char(' ') + markers.at(i).comment();
int pos = (int)markers.at(i).time().frames(pCore->getCurrentFps());
QString position = pCore->timecode().getTimecode(markers.at(i).time()) + QLatin1Char(' ') + markers.at(i).comment();
QAction *go = m_markerMenu->addAction(position);
go->setData(pos);
}
......@@ -647,8 +633,8 @@ void Monitor::setGuides(const QMap<double, QString> &guides)
i.next();
CommentedTime timeGuide(GenTime(i.key()), i.value());
guidesList << timeGuide;
int pos = (int)timeGuide.time().frames(m_monitorManager->timecode().fps());
QString position = m_monitorManager->timecode().getTimecode(timeGuide.time()) + QLatin1Char(' ') + timeGuide.comment();
int pos = (int)timeGuide.time().frames(pCore->getCurrentFps());
QString position = pCore->timecode().getTimecode(timeGuide.time()) + QLatin1Char(' ') + timeGuide.comment();
QAction *go = m_markerMenu->addAction(position);
go->setData(pos);
}
......@@ -660,14 +646,14 @@ void Monitor::setGuides(const QMap<double, QString> &guides)
void Monitor::slotSeekToPreviousSnap()
{
if (m_controller) {
m_glMonitor->getControllerProxy()->setPosition(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
m_glMonitor->getControllerProxy()->setPosition(getSnapForPos(true).frames(pCore->getCurrentFps()));
}
}
void Monitor::slotSeekToNextSnap()
{
if (m_controller) {
m_glMonitor->getControllerProxy()->setPosition(getSnapForPos(false).frames(m_monitorManager->timecode().fps()));
m_glMonitor->getControllerProxy()->setPosition(getSnapForPos(false).frames(pCore->getCurrentFps()));
}
}
......@@ -986,7 +972,7 @@ void Monitor::keyPressEvent(QKeyEvent *event)
void Monitor::slotMouseSeek(int eventDelta, uint modifiers)
{
if ((modifiers & Qt::ControlModifier) != 0u) {
int delta = m_monitorManager->timecode().fps();
int delta = qRound(pCore->getCurrentFps());
if (eventDelta > 0) {
delta = 0 - delta;
}
......@@ -1150,7 +1136,7 @@ void Monitor::checkOverlay(int pos)
if (model) {
bool found = false;
CommentedTime marker = model->getMarker(GenTime(pos, m_monitorManager->timecode().fps()), &found);
CommentedTime marker = model->getMarker(GenTime(pos, pCore->getCurrentFps()), &found);
if (found) {
overlayText = marker.comment();
}
......@@ -1491,10 +1477,10 @@ void Monitor::setCustomProfile(const QString &profile, const Timecode &tc)
void Monitor::resetProfile()
{
m_timePos->updateTimeCode(m_monitorManager->timecode());
m_timePos->updateTimeCode(pCore->timecode());
m_glMonitor->reloadProfile();
m_glMonitor->rootObject()->setProperty("framesize", QRect(0, 0, m_glMonitor->profileSize().width(), m_glMonitor->profileSize().height()));
double fps = m_monitorManager->timecode().fps();
double fps = pCore->getCurrentFps();
// Update drop frame info
m_qmlManager->setProperty(QStringLiteral("dropped"), false);
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(fps, 'g', 2));
......@@ -1724,7 +1710,7 @@ void Monitor::checkDrops(int dropped)
if (m_droppedTimer.isValid()) {
if (m_droppedTimer.hasExpired(1000)) {
m_droppedTimer.invalidate();
double fps = m_monitorManager->timecode().fps();
double fps = pCore->getCurrentFps();
if (dropped == 0) {
// No dropped frames since last check
m_qmlManager->setProperty(QStringLiteral("dropped"), false);
......@@ -1764,7 +1750,7 @@ QString Monitor::getMarkerThumb(GenTime pos)
QDir dir = pCore->currentDoc()->getCacheDir(CacheThumbs, &ok);
if (ok) {
QString url = dir.absoluteFilePath(m_controller->getClipHash() + QLatin1Char('#') +
QString::number((int)pos.frames(m_monitorManager->timecode().fps())) + QStringLiteral(".png"));
QString::number((int)pos.frames(pCore->getCurrentFps())) + QStringLiteral(".png"));
if (QFile::exists(url)) {
return url;
}
......@@ -1975,7 +1961,7 @@ void Monitor::loadQmlScene(MonitorSceneType type)
default:
break;
}
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(m_monitorManager->timecode().fps(), 'g', 2));
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(pCore->getCurrentFps(), 'g', 2));
}
void Monitor::setQmlProperty(const QString &name, const QVariant &value)
......
......@@ -105,12 +105,8 @@ public:
void reloadProducer(const QString &id);
/** @brief Reimplemented from QWidget, updates the palette colors. */
void setPalette(const QPalette &p);
/** @brief Returns a hh:mm:ss timecode from a frame number. */
QString getTimecodeFromFrames(int pos);
/** @brief Returns current project's fps. */
double fps() const;
/** @brief Returns current project's timecode. */
Timecode timecode() const;
/** @brief Get url for the clip's thumbnail */
QString getMarkerThumb(GenTime pos);
int getZoneStart();
......
......@@ -43,11 +43,6 @@ MonitorManager::MonitorManager(QObject *parent)
connect(&refreshTimer, &QTimer::timeout, this, &MonitorManager::forceProjectMonitorRefresh);
}
Timecode MonitorManager::timecode() const
{
return m_timecode;
}
QAction *MonitorManager::getAction(const QString &name)
{
return pCore->window()->action(name.toUtf8().constData());
......@@ -270,18 +265,18 @@ void MonitorManager::slotForwardOneFrame()
void MonitorManager::slotRewindOneSecond()
{
if (m_activeMonitor == m_clipMonitor) {
m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
m_clipMonitor->slotRewindOneFrame(qRound(pCore->getCurrentFps()));
} else if (m_activeMonitor == m_projectMonitor) {
m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
m_projectMonitor->slotRewindOneFrame(qRound(pCore->getCurrentFps()));
}
}
void MonitorManager::slotForwardOneSecond()
{
if (m_activeMonitor == m_clipMonitor) {
m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
m_clipMonitor->slotForwardOneFrame(qRound(pCore->getCurrentFps()));
} else if (m_activeMonitor == m_projectMonitor) {
m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
m_projectMonitor->slotForwardOneFrame(qRound(pCore->getCurrentFps()));
}
}
......@@ -303,9 +298,8 @@ void MonitorManager::slotEnd()
}
}
void MonitorManager::resetProfiles(const Timecode &tc)
void MonitorManager::resetProfiles()
{
m_timecode = tc;
m_clipMonitor->resetProfile();
m_projectMonitor->resetProfile();
}
......
......@@ -22,7 +22,6 @@
#include "monitor.h"
#include "timecode.h"
#include <QDir>
#include <QMutex>
#include <QTimer>
......@@ -44,7 +43,7 @@ public:
void appendMonitor(AbstractMonitor *monitor);
void removeMonitor(AbstractMonitor *monitor);
Timecode timecode() const;
void resetProfiles(const Timecode &tc);
void resetProfiles();
/** @brief delete and rebuild consumer, for example when external display is switched */
void resetConsumers(bool fullReset);
void stopActiveMonitor();
......@@ -138,7 +137,6 @@ private:
void setupActions();
Monitor *m_clipMonitor{nullptr};
Monitor *m_projectMonitor{nullptr};
Timecode m_timecode;
AbstractMonitor *m_activeMonitor{nullptr};
QList<AbstractMonitor *> m_monitorsList;
KDualAction *m_muteAction;
......
......@@ -295,3 +295,9 @@ void MonitorProxy::setAudioThumb(const QUrl thumbPath)
m_audioThumb = thumbPath;
emit audioThumbChanged();
}
QPoint MonitorProxy::profile()
{
QSize s = pCore->getCurrentFrameSize();
return QPoint(s.width(), s.height());
}
......@@ -38,6 +38,7 @@ class MonitorProxy : public QObject
Q_OBJECT
// Q_PROPERTY(int consumerPosition READ consumerPosition NOTIFY consumerPositionChanged)
Q_PROPERTY(int position MEMBER m_position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(QPoint profile READ profile NOTIFY profileChanged)
Q_PROPERTY(int seekFinished MEMBER m_seekFinished NOTIFY seekFinishedChanged)
Q_PROPERTY(int zoneIn READ zoneIn WRITE setZoneIn NOTIFY zoneChanged)
Q_PROPERTY(int zoneOut READ zoneOut WRITE setZoneOut NOTIFY zoneChanged)
......@@ -84,6 +85,7 @@ public:
QImage extractFrame(int frame_position, const QString &path = QString(), int width = -1, int height = -1, bool useSourceProfile = false);
Q_INVOKABLE QString toTimecode(int frames) const;
Q_INVOKABLE double fps() const;
QPoint profile();
void setClipProperties(ClipType::ProducerType type, bool hasAV, const QString clipName);
void setAudioThumb(const QUrl thumbPath = QUrl());
......@@ -107,6 +109,7 @@ signals:
void clipNameChanged();
void clipTypeChanged();
void audioThumbChanged();
void profileChanged();
private:
GLWidget *q;
......
......@@ -14,7 +14,7 @@ Item {
height: 300; width: 400
property string markerText
property int itemType: 0
property point profile
property point profile: controller.profile
property double zoom
property double scalex
property double scaley
......
......@@ -12,7 +12,7 @@ Item {
// default size, but scalable by user
height: 300; width: 400
property string markerText
property point profile
property point profile: controller.profile
property double zoom
property double scalex
property double scaley
......
......@@ -10,7 +10,7 @@ Item {
property string comment
property string framenum
property rect framesize
property point profile
property point profile: controller.profile
property point center
property double scalex
property double scaley
......
......@@ -11,7 +11,7 @@ Item {
property string framenum
property rect framesize
property rect adjustedFrame
property point profile
property point profile: controller.profile
property point center
property double scalex
property double scaley
......
......@@ -10,7 +10,7 @@ Item {
height: 300; width: 400
property string comment
property string framenum
property point profile
property point profile: controller.profile
property point center
property real baseUnit: fontMetrics.font.pointSize
property double scalex : 1
......
......@@ -17,7 +17,7 @@ Item {
property real baseUnit: fontMetrics.font.pixelSize * 0.8
// percentage holds splitter pos relative to the scene percentage
property double percentage
property point profile
property point profile: controller.profile
property point center
property double offsetx
property double offsety
......
......@@ -709,7 +709,6 @@ void ProjectManager::prepareSave()
void ProjectManager::slotResetProfiles()
{
m_project->resetProfile();
pCore->monitorManager()->resetProfiles(m_project->timecode());
pCore->monitorManager()->updateScopeSource();
}
......
......@@ -88,7 +88,7 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, QString projectTit
, m_missingMessage(nullptr)
, m_projectTitlePath(std::move(projectTitlePath))
, m_tc(tc)
, m_fps(monitor->fps())
, m_fps(pCore->getCurrentFps())
, m_guides(QList<QGraphicsLineItem *>())
{
setupUi(this);
......
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