move away from locally stored profile info

fix bin registration for timeline clips
lock a bin clip until it's producer is ready so that redo does not mess up timeline
parent 4d6f7496
......@@ -1295,7 +1295,7 @@ void Bin::setDocument(KdenliveDoc *project)
m_folderCounter = 1;
m_doc = project;
int iconHeight = QFontInfo(font()).pixelSize() * 3.5;
m_iconSize = QSize(iconHeight * m_doc->dar(), iconHeight);
m_iconSize = QSize(iconHeight * pCore->getCurrentDar(), iconHeight);
m_jobManager = new JobManager(this);
setEnabled(true);
blockSignals(false);
......
......@@ -272,6 +272,15 @@ std::unique_ptr<ProfileModel> &Core::getCurrentProfile() const
return ProfileRepository::get()->getProfile(profile);
}
bool Core::setCurrentProfile(const QString &profilePath)
{
if (ProfileRepository::get()->profileExists(profilePath)) {
KdenliveSettings::setCurrent_profile(profilePath);
return true;
}
return false;
}
double Core::getCurrentSar() const
{
return getCurrentProfile()->sar();
......
......@@ -99,7 +99,10 @@ public:
/** @brief Returns a pointer to the current profile */
std::unique_ptr<ProfileModel> &getCurrentProfile() const;
/** @brief Define the active profile
* @returns true if profile exists, false if not found
*/
bool setCurrentProfile(const QString &profilePath);
/** @brief Returns Sample Aspect Ratio of current profile */
double getCurrentSar() const;
/** @brief Returns Display Aspect Ratio of current profile */
......
......@@ -23,6 +23,7 @@
#include "profiles/profilemodel.hpp"
#include "profiles/profilerepository.hpp"
#include "timecode.h"
#include "core.h"
#include "ui_saveprofile_ui.h"
#include "utils/KoIconUtils.h"
......@@ -164,10 +165,9 @@ const QString RenderJobItem::metadata() const
return m_data;
}
RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, const QString &profile, QWidget *parent)
RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidget *parent)
: QDialog(parent)
, m_projectFolder(projectfolder)
, m_profile(profile)
, m_blockProcessing(false)
{
m_view.setupUi(this);
......@@ -435,7 +435,7 @@ void RenderWidget::setGuides(const QMap<double, QString> &guidesData, double dur
m_view.render_guide->setEnabled(false);
m_view.create_chapter->setEnabled(false);
}
double fps = ProfileRepository::get()->getProfile(m_profile)->fps();
double fps = pCore->getCurrentProfile()->fps();
QMapIterator<double, QString> i(guidesData);
while (i.hasNext()) {
i.next();
......@@ -1146,7 +1146,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
}
bool resizeProfile = false;
std::unique_ptr<ProfileModel> &profile = ProfileRepository::get()->getProfile(m_profile);
std::unique_ptr<ProfileModel> &profile = pCore->getCurrentProfile();
if (renderArgs.contains(QLatin1String("%dv_standard"))) {
QString std;
if (fmod((double)profile->frame_rate_num() / profile->frame_rate_den(), 30.01) > 27) {
......@@ -1510,8 +1510,9 @@ int RenderWidget::waitingJobsCount() const
return count;
}
void RenderWidget::setProfile(const QString &profile)
void RenderWidget::adjustViewToProfile()
{
//TODO: Update settings on profile change
m_view.scanning_list->setCurrentIndex(0);
m_view.rescale_width->setValue(KdenliveSettings::defaultrescalewidth());
if (!m_view.rescale_keep->isChecked()) {
......@@ -1519,10 +1520,7 @@ void RenderWidget::setProfile(const QString &profile)
m_view.rescale_height->setValue(KdenliveSettings::defaultrescaleheight());
m_view.rescale_height->blockSignals(false);
}
if (m_profile != profile) {
m_profile = profile;
refreshView();
}
refreshView();
}
void RenderWidget::refreshView()
......@@ -1536,7 +1534,7 @@ void RenderWidget::refreshView()
const QColor disabledbg = scheme.background(KColorScheme::NegativeBackground).color();
// We borrow a reference to the profile's pointer to query it more easily
std::unique_ptr<ProfileModel> &profile = ProfileRepository::get()->getProfile(m_profile);
std::unique_ptr<ProfileModel> &profile = pCore->getCurrentProfile();
double project_framerate = (double)profile->frame_rate_num() / profile->frame_rate_den();
for (int i = 0; i < m_view.formats->topLevelItemCount(); ++i) {
QTreeWidgetItem *group = m_view.formats->topLevelItem(i);
......@@ -2643,7 +2641,7 @@ void RenderWidget::slotUpdateRescaleWidth(int val)
return;
}
m_view.rescale_height->blockSignals(true);
std::unique_ptr<ProfileModel> &profile = ProfileRepository::get()->getProfile(m_profile);
std::unique_ptr<ProfileModel> &profile = pCore->getCurrentProfile();
m_view.rescale_height->setValue(val * profile->height() / profile->width());
KdenliveSettings::setDefaultrescaleheight(m_view.rescale_height->value());
m_view.rescale_height->blockSignals(false);
......@@ -2656,7 +2654,7 @@ void RenderWidget::slotUpdateRescaleHeight(int val)
return;
}
m_view.rescale_width->blockSignals(true);
std::unique_ptr<ProfileModel> &profile = ProfileRepository::get()->getProfile(m_profile);
std::unique_ptr<ProfileModel> &profile = pCore->getCurrentProfile();
m_view.rescale_width->setValue(val * profile->width() / profile->height());
KdenliveSettings::setDefaultrescaleheight(m_view.rescale_width->value());
m_view.rescale_width->blockSignals(false);
......
......@@ -113,11 +113,11 @@ class RenderWidget : public QDialog
Q_OBJECT
public:
explicit RenderWidget(const QString &projectfolder, bool enableProxy, const QString &profile, QWidget *parent = nullptr);
explicit RenderWidget(const QString &projectfolder, bool enableProxy, QWidget *parent = nullptr);
virtual ~RenderWidget();
void setGuides(const QMap<double, QString> &guidesData, double duration);
void focusFirstVisibleItem(const QString &profile = QString());
void setProfile(const QString &profile);
void adjustViewToProfile();
void setRenderJob(const QString &dest, int progress = 0);
void setRenderStatus(const QString &dest, int status, const QString &error);
void setDocumentPath(const QString &path);
......@@ -197,7 +197,6 @@ private slots:
private:
Ui::RenderWidget_UI m_view;
QString m_projectFolder;
QString m_profile;
RenderViewDelegate *m_scriptsDelegate;
RenderViewDelegate *m_jobsDelegate;
bool m_blockProcessing;
......
......@@ -21,6 +21,7 @@
#include "bin/bin.h"
#include "bin/bincommands.h"
#include "bin/model/markerlistmodel.hpp"
#include "profiles/profilerepository.hpp"
#include "bin/projectclip.h"
#include "core.h"
#include "dialogs/profilesdialog.h"
......@@ -76,25 +77,12 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGro
: QObject(parent)
, m_autosave(nullptr)
, m_url(url)
, m_width(0)
, m_height(0)
, m_modified(false)
, m_projectFolder(projectFolder)
{
m_commandStack = std::make_shared<DocUndoStack>(undoGroup);
m_guideModel.reset(new MarkerListModel(m_commandStack, this));
// init m_profile struct
m_profile.frame_rate_num = 0;
m_profile.frame_rate_den = 0;
m_profile.width = 0;
m_profile.height = 0;
m_profile.progressive = 0;
m_profile.sample_aspect_num = 0;
m_profile.sample_aspect_den = 0;
m_profile.display_aspect_num = 0;
m_profile.display_aspect_den = 0;
m_profile.colorspace = 0;
m_clipManager = new ClipManager(this);
connect(m_clipManager, SIGNAL(displayMessage(QString, int)), parent, SLOT(slotGotProgressInfo(QString, int)));
connect(this, SIGNAL(updateCompositionMode(int)), parent, SLOT(slotUpdateCompositeAction(int)));
......@@ -252,7 +240,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGro
// Something went wrong, or a new file was requested: create a new project
if (!success) {
m_url.clear();
m_profile = ProfilesDialog::getVideoProfile(profileName);
pCore->setCurrentProfile(profileName);
m_document = createEmptyDocument(tracks.x(), tracks.y());
updateProjectProfile(false);
}
......@@ -670,19 +658,9 @@ void KdenliveDoc::moveProjectData(const QString & /*src*/, const QString &dest)
}
}
const QString &KdenliveDoc::profilePath() const
{
return m_profile.path;
}
MltVideoProfile KdenliveDoc::mltProfile() const
{
return m_profile;
}
bool KdenliveDoc::profileChanged(const QString &profile) const
{
return m_profile.toList() != ProfilesDialog::getVideoProfile(profile).toList();
return pCore->getCurrentProfile() != ProfileRepository::get()->getProfile(profile);
}
ProfileInfo KdenliveDoc::getProfileInfo() const
......@@ -698,11 +676,6 @@ Render *KdenliveDoc::renderer()
return nullptr;
}
double KdenliveDoc::dar() const
{
return (double)m_profile.display_aspect_num / m_profile.display_aspect_den;
}
std::shared_ptr<DocUndoStack> KdenliveDoc::commandStack()
{
return m_commandStack;
......@@ -735,12 +708,12 @@ double KdenliveDoc::projectDuration() const
int KdenliveDoc::width() const
{
return m_width;
return pCore->getCurrentProfile()->width();
}
int KdenliveDoc::height() const
{
return m_height;
return pCore->getCurrentProfile()->height();
}
QUrl KdenliveDoc::url() const
......@@ -779,9 +752,9 @@ bool KdenliveDoc::isModified() const
const QString KdenliveDoc::description() const
{
if (!m_url.isValid()) {
return i18n("Untitled") + QStringLiteral("[*] / ") + m_profile.description;
return i18n("Untitled") + QStringLiteral("[*] / ") + pCore->getCurrentProfile()->description();
}
return m_url.fileName() + QStringLiteral(" [*]/ ") + m_profile.description;
return m_url.fileName() + QStringLiteral(" [*]/ ") + pCore->getCurrentProfile()->description();
}
QString KdenliveDoc::searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const
......@@ -1295,7 +1268,7 @@ QMap<QString, QString> KdenliveDoc::documentProperties()
m_documentProperties.insert(QStringLiteral("storagefolder"),
m_projectFolder + QLatin1Char('/') + m_documentProperties.value(QStringLiteral("documentid")));
}
m_documentProperties.insert(QStringLiteral("profile"), profilePath());
m_documentProperties.insert(QStringLiteral("profile"), pCore->getCurrentProfile()->path());
m_documentProperties.insert(QStringLiteral("position"), QString::number(pCore->monitorManager()->projectMonitor()->position()));
if (!m_documentProperties.contains(QStringLiteral("decimalPoint"))) {
m_documentProperties.insert(QStringLiteral("decimalPoint"), QLocale().decimalPoint());
......@@ -1348,16 +1321,18 @@ void KdenliveDoc::loadDocumentProperties()
}
QString profile = m_documentProperties.value(QStringLiteral("profile"));
if (!profile.isEmpty()) {
m_profile = ProfilesDialog::getVideoProfile(profile);
}
if (!m_profile.isValid()) {
bool profileFound = pCore->setCurrentProfile(profile);
if (!profileFound) {
// try to find matching profile from MLT profile properties
list = m_document.elementsByTagName(QStringLiteral("profile"));
if (!list.isEmpty()) {
m_profile = ProfilesDialog::getVideoProfileFromXml(list.at(0).toElement());
MltVideoProfile prof = ProfilesDialog::getVideoProfileFromXml(list.at(0).toElement());
profileFound = pCore->setCurrentProfile(prof.path);
}
}
if (!profileFound) {
qDebug()<<"ERROR, no matching profile found";
}
updateProjectProfile(false);
}
......@@ -1365,15 +1340,10 @@ void KdenliveDoc::updateProjectProfile(bool reloadProducers)
{
pCore->bin()->abortAudioThumbs();
pCore->producerQueue()->abortOperations();
KdenliveSettings::setProject_display_ratio((double)m_profile.display_aspect_num / m_profile.display_aspect_den);
double fps = (double)m_profile.frame_rate_num / m_profile.frame_rate_den;
KdenliveSettings::setProject_fps(fps);
m_width = m_profile.width;
m_height = m_profile.height;
double fps = pCore->getCurrentFps();
double fpsChanged = m_timecode.fps() / fps;
m_timecode.setFormat(fps);
KdenliveSettings::setCurrent_profile(m_profile.path);
pCore->monitorManager()->resetProfiles(m_profile, m_timecode);
pCore->monitorManager()->resetProfiles(m_timecode);
if (!reloadProducers) {
return;
}
......@@ -1385,7 +1355,6 @@ void KdenliveDoc::updateProjectProfile(bool reloadProducers)
void KdenliveDoc::resetProfile()
{
m_profile = ProfilesDialog::getVideoProfile(KdenliveSettings::current_profile());
updateProjectProfile(true);
emit docModified(true);
}
......@@ -1401,7 +1370,7 @@ void KdenliveDoc::slotSwitchProfile()
// we want a profile switch
MltVideoProfile profile = MltVideoProfile(data);
if (profile.isValid()) {
m_profile = profile;
pCore->setCurrentProfile(profile.path);
updateProjectProfile(true);
emit docModified(true);
}
......@@ -1425,24 +1394,24 @@ void KdenliveDoc::switchProfile(MltVideoProfile profile, const QString &id, cons
if (KdenliveSettings::default_profile().isEmpty()) {
// Default project format not yet confirmed, propose
QString currentProfileDesc = pCore->getCurrentProfile()->description();
KMessageBox::ButtonCode answer = KMessageBox::questionYesNoCancel(
QApplication::activeWindow(),
i18n("Your default project profile is %1, but your clip's profile is %2.\nDo you want to change default profile for future projects ?",
m_profile.description, profile.description),
currentProfileDesc, profile.description),
i18n("Change default project profile"), KGuiItem(i18n("Change default to %1", profile.description)),
KGuiItem(i18n("Keep current default %1", m_profile.description)), KGuiItem(i18n("Ask me later")));
KGuiItem(i18n("Keep current default %1", currentProfileDesc)), KGuiItem(i18n("Ask me later")));
switch (answer) {
case KMessageBox::Yes:
KdenliveSettings::setDefault_profile(profile.path);
m_profile = profile;
pCore->setCurrentProfile(profile.path);
updateProjectProfile(true);
emit docModified(true);
pCore->producerQueue()->getFileProperties(xml, id, 150, true);
return;
break;
case KMessageBox::No:
KdenliveSettings::setDefault_profile(m_profile.path);
return;
break;
default:
......@@ -1500,12 +1469,14 @@ void KdenliveDoc::switchProfile(MltVideoProfile profile, const QString &id, cons
i18n("No profile found for your clip.\nCreate and switch to new profile (%1x%2, %3fps)?%4", profile.width,
profile.height, QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2),
adjustMessage)) == KMessageBox::Continue) {
m_profile = profile;
m_profile.description = QStringLiteral("%1x%2 %3fps")
profile.description = QStringLiteral("%1x%2 %3fps")
.arg(profile.width)
.arg(profile.height)
.arg(QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2));
ProfilesDialog::saveProfile(m_profile);
ProfilesDialog::saveProfile(profile);
// reload profiles from disk
ProfileRepository::get()->refresh();
pCore->setCurrentProfile(profile.path);
updateProjectProfile(true);
emit docModified(true);
pCore->producerQueue()->getFileProperties(xml, id, 150, true);
......
......@@ -89,7 +89,6 @@ public:
/** @brief Get a list of all clip ids that are inside a folder. */
QStringList getBinFolderClipIds(const QString &folderId) const;
const QString &profilePath() const;
/** @brief Returns current project profile. */
MltVideoProfile mltProfile() const;
ProfileInfo getProfileInfo() const;
......@@ -186,12 +185,9 @@ private:
QTimer m_modifiedTimer;
/** List of the clip IDs that need to be reloaded after being externally modified */
QMap<QString, QTime> m_modifiedClips;
int m_width;
int m_height;
Timecode m_timecode;
std::shared_ptr<DocUndoStack> m_commandStack;
ClipManager *m_clipManager;
MltVideoProfile m_profile;
QString m_searchFolder;
/** @brief Tells whether the current document has been changed after being saved. */
......
......@@ -675,10 +675,6 @@
<label>Currently displayed page in properties panel</label>
<default>0</default>
</entry>
<entry name="project_display_ratio" type="Double">
<label>Current project display ratio.</label>
<default>1.7777778</default>
</entry>
<entry name="project_fps" type="Double">
<label>Current project fps.</label>
<default>25</default>
......
......@@ -21,6 +21,7 @@
#include "assets/assetpanel.hpp"
#include "bin/generators/generators.h"
#include "bin/projectclip.h"
#include "profiles/profilemodel.hpp"
#include "core.h"
#include "dialogs/clipcreationdialog.h"
#include "dialogs/kdenlivesettingsdialog.h"
......@@ -206,13 +207,13 @@ void MainWindow::init()
new RenderingAdaptor(this);
QString defaultProfile = KdenliveSettings::default_profile();
KdenliveSettings::setCurrent_profile(defaultProfile.isEmpty() ? ProjectManager::getDefaultProjectFormat() : defaultProfile);
pCore->setCurrentProfile(defaultProfile.isEmpty() ? ProjectManager::getDefaultProjectFormat() : defaultProfile);
m_commandStack = new QUndoGroup();
// If using a custom profile, make sure the file exists or fallback to default
if (KdenliveSettings::current_profile().startsWith(QLatin1Char('/')) && !QFile::exists(KdenliveSettings::current_profile())) {
KMessageBox::sorry(this, i18n("Cannot find your default profile, switching to ATSC 1080p 25"));
KdenliveSettings::setCurrent_profile(QStringLiteral("atsc_1080p_25"));
pCore->setCurrentProfile(QStringLiteral("atsc_1080p_25"));
KdenliveSettings::setDefault_profile(QStringLiteral("atsc_1080p_25"));
}
......@@ -1710,8 +1711,8 @@ void MainWindow::slotEditProjectSettings()
if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) {
slotSwitchAudioThumbs();
}
if (project->profilePath() != profile || project->profileChanged(profile)) {
KdenliveSettings::setCurrent_profile(profile);
if (pCore->getCurrentProfile()->path() != profile || project->profileChanged(profile)) {
pCore->setCurrentProfile(profile);
pCore->projectManager()->slotResetProfiles();
slotUpdateDocumentState(true);
}
......@@ -1816,16 +1817,13 @@ void MainWindow::slotRenderProject()
if (!m_renderWidget) {
QString projectfolder = project ? project->projectDataFolder() + QDir::separator() : KdenliveSettings::defaultprojectfolder();
MltVideoProfile profile;
if (project) {
profile = project->mltProfile();
m_renderWidget = new RenderWidget(projectfolder, project->useProxy(), profile.path, this);
m_renderWidget = new RenderWidget(projectfolder, project->useProxy(), this);
connect(m_renderWidget, &RenderWidget::shutdown, this, &MainWindow::slotShutdown);
connect(m_renderWidget, &RenderWidget::selectedRenderProfile, this, &MainWindow::slotSetDocumentRenderProfile);
connect(m_renderWidget, &RenderWidget::prepareRenderingData, this, &MainWindow::slotPrepareRendering);
connect(m_renderWidget, &RenderWidget::abortProcess, this, &MainWindow::abortRenderJob);
connect(m_renderWidget, &RenderWidget::openDvdWizard, this, &MainWindow::slotDvdWizard);
m_renderWidget->setProfile(project->mltProfile().path);
m_renderWidget->setGuides(pCore->projectManager()->currentTimeline()->projectView()->guidesData(), project->projectDuration());
m_renderWidget->setDocumentPath(project->projectDataFolder() + QDir::separator());
m_renderWidget->setRenderProfile(project->getRenderProperties());
......@@ -2057,14 +2055,13 @@ void MainWindow::connectDocument()
if (m_renderWidget) {
slotCheckRenderStatus();
m_renderWidget->setProfile(project->mltProfile().path);
m_renderWidget->adjustViewToProfile();
// m_renderWidget->setGuides(pCore->projectManager()->currentTimeline()->projectView()->guidesData(), project->projectDuration());
m_renderWidget->setDocumentPath(project->projectDataFolder() + QDir::separator());
m_renderWidget->setRenderProfile(project->getRenderProperties());
}
m_zoomSlider->setValue(project->zoom().x());
m_commandStack->setActiveStack(project->commandStack().get());
KdenliveSettings::setProject_display_ratio(project->dar());
setWindowTitle(project->description());
setWindowModified(project->isModified());
......
......@@ -77,7 +77,7 @@ ClipController::ClipController(std::shared_ptr<BinController> bincontroller, std
ClipController::ClipController(std::shared_ptr<BinController> bincontroller)
: selectedEffectIndex(1)
, m_audioThumbCreated(false)
, m_masterProducer(ClipController::mediaUnavailable)
, m_masterProducer(nullptr) //ClipController::mediaUnavailable)
, m_properties(nullptr)
, m_usesProxy(false)
, m_audioInfo(nullptr)
......@@ -88,6 +88,7 @@ ClipController::ClipController(std::shared_ptr<BinController> bincontroller)
, m_binController(bincontroller)
, m_snapMarkers(QList<CommentedTime>())
{
m_producerLock.lock();
}
// static
......@@ -123,8 +124,11 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
m_properties = new Mlt::Properties(producer->get_properties());
m_masterProducer = producer;
if (!m_masterProducer->is_valid()) {
m_masterProducer = ClipController::mediaUnavailable;
m_producerLock.unlock();
qCDebug(KDENLIVE_LOG) << "// WARNING, USING INVALID PRODUCER";
} else {
m_producerLock.unlock();
QString proxy = m_properties->get("kdenlive:proxy");
m_service = m_properties->get("mlt_service");
QString path = m_properties->get("resource");
......@@ -219,6 +223,7 @@ bool ClipController::hasLimitedDuration() const
std::shared_ptr<Mlt::Producer> ClipController::originalProducer()
{
QMutexLocker lock(&m_producerLock);
return m_masterProducer;
}
......
......@@ -244,6 +244,9 @@ protected:
// void rebuildEffectList(ProfileInfo info);
std::shared_ptr<EffectStackModel> m_effectStack;
std::shared_ptr<MarkerListModel> m_markerModel;
private:
QMutex m_producerLock;
};
#endif
......@@ -34,6 +34,7 @@
#include "mltcontroller/bincontroller.h"
#include "qml/qmlaudiothumb.h"
#include "timeline2/view/qml/timelineitems.h"
#include "profiles/profilemodel.hpp"
#include <mlt++/Mlt.h>
#ifndef GL_UNPACK_ROW_LENGTH
......@@ -984,7 +985,7 @@ int GLWidget::reconfigureMulti(const QString &params, const QString &path, Mlt::
if (m_consumer->is_valid()) {
// buid sub consumers
// m_consumer->set("mlt_image_format", "yuv422");
reloadProfile(*profile);
reloadProfile();
int volume = KdenliveSettings::volume();
m_consumer->set("0", serviceName.toUtf8().constData());
m_consumer->set("0.mlt_image_format", "yuv422");
......@@ -1050,7 +1051,7 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
// use SDL for audio, OpenGL for video
QString serviceName = property("mlt_service").toString();
if (profile) {
reloadProfile(*profile);
reloadProfile();
m_blackClip.reset(new Mlt::Producer(*profile, "color:black"));
m_blackClip->set("kdenlive:id", "black");
}
......@@ -1193,16 +1194,17 @@ void GLWidget::resetProfile(const MltVideoProfile &profile)
refreshSceneLayout();
}
void GLWidget::reloadProfile(Mlt::Profile &profile)
void GLWidget::reloadProfile()
{
m_monitorProfile->get_profile()->description = strdup(profile.description());
m_monitorProfile->set_colorspace(profile.colorspace());
m_monitorProfile->set_frame_rate(profile.frame_rate_num(), profile.frame_rate_den());
m_monitorProfile->set_height(profile.height());
m_monitorProfile->set_width(profile.width());
m_monitorProfile->set_progressive(static_cast<int>(profile.progressive()));
m_monitorProfile->set_sample_aspect(profile.sample_aspect_num(), profile.sample_aspect_den());
m_monitorProfile->set_display_aspect(profile.display_aspect_num(), profile.display_aspect_den());
auto &profile = pCore->getCurrentProfile();
m_monitorProfile->get_profile()->description = qstrdup(profile->description().toUtf8().constData());
m_monitorProfile->set_colorspace(profile->colorspace());
m_monitorProfile->set_frame_rate(profile->frame_rate_num(), profile->frame_rate_den());
m_monitorProfile->set_height(profile->height());
m_monitorProfile->set_width(profile->width());
m_monitorProfile->set_progressive(static_cast<int>(profile->progressive()));
m_monitorProfile->set_sample_aspect(profile->sample_aspect_num(), profile->sample_aspect_den());
m_monitorProfile->set_display_aspect(profile->display_aspect_num(), profile->display_aspect_den());
m_monitorProfile->set_explicit(1);
// The profile display aspect ratio may have changed.
resizeGL(width(), height());
......
......@@ -95,7 +95,7 @@ public:
void updateGamma();
Mlt::Profile *profile();
void resetProfile(const MltVideoProfile &profile);
void reloadProfile(Mlt::Profile &profile);
void reloadProfile();
void lockMonitor();
void releaseMonitor();
int realTime() const;
......
......@@ -1415,18 +1415,18 @@ void Monitor::setCustomProfile(const QString &profile, const Timecode &tc)
if (m_multitrackView) {
m_multitrackView->setChecked(false);
}
m_glMonitor->resetProfile(ProfilesDialog::getVideoProfile(profile));
pCore->setCurrentProfile(profile);
m_glMonitor->reloadProfile();
}
void Monitor::resetProfile(const MltVideoProfile &profile)
void Monitor::resetProfile()
{
m_timePos->updateTimeCode(m_monitorManager->timecode());
if (render == nullptr) {
return;
}
render->prepareProfileReset(m_monitorManager->timecode().fps());
m_glMonitor->resetProfile(profile);
render->finishProfileReset();
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();
// Update dro pframe info
......
......@@ -89,7 +89,7 @@ public:
~Monitor();
Render *render;
AbstractRender *abstractRender() override;
void resetProfile(const MltVideoProfile &profile);
void resetProfile();
void setCustomProfile(const QString &profile, const Timecode &tc);
void setupMenu(QMenu *goMenu, QMenu *overlayMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = nullptr, QAction *loopClip = nullptr);
const QString sceneList(const QString &root);
......
......@@ -311,11 +311,11 @@ void MonitorManager::slotEnd()
}
}
void MonitorManager::resetProfiles(const MltVideoProfile &profile, const Timecode &tc)
void MonitorManager::resetProfiles(const Timecode &tc)
{
m_timecode = tc;
m_clipMonitor->resetProfile(profile);
m_projectMonitor->resetProfile(profile);
m_clipMonitor->resetProfile();
m_projectMonitor->resetProfile();
}
void MonitorManager::slotUpdateAudioMonitoring()
......
......@@ -43,7 +43,7 @@ public:
void appendMonitor(AbstractMonitor *monitor);
void removeMonitor(AbstractMonitor *monitor);
Timecode timecode() const;
void resetProfiles(const MltVideoProfile &profile, const Timecode &tc);
void resetProfiles(const Timecode &tc);
void stopActiveMonitor();
void pauseActiveMonitor();
AbstractRender *activeRenderer();
......
......@@ -746,7 +746,7 @@ void ProjectManager::prepareSave()
void ProjectManager::slotResetProfiles()
{
m_project->resetProfile();
pCore->monitorManager()->resetProfiles(m_project->mltProfile(), m_project->timecode());
pCore->monitorManager()->resetProfiles(m_project->timecode());
pCore->monitorManager()->updateScopeSource();
}
......
......@@ -316,7 +316,7 @@ void CustomTrackView::checkAutoScroll()
int CustomTrackView::getFrameWidth() const
{
return (int)(m_tracksHeight * m_document->dar() + 0.5);
return (int)(m_tracksHeight * pCore->getCurrentDar() + 0.5);
}
void CustomTrackView::updateSceneFrameWidth(double fpsChanged)
......
......@@ -69,21 +69,29 @@ int ClipModel::construct(const std::weak_ptr<TimelineModel> &parent, const QStri
qDebug() << "Error : construction of clip failed because parent timeline is not available anymore";
Q_ASSERT(false);
}
auto binClip = pCore->bin()->getBinClip(binClipId);
if (!binClip) {
qDebug() << "Error : Bin clip for id: " << binClipId << " NOT AVAILABLE!!!";
}
binClip->registerTimelineClip(parent, id);
return id;
}
ClipModel::~ClipModel()
void ClipModel::registerClipToBin()
{
auto binClip = pCore->bin()->getBinClip(m_binClipId);
if (!binClip) {
qDebug() << "Error : Bin clip for id: " << m_binClipId << " NOT AVAILABLE!!!";
}
binClip->registerTimelineClip(m_parent, m_id);
}
void ClipModel::deregisterClipToBin()
{
std::shared_ptr<ProjectClip> binClip = pCore->bin()->getBinClip(m_binClipId);
binClip->deregisterTimelineClip(m_id);
}
ClipModel::~ClipModel()
{
}
bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo)
{
QWriteLocker locker(&m_lock);
......
......@@ -82,6 +82,9 @@ public:
/** @brief Returns the bin clip's id */
const QString &binId() const;
void registerClipToBin();
void deregisterClipToBin();
bool addEffect(const QString &effectId);
bool copyEffect(std::shared_ptr<EffectStackModel> stackModel, int rowId);
......
......@@ -954,8 +954,10 @@ void TimelineModel::registerTrack(std::shared_ptr<TrackModel> track, int pos, bo
void TimelineModel::registerClip(const std::shared_ptr<