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

Track compositing is now a simple checkbox instead of the deprecated none/high res choice

parent 945199a1
Pipeline #194884 passed with stage
in 9 minutes and 32 seconds
......@@ -321,5 +321,5 @@ signals:
/** @brief If a command is pushed when we are in the middle of undo stack, invalidate further undo history */
void removeInvalidUndo(int ix);
/** @brief Update compositing info */
void updateCompositionMode(int);
void updateCompositionMode(bool);
};
......@@ -1092,22 +1092,9 @@ void MainWindow::setupActions()
connect(m_useTimelineZone, &KDualAction::activeChangedByUser, this, &MainWindow::slotSwitchTimelineZone);
addAction(QStringLiteral("use_timeline_zone_in_edit"), m_useTimelineZone);
m_compositeAction = new KSelectAction(QIcon::fromTheme(QStringLiteral("composite-track-off")), i18n("Track Compositing"), this);
m_compositeAction->setToolTip(i18n("Track compositing"));
QAction *noComposite = new QAction(QIcon::fromTheme(QStringLiteral("composite-track-off")), i18n("None"), this);
noComposite->setCheckable(true);
noComposite->setData(0);
m_compositeAction->addAction(noComposite);
QString compose = TransitionsRepository::get()->getCompositingTransition();
if (compose == QStringLiteral("movit.overlay") || compose != QStringLiteral("composite")) {
// Movit, do not show "preview" option since movit is faster
QAction *hqComposite = new QAction(QIcon::fromTheme(QStringLiteral("composite-track-on")), i18n("High Quality"), this);
hqComposite->setCheckable(true);
hqComposite->setData(2);
m_compositeAction->addAction(hqComposite);
m_compositeAction->setCurrentAction(hqComposite);
}
connect(m_compositeAction, static_cast<void (KSelectAction::*)(QAction *)>(&KSelectAction::triggered), this, &MainWindow::slotUpdateCompositing);
m_compositeAction = new QAction(i18n("Enable Track Compositing"), this);
m_compositeAction->setCheckable(true);
connect(m_compositeAction, &QAction::triggered, this, &MainWindow::slotUpdateCompositing);
addAction(QStringLiteral("timeline_compositing"), m_compositeAction);
actionCollection()->setShortcutsConfigurable(m_compositeAction, false);
......@@ -2166,9 +2153,6 @@ void MainWindow::slotRenderProject()
m_renderWidget->updateDocumentPath();
m_renderWidget->setRenderProfile(project->getRenderProperties());
}
if (m_renderWidget && m_compositeAction && m_compositeAction->currentAction()) {
m_renderWidget->errorMessage(RenderWidget::CompositeError, QString());
}
slotCheckRenderStatus();
if (m_renderWidget) {
......@@ -4085,28 +4069,15 @@ void MainWindow::slotManageCache()
d->exec();
}
void MainWindow::slotUpdateCompositing(QAction *compose)
void MainWindow::slotUpdateCompositing(bool checked)
{
int mode = compose->data().toInt();
getMainTimeline()->controller()->switchCompositing(mode);
if (m_renderWidget) {
m_renderWidget->errorMessage(RenderWidget::CompositeError, mode == 1 ? i18n("Rendering using low quality track compositing") : QString());
}
getMainTimeline()->controller()->switchCompositing(checked);
pCore->currentDoc()->setModified();
}
void MainWindow::slotUpdateCompositeAction(int mode)
void MainWindow::slotUpdateCompositeAction(bool enable)
{
QList<QAction *> actions = m_compositeAction->actions();
for (int i = 0; i < actions.count(); i++) {
if (actions.at(i)->data().toInt() == mode) {
m_compositeAction->setCurrentAction(actions.at(i));
break;
}
}
if (m_renderWidget) {
m_renderWidget->errorMessage(RenderWidget::CompositeError, mode == 1 ? i18n("Rendering using low quality track compositing") : QString());
}
m_compositeAction->setChecked(enable);
}
void MainWindow::showMenuBar(bool show)
......
......@@ -220,7 +220,7 @@ private:
QDockWidget *m_onlineResourcesDock;
KSelectAction *m_timeFormatButton;
KSelectAction *m_compositeAction;
QAction *m_compositeAction;
TimelineTabs *m_timelineTabs{nullptr};
QVector <Bin*>m_binWidgets;
......@@ -343,7 +343,7 @@ public slots:
/** @brief The path of the current document changed (save as), update render settings */
void updateProjectPath(const QString &path);
/** @brief Update compositing action to display current project setting. */
void slotUpdateCompositeAction(int mode);
void slotUpdateCompositeAction(bool enable);
/** @brief Update duration of projet in timeline toolbar. */
void slotUpdateProjectDuration(int pos);
......@@ -534,7 +534,7 @@ private slots:
/** @brief Change forced icon theme setting (asks for app restart). */
void forceIconSet(bool force);
/** @brief Toggle current project's compositing mode. */
void slotUpdateCompositing(QAction *compose);
void slotUpdateCompositing(bool checked);
/** @brief Set timeline toolbar icon size. */
void setTimelineToolbarIconSize(QAction *a);
void slotEditItemSpeed();
......
......@@ -1056,15 +1056,9 @@ bool ProjectManager::updateTimeline(int pos, const QString &chunks, const QStrin
xmlProd.reset(nullptr);
const QString groupsData = m_project->getDocumentProperty(QStringLiteral("groups"));
// update track compositing
int compositing = pCore->currentDoc()->getDocumentProperty(QStringLiteral("compositing"), QStringLiteral("2")).toInt();
if (compositing == 1) {
// Composite transition is deprecated, switch to hq by default
compositing = 2;
}
bool compositing = pCore->currentDoc()->getDocumentProperty(QStringLiteral("compositing"), QStringLiteral("1")).toInt() > 0;
emit pCore->currentDoc()->updateCompositionMode(compositing);
if (compositing < 2) {
pCore->window()->getMainTimeline()->controller()->switchCompositing(compositing);
}
pCore->window()->getMainTimeline()->controller()->switchCompositing(compositing);
if (!groupsData.isEmpty()) {
m_mainTimelineModel->loadGroups(groupsData);
}
......
......@@ -2748,10 +2748,10 @@ void TimelineController::changeItemSpeed(int clipId, double speed)
}
}
void TimelineController::switchCompositing(int mode)
void TimelineController::switchCompositing(bool enable)
{
// m_model->m_tractor->lock();
pCore->currentDoc()->setDocumentProperty(QStringLiteral("compositing"), QString::number(mode));
pCore->currentDoc()->setDocumentProperty(QStringLiteral("compositing"), QString::number(enable));
QScopedPointer<Mlt::Service> service(m_model->m_tractor->field());
QScopedPointer<Mlt::Field> field(m_model->m_tractor->field());
field->lock();
......@@ -2769,13 +2769,12 @@ void TimelineController::switchCompositing(int mode)
service.reset(service->producer());
}
}
if (mode > 0) {
if (enable) {
// Loop through tracks
for (int track = 0; track < m_model->getTracksCount(); track++) {
if (m_model->getTrackById(m_model->getTrackIndexFromPosition(track))->getProperty("kdenlive:audio_track").toInt() == 0) {
// This is a video track
Mlt::Transition t(*m_model->m_tractor->profile(),
mode == 1 ? "composite" : TransitionsRepository::get()->getCompositingTransition().toUtf8().constData());
Mlt::Transition t(*m_model->m_tractor->profile(), TransitionsRepository::get()->getCompositingTransition().toUtf8().constData());
t.set("always_active", 1);
t.set_tracks(0, track + 1);
t.set("internal_added", 237);
......
......@@ -573,7 +573,7 @@ public:
QMap<QString, QString> documentProperties();
/** @brief Change track compsiting mode */
void switchCompositing(int mode);
void switchCompositing(bool enable);
/** @brief Change a clip item's speed in timeline */
Q_INVOKABLE void changeItemSpeed(int clipId, double speed);
......
Supports Markdown
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