Commit 2a81464e authored by Julius Künzel's avatar Julius Künzel
Browse files

Add option to select clip monitor background color

This is usefull for clips with transparency like title clips, png
images, etc.

Change the color from the clip monitor's hamburger menu (entry
"Background Color")

Fixes #1195
parent 85dfe0a0
Pipeline #82194 canceled with stage
......@@ -452,6 +452,11 @@
<default>#535353</default>
</entry>
<entry name="monitor_background" type="String">
<label>Background color for clip monitor (only visible with transparent clips).</label>
<default>black</default>
</entry>
<entry name="volume" type="Int">
<label>Volume used for SDL output.</label>
<default>100</default>
......
......@@ -384,6 +384,22 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
menu->addAction(widgetslider);
m_configMenu->addMenu(menu);
if (m_id == Kdenlive::ClipMonitor) {
m_background = new KSelectAction(QIcon::fromTheme(QStringLiteral("paper-color")), i18n("Background Color"), this);
QAction *blackAction = m_background->addAction(QIcon(), i18n("Black"));
blackAction->setData("black");
QAction *whiteAction = m_background->addAction(QIcon(), i18n("White"));
whiteAction->setData("white");
QAction *pinkAction = m_background->addAction(QIcon(), i18n("Pink"));
pinkAction->setData("#ff00ff");
m_configMenu->addAction(m_background);
m_background->setCurrentAction(blackAction);
connect(m_background, static_cast<void (KSelectAction::*)(QAction *)>(&KSelectAction::triggered), this, [this](QAction *a){
KdenliveSettings::setMonitor_background(a->data().toString());
buildBackgroundedProducer(position());
});
}
/*QIcon icon;
if (KdenliveSettings::volume() == 0) {
icon = QIcon::fromTheme(QStringLiteral("audio-volume-muted"));
......@@ -708,6 +724,27 @@ void Monitor::slotForceSize(QAction *a)
updateGeometry();
}
void Monitor::buildBackgroundedProducer(int pos) {
if (KdenliveSettings::monitor_background() != "black") {
Mlt::Tractor trac(pCore->getCurrentProfile()->profile());
QString color = QString("color:%1").arg(KdenliveSettings::monitor_background());
std::shared_ptr<Mlt::Producer> bg(new Mlt::Producer(*trac.profile(), color.toUtf8().constData()));
bg->set("length", m_controller->originalProducer()->get_length());
trac.set_track(*bg.get(), 0);
trac.set_track(*m_controller->originalProducer().get(), 1);
QString composite = TransitionsRepository::get()->getCompositingTransition();
std::unique_ptr<Mlt::Transition> transition = TransitionsRepository::get()->getTransition(composite);
transition->set("internal_added", 237);
transition->set("always_active", 1);
transition->set_tracks(0, 1);
trac.plant_transition(*transition.get(), 0, 1);
m_glMonitor->setProducer(std::make_shared<Mlt::Producer>(trac), isActive(), pos);
qDebug() << "set hacked background monitor";
} else {
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), pos);
}
}
void Monitor::updateMarkers()
{
......@@ -1688,7 +1725,7 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
if (m_glWidget->isFullScreen() || !m_glWidget->visibleRegion().isEmpty()) {
slotActivateMonitor();
}
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), in);
buildBackgroundedProducer(in);
} else {
qDebug()<<"*************** CONTROLLER NOT READY";
}
......
......@@ -189,6 +189,7 @@ private:
TimecodeDisplay *m_timePos;
KDualAction *m_playAction;
KSelectAction *m_forceSize;
KSelectAction *m_background;
/** Has to be available so we can enable and disable it. */
QAction *m_loopClipAction;
QAction *m_zoomVisibilityAction;
......@@ -239,6 +240,7 @@ private slots:
void slotAdjustEffectCompare();
void slotShowMenu(const QPoint pos);
void slotForceSize(QAction *a);
void buildBackgroundedProducer(int pos);
void slotSeekToKeyFrame();
/** @brief Display a non blocking error message to user **/
void warningMessage(const QString &text, int timeout = 5000, const QList<QAction *> &actions = QList<QAction *>());
......
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