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

Fix preview scaling switches monitor focus to clip monitor

parent fcf8ee8b
......@@ -1991,7 +1991,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();
m_monitor->refreshMonitor();
} else {
m_monitor->slotActivateMonitor();
}
......@@ -3020,9 +3020,8 @@ void Bin::refreshClip(const QString &id)
{
if (m_monitor->activeClipId() == id) {
if (pCore->monitorManager()->clipMonitorVisible()) {
m_monitor->slotActivateMonitor();
m_monitor->refreshMonitor(true);
}
m_monitor->refreshMonitorIfActive(true);
}
}
......
......@@ -350,15 +350,34 @@ std::unique_ptr<ProfileModel> &Core::getCurrentProfile() const
return ProfileRepository::get()->getProfile(m_currentProfile);
}
Mlt::Profile &Core::getMonitorProfile()
{
return m_monitorProfile;
}
Mlt::Profile *Core::getProjectProfile()
{
if (!m_projectProfile) {
m_projectProfile = std::make_unique<Mlt::Profile>(m_currentProfile.toStdString().c_str());
m_projectProfile->set_explicit(1);
updateMonitorProfile();
}
return m_projectProfile.get();
}
void Core::updateMonitorProfile()
{
m_monitorProfile.set_colorspace(m_projectProfile->colorspace());
m_monitorProfile.set_frame_rate(m_projectProfile->frame_rate_num(), m_projectProfile->frame_rate_den());
m_monitorProfile.set_width(m_projectProfile->width());
m_monitorProfile.set_height(m_projectProfile->height());
m_monitorProfile.set_progressive(m_projectProfile->progressive());
m_monitorProfile.set_sample_aspect(m_projectProfile->sample_aspect_num(), m_projectProfile->sample_aspect_den());
m_monitorProfile.set_display_aspect(m_projectProfile->display_aspect_num(), m_projectProfile->display_aspect_den());
m_monitorProfile.set_explicit(true);
}
const QString &Core::getCurrentProfilePath() const
{
return m_currentProfile;
......@@ -383,6 +402,7 @@ bool Core::setCurrentProfile(const QString &profilePath)
m_projectProfile->set_display_aspect(getCurrentProfile()->display_aspect_num(), getCurrentProfile()->display_aspect_den());
m_projectProfile->set_width(getCurrentProfile()->width());
m_projectProfile->set_explicit(true);
updateMonitorProfile();
}
// inform render widget
m_timecode.setFormat(getCurrentProfile()->fps());
......
......@@ -27,6 +27,8 @@ the Free Software Foundation, either version 3 of the License, or
#include <unordered_set>
#include "timecode.h"
#include "mlt++/MltProfile.h"
class Bin;
class DocUndoStack;
class EffectStackModel;
......@@ -48,7 +50,6 @@ class TimeRemap;
namespace Mlt {
class Repository;
class Producer;
class Profile;
} // namespace Mlt
#define EXIT_RESTART (42)
......@@ -227,9 +228,11 @@ public:
void processInvalidFilter(const QString service, const QString id, const QString message);
/** @brief Update current project's tags */
void updateProjectTags(QMap <QString, QString> tags);
/** @brief Returns the consumer profile, that will be scaled
* according to preview settings. Should only be used on the consumer */
/** @brief Returns the project profile */
Mlt::Profile *getProjectProfile();
/** @brief Returns the consumer profile, that will be scaled
* according to preview settings. Should only be used on the consumer */
Mlt::Profile &getMonitorProfile();
/** @brief Returns a copy of current timeline's master playlist */
std::unique_ptr<Mlt::Producer> getMasterProducerInstance();
/** @brief Returns a copy of a track's playlist */
......@@ -287,6 +290,8 @@ private:
Timecode m_timecode;
std::unique_ptr<Mlt::Profile> m_thumbProfile;
/** @brief Mlt profile used in the consumer 's monitors */
Mlt::Profile m_monitorProfile;
/** @brief Mlt profile used to build the project's clips */
std::unique_ptr<Mlt::Profile> m_projectProfile;
bool m_guiConstructed = false;
/** @brief Check that the profile is valid (width is a multiple of 8 and height a multiple of 2 */
......@@ -312,11 +317,13 @@ public slots:
void updateMasterZones();
/** @brief Open the proxies test dialog. */
void testProxies();
/** @brief Refresh the monitor profile when project profile changes. */
void updateMonitorProfile();
signals:
void coreIsReady();
void updateLibraryPath();
void updateMonitorProfile();
//void updateMonitorProfile();
/** @brief Call config dialog on a selected page / tab */
void showConfigDialog(int, int);
void finalizeRecording(const QString &captureFile);
......
......@@ -83,6 +83,11 @@ RemapView::RemapView(QWidget *parent)
connect(&timer, &QTimer::timeout, this, &RemapView::reloadProducer);
}
bool RemapView::isInRange() const
{
return m_bottomPosition != -1;
}
void RemapView::updateInPos(int pos)
{
if (m_currentKeyframe.second > -1) {
......@@ -1015,14 +1020,19 @@ void RemapView::slotSetPosition(int pos)
void RemapView::slotSetBottomPosition(int pos)
{
qDebug()<<"=== SETTING BOTTOM POS: "<<pos;
if (pos < 0 || pos + m_inFrame > m_keyframes.lastKey()) {
pos = -1;
}
if (pos != m_bottomPosition) {
m_bottomPosition = pos;
qDebug()<<"==== CURRENT: "<<(m_bottomPosition + m_inFrame)<<" = "<<m_keyframes.keys();
bool isKfr = m_keyframes.contains(m_bottomPosition + m_inFrame);
if (isKfr) {
bool isLast = m_bottomPosition + m_inFrame == m_keyframes.firstKey() || m_bottomPosition + m_inFrame == m_keyframes.lastKey();
emit atKeyframe(isKfr, isLast);
if (m_bottomPosition > -1) {
bool isKfr = m_keyframes.contains(m_bottomPosition + m_inFrame);
if (isKfr) {
bool isLast = m_bottomPosition + m_inFrame == m_keyframes.firstKey() || m_bottomPosition + m_inFrame == m_keyframes.lastKey();
emit atKeyframe(isKfr, isLast);
} else {
emit atKeyframe(false, false);
}
} else {
emit atKeyframe(false, false);
}
......@@ -1720,7 +1730,6 @@ void TimeRemap::selectedClip(int cid)
}
});
m_seekConnection2 = connect(pCore->getMonitor(Kdenlive::ProjectMonitor), &Monitor::seekPosition, [this](int pos) {
//qDebug()<<"=== PROJECT SEEK: "<<pos<<", START: "<<m_view->m_startPos<<", MAPPED: "<<GenTime(m_view->m_remapLink->anim_get_double("map", pos - m_view->m_startPos)).frames(pCore->getCurrentFps());
m_view->slotSetBottomPosition(pos - m_view->m_startPos);
});
}
......@@ -1938,6 +1947,11 @@ void TimeRemap::switchRemapParam()
updateKeyframesWithUndo(QMap<int,int>(),QMap<int,int>());
}
bool TimeRemap::isInRange() const
{
return m_cid != -1 && m_view->isInRange();
}
TimeRemap::~TimeRemap()
{
//delete m_previewTimer;
......
......@@ -56,6 +56,8 @@ public:
int remapMax() const;
bool movingKeyframe() const;
void refreshOnDurationChanged(int remapDuration);
/** @brief Returns true if timeline cursor is inside the remapped clip */
bool isInRange() const;
QTimer timer;
protected:
......@@ -160,6 +162,8 @@ public:
void setClip(std::shared_ptr<ProjectClip> clip, int in = -1, int out = -1);
/** @brief the bin id of the clip currently active in remap widget */
const QString &currentClip() const;
/** @brief Returns true if timeline cursor is inside the remapped clip */
bool isInRange() const;
private slots:
void updateKeyframes(bool resize = true);
......
......@@ -142,7 +142,7 @@ GLWidget::GLWidget(int id, QObject *parent)
connect(this, &QQuickWindow::sceneGraphInitialized, this, &GLWidget::initializeGL, Qt::DirectConnection);
connect(this, &QQuickWindow::beforeRendering, this, &GLWidget::paintGL, Qt::DirectConnection);
connect(pCore.get(), &Core::updateMonitorProfile, this, &GLWidget::reloadProfile);
//connect(pCore.get(), &Core::updateMonitorProfile, this, &GLWidget::reloadProfile);
registerTimelineItems();
m_proxy = new MonitorProxy(this);
......@@ -1091,7 +1091,7 @@ int GLWidget::reconfigure()
QString audioBackend = (KdenliveSettings::external_display()) ? QString("decklink:%1").arg(KdenliveSettings::blackmagic_output_device())
: KdenliveSettings::audiobackend();
if (m_consumer == nullptr || serviceName.isEmpty() || serviceName != audioBackend) {
m_consumer.reset(new Mlt::FilteredConsumer(*pCore->getProjectProfile(), audioBackend.toLatin1().constData()));
m_consumer.reset(new Mlt::FilteredConsumer(pCore->getMonitorProfile(), audioBackend.toLatin1().constData()));
if (m_consumer->is_valid()) {
serviceName = audioBackend;
} else {
......@@ -1103,7 +1103,7 @@ int GLWidget::reconfigure()
// Already tested
continue;
}
m_consumer.reset(new Mlt::FilteredConsumer(*pCore->getProjectProfile(), bk.toLatin1().constData()));
m_consumer.reset(new Mlt::FilteredConsumer(pCore->getMonitorProfile(), bk.toLatin1().constData()));
if (m_consumer->is_valid()) {
if (audioBackend == KdenliveSettings::sdlAudioBackend()) {
// switch sdl audio backend
......@@ -1883,6 +1883,8 @@ bool GLWidget::updateScaling()
return false;
}
m_profileSize = profileSize;
pCore->getMonitorProfile().set_width(m_profileSize.width());
pCore->getMonitorProfile().set_height(m_profileSize.height());
if (m_consumer) {
m_consumer->set("width", m_profileSize.width());
m_consumer->set("height", m_profileSize.height());
......
......@@ -217,10 +217,11 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
}
emit m_monitorManager->scalingChanged();
emit m_monitorManager->updatePreviewScaling();
m_monitorManager->refreshMonitors();
});
connect(manager, &MonitorManager::updatePreviewScaling, this, [this, scalingAction]() {
bool scalingChanged = m_glMonitor->updateScaling();
m_glMonitor->updateScaling();
switch (KdenliveSettings::previewScaling()) {
case 2:
scalingAction->setCurrentIndex(1);
......@@ -238,9 +239,6 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
scalingAction->setCurrentIndex(0);
break;
}
if (scalingChanged) {
refreshMonitorIfActive();
}
});
scalingAction->setFrame(false);
scalingAction->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
......@@ -1398,7 +1396,7 @@ void Monitor::forceMonitorRefresh()
m_glMonitor->refresh();
}
void Monitor::refreshMonitorIfActive(bool directUpdate)
void Monitor::refreshMonitor(bool directUpdate)
{
if (!m_glMonitor->isReady()) {
return;
......@@ -1422,6 +1420,18 @@ void Monitor::refreshMonitorIfActive(bool directUpdate)
}
}
void Monitor::refreshMonitorIfActive(bool directUpdate)
{
if (!m_glMonitor->isReady() || !isActive()) {
return;
}
if (directUpdate) {
m_glMonitor->refresh();
} else {
m_glMonitor->requestRefresh();
}
}
void Monitor::pause()
{
if (!m_playAction->isActive() || !slotActivateMonitor()) {
......
......@@ -327,6 +327,7 @@ public slots:
/** @brief Check current position to show relevant infos in qml view (markers, zone in/out, etc). */
void checkOverlay(int pos = -1);
void refreshMonitorIfActive(bool directUpdate = false) override;
void refreshMonitor(bool directUpdate = false);
void forceMonitorRefresh();
/** @brief Clear read ahead cache, to ensure up to date audio */
void purgeCache();
......
......@@ -31,6 +31,7 @@
#include "kdenlive_debug.h"
#include <QObject>
#include <dialogs/timeremap.h>
const double MonitorManager::speedArray[6] = {1. ,1.5, 2., 3., 5.5, 10.};
......@@ -112,14 +113,14 @@ void MonitorManager::refreshProjectRange(QPair<int, int> range)
}
}
void MonitorManager::refreshProjectMonitor()
void MonitorManager::refreshProjectMonitor(bool directUpdate)
{
m_projectMonitor->refreshMonitorIfActive();
m_projectMonitor->refreshMonitor(directUpdate);
}
void MonitorManager::refreshClipMonitor(bool directUpdate)
{
m_clipMonitor->refreshMonitorIfActive(directUpdate);
m_clipMonitor->refreshMonitor(directUpdate);
}
void MonitorManager::forceProjectMonitorRefresh()
......@@ -137,6 +138,24 @@ bool MonitorManager::clipMonitorVisible() const
return (m_clipMonitor->monitorIsFullScreen() || (m_clipMonitor->isVisible() && !m_clipMonitor->visibleRegion().isEmpty()));
}
void MonitorManager::refreshMonitors()
{
if (m_activeMonitor) {
if (m_activeMonitor == m_clipMonitor) {
activateMonitor(Kdenlive::ProjectMonitor);
refreshProjectMonitor(true);
activateMonitor(Kdenlive::ClipMonitor);
refreshClipMonitor(true);
} else {
activateMonitor(Kdenlive::ClipMonitor);
refreshClipMonitor(true);
activateMonitor(Kdenlive::ProjectMonitor);
refreshProjectMonitor(true);
}
}
}
bool MonitorManager::activateMonitor(Kdenlive::MonitorId name)
{
if ((m_activeMonitor != nullptr) && m_activeMonitor->id() == name) {
......
......@@ -72,6 +72,8 @@ public:
bool projectMonitorVisible() const;
/** @brief Returns true if the clip monitor is visible (and not tabbed under another dock. */
bool clipMonitorVisible() const;
/** @brief Refresh both monitors. */
void refreshMonitors();
QTimer refreshTimer;
static const double speedArray[6];
......@@ -97,7 +99,7 @@ public slots:
void slotSetInPoint();
void slotSetOutPoint();
void focusProjectMonitor();
void refreshProjectMonitor();
void refreshProjectMonitor(bool directUpdate = false);
/** @brief Refresh project monitor if the timeline cursor is inside the range. */
void refreshProjectRange(QPair<int, int>range);
void refreshClipMonitor(bool directUpdate = false);
......
......@@ -2290,7 +2290,7 @@ void TimelineController::switchCompositing(int mode)
}
if (mode > 0) {
const QString compositeGeometry =
QStringLiteral("0=0/0:%1x%2").arg(m_model->m_tractor->profile()->width()).arg(m_model->m_tractor->profile()->height());
QStringLiteral("0 0 %1 %2").arg(m_model->m_tractor->profile()->width()).arg(m_model->m_tractor->profile()->height());
// Loop through tracks
for (int track = 0; track < m_model->getTracksCount(); track++) {
......
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