#include <KUrlRequester>
#include <KColorScheme>
#include <KColorUtils>
+#include <KApplication>
class Boolval: public QWidget, public Ui::Boolval_UI
{
m_paramWidget(NULL),
m_effect(effect),
m_original_effect(original_effect),
- m_lastEffect(lastEffect)
+ m_lastEffect(lastEffect),
+ m_regionEffect(false)
{
- setupUi(this);
+ if (m_effect.attribute("tag") == "region") {
+ m_regionEffect = true;
+ decoframe->setObjectName("decoframegroup");
+ }
filterWheelEvent = true;
m_info.fromString(effect.attribute("kdenlive_info"));
setFont(KGlobalSettings::smallestReadableFont());
//buttonShowComments->setIcon(KIcon("help-about"));
//buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
m_menu = new QMenu;
+ if (m_regionEffect) m_menu->addAction(KIcon("document-new"), i18n("Change Region"), this, SLOT(slotResetEffect()));
m_menu->addAction(KIcon("view-refresh"), i18n("Reset Effect"), this, SLOT(slotResetEffect()));
m_menu->addAction(KIcon("document-save"), i18n("Save Effect"), this, SLOT(slotSaveEffect()));
QDomElement namenode = m_effect.firstChildElement("name");
if (namenode.isNull()) return;
- title->setText(i18n(namenode.text().toUtf8().data()));
+ QString effectname = i18n(namenode.text().toUtf8().data());
+ if (m_regionEffect) effectname.append(":" + KUrl(EffectsList::parameter(m_effect, "resource")).fileName());
+
+ QHBoxLayout *l = static_cast <QHBoxLayout *>(frame->layout());
+ title = new QLabel(this);
+ l->insertWidget(2, title);
+
+ title->setText(effectname);
/*
* Do not show icon, makes too much visual noise
QString type = m_effect.attribute("type", QString());
else icon = KIcon("kdenlive-show-video");
effecticon->setPixmap(icon.pixmap(16,16));*/
- m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
+ if (!m_regionEffect) {
+ m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
+ m_menu->addAction(KIcon("folder-new"), i18n("Create Region"), this, SLOT(slotCreateRegion()));
+ }
setupWidget(info, metaInfo);
setAcceptDrops(true);
menuButton->setIcon(KIcon("kdenlive-menu"));
QString stylesheet;
- // group editable labels
- stylesheet.append(QString("MyEditableLabel { background-color: transparent;color: palette(bright-text);} "));
-
// effect background
stylesheet.append(QString("QFrame#decoframe {border-top-left-radius:5px;border-top-right-radius:5px;border-bottom:2px solid palette(mid);border-top:1px solid palette(light);} QFrame#decoframe[active=\"true\"] {background: %1;}").arg(hgh.name()));
-
+
// effect in group background
stylesheet.append(QString("QFrame#decoframesub {border-top:1px solid palette(light);} QFrame#decoframesub[active=\"true\"] {background: %1;}").arg(hgh.name()));
// spin box for draggable widget
stylesheet.append(QString("QAbstractSpinBox#dragBox {border: 1px solid palette(dark);border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox:disabled#dragBox {border: 1px solid palette(button);} QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %1;} QAbstractSpinBox:hover#dragBox {border: 1px solid %2;} ").arg(hover_bg.name()).arg(selected_bg.name()));
-
+
+ // group editable labels
+ stylesheet.append(QString("MyEditableLabel { background-color: transparent; color: palette(bright-text); border-radius: 2px;border: 1px solid transparent;} MyEditableLabel:hover {border: 1px solid palette(highlight);} "));
+
return stylesheet;
}
emit createGroup(effectIndex());
}
+void CollapsibleEffect::slotCreateRegion()
+{
+ QString allExtensions = ProjectList::getExtensions();
+ const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
+ KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow());
+ d->setOperationMode(KFileDialog::Opening);
+ d->setMode(KFile::File);
+ if (d->exec() == QDialog::Accepted) {
+ KUrl url = d->selectedUrl();
+ if (!url.isEmpty()) emit createRegion(effectIndex(), url);
+ }
+ delete d;
+}
+
void CollapsibleEffect::slotUnGroup()
{
emit unGroup(this);
QWidget::mouseReleaseEvent(event);
}
-void CollapsibleEffect::slotEnable(bool disable)
+void CollapsibleEffect::slotEnable(bool disable, bool updateMainStatus)
{
title->setEnabled(!disable);
enabledButton->blockSignals(true);
if (!disable || KdenliveSettings::disable_effect_parameters()) {
widgetFrame->setEnabled(!disable);
}
- emit effectStateChanged(disable, effectIndex());
+ emit effectStateChanged(disable, effectIndex(), updateMainStatus);
}
void CollapsibleEffect::slotDeleteEffect()
void CollapsibleEffect::slotEffectUp()
{
- emit changeEffectPosition(effectIndex(), true);
+ emit changeEffectPosition(QList <int>() <<effectIndex(), true);
}
void CollapsibleEffect::slotEffectDown()
{
- emit changeEffectPosition(effectIndex(), false);
+ emit changeEffectPosition(QList <int>() <<effectIndex(), false);
}
void CollapsibleEffect::slotSaveEffect()
collapseButton->setArrowType(Qt::RightArrow);
m_info.isCollapsed = true;
}
- m_effect.setAttribute("kdenlive_info", m_info.toString());
- emit parameterChanged(m_original_effect, m_effect, effectIndex());
+ updateCollapsedState();
+}
+
+void CollapsibleEffect::groupStateChanged(bool collapsed)
+{
+ m_info.groupIsCollapsed = collapsed;
+ updateCollapsedState();
+}
+
+void CollapsibleEffect::updateCollapsedState()
+{
+ QString info = m_info.toString();
+ if (info != m_effect.attribute("kdenlive_info")) {
+ m_effect.setAttribute("kdenlive_info", info);
+ emit parameterChanged(m_original_effect, m_effect, effectIndex());
+ }
}
void CollapsibleEffect::setGroupIndex(int ix)
{
m_info.groupIndex = ix;
+ m_effect.setAttribute("kdenlive_info", m_info.toString());
}
void CollapsibleEffect::setGroupName(const QString &groupName)
{
m_info.groupName = groupName;
+ m_effect.setAttribute("kdenlive_info", m_info.toString());
}
QString CollapsibleEffect::infoString() const
}
if (m_effect.attribute("tag") == "region") {
+ m_regionEffect = true;
QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
vbox->setContentsMargins(0, 0, 0, 0);
vbox->setSpacing(2);
QDomNodeList origin_effects = m_original_effect.elementsByTagName("effect");
QWidget *container = new QWidget(widgetFrame);
vbox->addWidget(container);
- m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
+ // m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
for (int i = 0; i < effects.count(); i++) {
CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, metaInfo, container);
m_subParamWidgets.append(coll);
+ connect(coll, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateRegionEffectParams(const QDomElement, const QDomElement, int)));
//container = new QWidget(widgetFrame);
vbox->addWidget(coll);
//p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
}
}
+void CollapsibleEffect::slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/)
+{
+ kDebug()<<"// EMIT CHANGE SUBEFFECT.....:";
+ emit parameterChanged(m_original_effect, m_effect, effectIndex());
+}
+
void CollapsibleEffect::slotSyncEffectsPos(int pos)
{
emit syncEffectsPos(pos);
doc.setContent(effects, true);
QDomElement e = doc.documentElement();
int ix = e.attribute("kdenlive_ix").toInt();
- if (ix == effectIndex()) {
+ int currentEffectIx = effectIndex();
+ if (ix == currentEffectIx) {
// effect dropped on itself, reject
event->ignore();
return;
}
- if (ix == 0) {
+ if (ix == 0 || e.tagName() == "effectgroup") {
+ if (e.tagName() == "effectgroup") {
+ // moving a group
+ QDomNodeList subeffects = e.elementsByTagName("effect");
+ if (subeffects.isEmpty()) {
+ event->ignore();
+ return;
+ }
+ EffectInfo info;
+ info.fromString(subeffects.at(0).toElement().attribute("kdenlive_info"));
+ event->setDropAction(Qt::MoveAction);
+ event->accept();
+ if (info.groupIndex >= 0) {
+ // Moving group
+ QList <int> effectsIds;
+ // Collect moved effects ids
+ for (int i = 0; i < subeffects.count(); i++) {
+ QDomElement effect = subeffects.at(i).toElement();
+ effectsIds << effect.attribute("kdenlive_ix").toInt();
+ }
+ emit moveEffect(effectsIds, currentEffectIx, info.groupIndex, info.groupName);
+ }
+ else {
+ // group effect dropped from effect list
+ if (m_info.groupIndex > -1) {
+ // TODO: Should we merge groups??
+
+ }
+ emit addEffect(e);
+ }
+ return;
+ }
// effect dropped from effects list, add it
e.setAttribute("kdenlive_ix", ix);
+ if (m_info.groupIndex > -1) {
+ // Dropped on a group
+ e.setAttribute("kdenlive_info", m_info.toString());
+ }
event->setDropAction(Qt::CopyAction);
event->accept();
emit addEffect(e);
return;
}
- emit moveEffect(ix, effectIndex(), m_info.groupIndex, m_info.groupName);
+ emit moveEffect(QList <int> () <<ix, currentEffectIx, m_info.groupIndex, m_info.groupName);
event->setDropAction(Qt::MoveAction);
event->accept();
}
m_keyframeEditor->addParameter(pa);
}
} else if (type == "color") {
+ if (pa.hasAttribute("paramprefix")) value.remove(0, pa.attribute("paramprefix").size());
if (value.startsWith('#'))
value = value.replace('#', "0x");
ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
+ choosecolor->setAlphaChannelEnabled(true);
m_vbox->addWidget(choosecolor);
m_valueItems[paramName] = choosecolor;
connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
QDomNodeList namenode = m_effect.elementsByTagName("parameter");
for (int i = 0; i < namenode.count() ; i++) {
- QDomNode pa = namenode.item(i);
+ QDomElement pa = namenode.item(i).toElement();
QDomElement na = pa.firstChildElement("name");
- QString type = pa.attributes().namedItem("type").nodeValue();
- QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
+ QString type = pa.attribute("type");
+ QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
if (type == "complex")
paramName.append("complex");
else if (type == "position")
} else if (type == "color") {
ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
setValue = choosecolor->getColor();
+ if (pa.hasAttribute("paramprefix")) setValue.prepend(pa.attribute("paramprefix"));
} else if (type == "complex") {
ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
namenode.item(i) = complex->getParamDesc();
} else if (type == "curve") {
KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
QList<QPointF> points = curve->curve().points();
- QString number = pa.attributes().namedItem("number").nodeValue();
- QString inName = pa.attributes().namedItem("inpoints").nodeValue();
- QString outName = pa.attributes().namedItem("outpoints").nodeValue();
- int off = pa.attributes().namedItem("min").nodeValue().toInt();
- int end = pa.attributes().namedItem("max").nodeValue().toInt();
+ QString number = pa.attribute("number");
+ QString inName = pa.attribute("inpoints");
+ QString outName = pa.attribute("outpoints");
+ int off = pa.attribute("min").toInt();
+ int end = pa.attribute("max").toInt();
if (oldparam.attribute("version").toDouble() > 0.2) {
EffectsList::setParameter(m_effect, number, locale.toString(points.count() / 10.));
} else {
EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
}
- QString depends = pa.attributes().namedItem("depends").nodeValue();
+ QString depends = pa.attribute("depends");
if (!depends.isEmpty())
meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
} else if (type == "bezier_spline") {
BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
setValue = widget->spline();
- QString depends = pa.attributes().namedItem("depends").nodeValue();
+ QString depends = pa.attribute("depends");
if (!depends.isEmpty())
meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
#ifdef USE_QJSON
setValue = getWipeString(info);
} else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
- QDomElement elem = pa.toElement();
QString realName = i18n(na.toElement().text().toUtf8().data());
QString val = m_keyframeEditor->getValue(realName);
- elem.setAttribute("keyframes", val);
+ pa.setAttribute("keyframes", val);
if (m_keyframeEditor->isVisibleParam(realName)) {
- elem.setAttribute("intimeline", "1");
+ pa.setAttribute("intimeline", "1");
}
- else if (elem.hasAttribute("intimeline"))
- elem.removeAttribute("intimeline");
+ else if (pa.hasAttribute("intimeline"))
+ pa.removeAttribute("intimeline");
} else if (type == "url") {
KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
setValue = req->url().path();
setValue = fontfamily->currentFont().family();
}
if (!setValue.isNull())
- pa.attributes().namedItem("value").setNodeValue(setValue);
+ pa.setAttribute("value", setValue);
}
emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());
return QString(start + ";-1=" + end);
}
+void ParameterContainer::updateParameter(const QString &key, const QString &value)
+{
+ m_effect.setAttribute(key, value);
+}
+
void ParameterContainer::slotStartFilterJobAction()
{
QDomNodeList namenode = m_effect.elementsByTagName("parameter");