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

Fix guides in render widget

Fixes #207
parent 61323532
Pipeline #3905 passed with stage
in 25 minutes and 29 seconds
......@@ -465,29 +465,49 @@ void RenderWidget::slotCheckEndGuidePosition()
}
}
void RenderWidget::setGuides(const QList<CommentedTime> &guidesList, double duration)
void RenderWidget::setGuides(std::weak_ptr<MarkerListModel> guidesModel)
{
m_guidesModel = std::move(guidesModel);
reloadGuides();
if (auto ptr = m_guidesModel.lock()) {
connect(ptr.get(), &MarkerListModel::modelChanged, this, &RenderWidget::reloadGuides);
}
}
void RenderWidget::reloadGuides()
{
double projectDuration = GenTime(pCore->projectDuration() - TimelineModel::seekDuration - 2, pCore->getCurrentFps()).ms() / 1000;
QVariant startData = m_view.guide_start->currentData();
QVariant endData = m_view.guide_end->currentData();
m_view.guide_start->clear();
m_view.guide_end->clear();
if (!guidesList.isEmpty()) {
m_view.guide_start->addItem(i18n("Beginning"), "0");
m_view.render_guide->setEnabled(true);
m_view.create_chapter->setEnabled(true);
if (auto ptr = m_guidesModel.lock()) {
QList<CommentedTime> markers = ptr->getAllMarkers();
double fps = pCore->getCurrentProfile()->fps();
m_view.render_guide->setEnabled(!markers.isEmpty());
if (!markers.isEmpty()) {
m_view.guide_start->addItem(i18n("Beginning"), "0");
m_view.create_chapter->setEnabled(true);
for (auto marker : markers) {
GenTime pos = marker.time();
const QString guidePos = Timecode::getStringTimecode(pos.frames(fps), fps);
m_view.guide_start->addItem(marker.comment() + QLatin1Char('/') + guidePos, pos.seconds());
m_view.guide_end->addItem(marker.comment() + QLatin1Char('/') + guidePos, pos.seconds());
}
m_view.guide_end->addItem(i18n("End"), QString::number(projectDuration));
if (!startData.isNull()) {
int ix = qMax(0, m_view.guide_start->findData(startData));
m_view.guide_start->setCurrentIndex(ix);
}
if (!endData.isNull()) {
int ix = qMax(m_view.guide_start->currentIndex() + 1, m_view.guide_end->findData(endData));
m_view.guide_end->setCurrentIndex(ix);
}
}
} else {
m_view.render_guide->setEnabled(false);
m_view.create_chapter->setEnabled(false);
}
double fps = pCore->getCurrentProfile()->fps();
for (int i = 0; i < guidesList.count(); i++) {
const CommentedTime &c = guidesList.at(i);
GenTime pos = c.time();
const QString guidePos = Timecode::getStringTimecode(pos.frames(fps), fps);
m_view.guide_start->addItem(c.comment() + QLatin1Char('/') + guidePos, pos.seconds());
m_view.guide_end->addItem(c.comment() + QLatin1Char('/') + guidePos, pos.seconds());
}
if (!guidesList.isEmpty()) {
m_view.guide_end->addItem(i18n("End"), QString::number(duration));
}
}
/**
......
......@@ -33,6 +33,7 @@ class Menu;
#endif
#include "definitions.h"
#include "bin/model/markerlistmodel.hpp"
#include "ui_renderwidget_ui.h"
class QDomElement;
......@@ -120,7 +121,7 @@ class RenderWidget : public QDialog
public:
explicit RenderWidget(bool enableProxy, QWidget *parent = nullptr);
~RenderWidget() override;
void setGuides(const QList<CommentedTime> &guidesList, double duration);
void setGuides(std::weak_ptr<MarkerListModel> guidesModel);
void focusFirstVisibleItem(const QString &profile = QString());
void setRenderJob(const QString &dest, int progress = 0);
void setRenderStatus(const QString &dest, int status, const QString &error);
......@@ -155,6 +156,7 @@ public slots:
void slotAbortCurrentJob();
void slotPrepareExport(bool scriptExport = false, const QString &scriptPath = QString());
void adjustViewToProfile();
void reloadGuides();
private slots:
void slotUpdateButtons(const QUrl &url);
......@@ -212,6 +214,7 @@ private:
KMessageWidget *m_infoMessage;
KMessageWidget *m_jobInfoMessage;
QMap<int, QString> m_errorMessages;
std::weak_ptr<MarkerListModel> m_guidesModel;
#ifdef KF5_USE_PURPOSE
Purpose::Menu *m_shareMenu;
......
......@@ -1771,8 +1771,7 @@ void MainWindow::slotRenderProject()
connect(m_renderWidget, &RenderWidget::abortProcess, this, &MainWindow::abortRenderJob);
connect(m_renderWidget, &RenderWidget::openDvdWizard, this, &MainWindow::slotDvdWizard);
connect(this, &MainWindow::updateRenderWidgetProfile, m_renderWidget, &RenderWidget::adjustViewToProfile);
double projectDuration = GenTime(getMainTimeline()->controller()->duration(), pCore->getCurrentFps()).ms() / 1000;
m_renderWidget->setGuides(project->getGuideModel()->getAllMarkers(), projectDuration);
m_renderWidget->setGuides(project->getGuideModel());
m_renderWidget->updateDocumentPath();
m_renderWidget->setRenderProfile(project->getRenderProperties());
}
......@@ -2000,7 +1999,7 @@ void MainWindow::connectDocument()
if (m_renderWidget) {
slotCheckRenderStatus();
// m_renderWidget->setGuides(pCore->projectManager()->currentTimeline()->projectView()->guidesData(), project->projectDuration());
m_renderWidget->setGuides(pCore->currentDoc()->getGuideModel());
m_renderWidget->updateDocumentPath();
m_renderWidget->setRenderProfile(project->getRenderProperties());
}
......@@ -2044,8 +2043,7 @@ void MainWindow::slotZoneMoved(int start, int end)
void MainWindow::slotGuidesUpdated()
{
if (m_renderWidget) {
double projectDuration = GenTime(getMainTimeline()->controller()->duration() - TimelineModel::seekDuration - 2, pCore->getCurrentFps()).ms() / 1000;
m_renderWidget->setGuides(pCore->currentDoc()->getGuideModel()->getAllMarkers(), projectDuration);
m_renderWidget->setGuides(pCore->currentDoc()->getGuideModel());
}
}
......
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