X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Feffectstackedit.cpp;h=8ec639f43889f63e0c1c59df571032e8fbcd6af3;hb=ce68de86827a11cd0dc96465fba021b2f7ceea55;hp=a2d2b5ff1e07e45b81a26514f4d9f8ddee8d6241;hpb=8b222e18e56f33b489e6d4e5d80ac6d23df5ce09;p=kdenlive diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index a2d2b5ff..8ec639f4 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -20,6 +20,8 @@ #include "ui_boolval_ui.h" #include "ui_wipeval_ui.h" #include "ui_urlval_ui.h" +#include "ui_keywordval_ui.h" +#include "ui_fontval_ui.h" #include "complexparameter.h" #include "geometryval.h" #include "positionedit.h" @@ -35,20 +37,21 @@ #include "doubleparameterwidget.h" #include "cornerswidget.h" #include "beziercurve/beziersplinewidget.h" -#ifdef QJSON +#ifdef USE_QJSON #include "rotoscoping/rotowidget.h" #endif #include #include #include -#include #include #include #include #include #include +#include +#include // For QDomNode debugging (output into files); leaving here as sample code. //#define DEBUG_ESE @@ -70,44 +73,39 @@ class Urlval: public QWidget, public Ui::Urlval_UI { }; +class Keywordval: public QWidget, public Ui::Keywordval_UI +{ +}; + +class Fontval: public QWidget, public Ui::Fontval_UI +{ +}; + QMap EffectStackEdit::iconCache; EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) : QScrollArea(parent), m_in(0), m_out(0), - m_frameSize(QPoint()), m_keyframeEditor(NULL), m_monitor(monitor), - m_geometryWidget(NULL) + m_geometryWidget(NULL), + m_paramWidget(NULL) { m_baseWidget = new QWidget(this); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_metaInfo.monitor = monitor; + m_metaInfo.trackMode = false; + setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setFrameStyle(QFrame::NoFrame); setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding)); - QPalette p = palette(); - KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme())); - QColor dark_bg = scheme.shade(KColorScheme::DarkShade); - QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color(); - QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color(); - QColor light_bg = scheme.shade(KColorScheme::LightShade); - - QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %1;border-radius:0px;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right: 0px;background:%4;padding: 0px;text-align:left center}\ - QProgressBar:horizontal#dragOnly {background: %1} QProgressBar:horizontal:hover#dragOnly {background: %3} QProgressBar:horizontal:hover {border: 1px solid %3;border-right: 0px;}\ - QProgressBar::chunk:horizontal {background: %1;} QProgressBar::chunk:horizontal:hover {background: %3;}\ - QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}\ - QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;}\ - QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ") - .arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name())); - setStyleSheet(stylesheet); - - setWidget(m_baseWidget); - setWidgetResizable(true); - m_vbox = new QVBoxLayout(m_baseWidget); + setStyleSheet(CollapsibleEffect::getStyleSheet()); + setWidget(m_baseWidget); + /*m_vbox = new QVBoxLayout(m_baseWidget); m_vbox->setContentsMargins(0, 0, 0, 0); - m_vbox->setSpacing(2); + m_vbox->setSpacing(2); */ + setWidgetResizable(true); } EffectStackEdit::~EffectStackEdit() @@ -116,8 +114,21 @@ EffectStackEdit::~EffectStackEdit() delete m_baseWidget; } +Monitor *EffectStackEdit::monitor() +{ + return m_metaInfo.monitor; +} + +void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t) +{ + m_metaInfo.profile = profile; + m_metaInfo.timecode = t; +} + void EffectStackEdit::setFrameSize(QPoint p) { + m_metaInfo.frameSize = p; + /* m_frameSize = p; QDomNodeList namenode = m_params.elementsByTagName("parameter"); for (int i = 0; i < namenode.count() ; i++) { @@ -137,38 +148,12 @@ void EffectStackEdit::setFrameSize(QPoint p) break; } } - } + }*/ } void EffectStackEdit::updateTimecodeFormat() { - if (m_keyframeEditor) - m_keyframeEditor->updateTimecodeFormat(); - - QDomNodeList namenode = m_params.elementsByTagName("parameter"); - for (int i = 0; i < namenode.count() ; i++) { - QDomNode pa = namenode.item(i); - 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()); - - if (type == "geometry") { - if (KdenliveSettings::on_monitor_effects()) { - if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat(); - } else { - Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); - geom->updateTimecodeFormat(); - } - break; - } else if (type == "position") { - PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]); - posi->updateTimecodeFormat(); - break; - } else if (type == "roto-spline") { - RotoWidget *widget = static_cast(m_valueItems[paramName]); - widget->updateTimecodeFormat(); - } - } + if (m_paramWidget) m_paramWidget->updateTimecodeFormat(); } void EffectStackEdit::meetDependency(const QString& name, QString type, QString value) @@ -187,12 +172,6 @@ void EffectStackEdit::meetDependency(const QString& name, QString type, QString } } -void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t) -{ - m_profile = profile; - m_timecode = t; -} - void EffectStackEdit::updateParameter(const QString &name, const QString &value) { m_params.setAttribute(name, value); @@ -205,9 +184,84 @@ void EffectStackEdit::updateParameter(const QString &name, const QString &value) } } -void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool isEffect) +bool EffectStackEdit::eventFilter( QObject * o, QEvent * e ) +{ + if (e->type() == QEvent::Wheel) { + QWheelEvent *we = static_cast(e); + bool filterWheel = verticalScrollBar() && verticalScrollBar()->isVisible(); + if (!filterWheel || we->modifiers() != Qt::NoModifier) { + e->accept(); + return false; + } + if (qobject_cast(o)) { + if(qobject_cast(o)->focusPolicy() == Qt::WheelFocus) + { + e->accept(); + return false; + } + else + { + e->ignore(); + return true; + } + } + if (qobject_cast(o)) { + if(qobject_cast(o)->focusPolicy() == Qt::WheelFocus) + { + e->accept(); + return false; + } + else + { + e->ignore(); + return true; + } + } + if (qobject_cast(o)) { + if(qobject_cast(o)->focusPolicy() == Qt::WheelFocus) + { + e->accept(); + return false; + } + else + { + e->ignore(); + return true; + } + } + } + return QWidget::eventFilter(o, e); +} + +void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, bool /*isEffect*/) { - clearAllItems(); + if (m_paramWidget) delete m_paramWidget; + m_paramWidget = new ParameterContainer(d, info, &m_metaInfo, m_baseWidget); + connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int))); + + connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString))); + + connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int))); + connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); + connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int))); + + + Q_FOREACH( QSpinBox * sp, m_baseWidget->findChildren() ) { + sp->installEventFilter( this ); + sp->setFocusPolicy( Qt::StrongFocus ); + } + Q_FOREACH( KComboBox * cb, m_baseWidget->findChildren() ) { + cb->installEventFilter( this ); + cb->setFocusPolicy( Qt::StrongFocus ); + } + Q_FOREACH( QProgressBar * cb, m_baseWidget->findChildren() ) { + cb->installEventFilter( this ); + cb->setFocusPolicy( Qt::StrongFocus ); + } + + return; + /* + //clearAllItems(); if (m_keyframeEditor) delete m_keyframeEditor; m_keyframeEditor = NULL; m_params = d; @@ -232,9 +286,10 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool } } #endif - QDomElement e = m_params.toElement(); - const int minFrame = e.attribute("start").toInt(); - const int maxFrame = e.attribute("end").toInt(); + int minFrame = d.attribute("start").toInt(); + int maxFrame = d.attribute("end").toInt(); + // In transitions, maxFrame is in fact one frame after the end of transition + if (maxFrame > 0) maxFrame --; bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters(); setEnabled(!disable); @@ -251,22 +306,21 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool QString comment; if (!commentElem.isNull()) comment = i18n(commentElem.text().toUtf8().data()); - QWidget * toFillin = new QWidget(m_baseWidget); QString value = pa.attribute("value").isNull() ? pa.attribute("default") : pa.attribute("value"); - /** See effects/README for info on the different types */ + if (type == "double" || type == "constant") { double min; double max; - if (pa.attribute("min").startsWith('%')) - min = ProfilesDialog::getStringEval(m_profile, pa.attribute("min")); + if (pa.attribute("min").contains('%')) + min = ProfilesDialog::getStringEval(m_profile, pa.attribute("min"), m_frameSize); else min = pa.attribute("min").toDouble(); - if (pa.attribute("max").startsWith('%')) - max = ProfilesDialog::getStringEval(m_profile, pa.attribute("max")); + if (pa.attribute("max").contains('%')) + max = ProfilesDialog::getStringEval(m_profile, pa.attribute("max"), m_frameSize); else max = pa.attribute("max").toDouble(); @@ -278,12 +332,21 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool))); } else if (type == "list") { Listval *lsval = new Listval; + QWidget * toFillin = new QWidget(m_baseWidget); lsval->setupUi(toFillin); - QStringList listitems = pa.attribute("paramlist").split(','); + m_vbox->addWidget(toFillin); + QStringList listitems = pa.attribute("paramlist").split(';'); + if (listitems.count() == 1) { + // probably custom effect created before change to ';' as separator + listitems = pa.attribute("paramlist").split(','); + } QDomElement list = pa.firstChildElement("paramlistdisplay"); QStringList listitemsdisplay; - if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(','); - else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(','); + if (!list.isNull()) { + listitemsdisplay = i18n(list.text().toUtf8().data()).split(','); + } else { + listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(','); + } if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems; lsval->list->setIconSize(QSize(30, 30)); @@ -309,7 +372,9 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool m_uiItems.append(lsval); } else if (type == "bool") { Boolval *bval = new Boolval; + QWidget * toFillin = new QWidget(m_baseWidget); bval->setupUi(toFillin); + m_vbox->addWidget(toFillin); bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked); bval->name->setText(paramName); bval->labelComment->setText(comment); @@ -363,14 +428,14 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool KeyframeEdit *geo; if (pa.attribute("widget") == "corners") { // we want a corners-keyframe-widget - CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt(), this); + CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_out, m_timecode, d.attribute("active_keyframe", "-1").toInt(), this); corners->slotShowScene(!disable); connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool))); connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int))); geo = static_cast(corners); } else { - geo = new KeyframeEdit(pa, m_in, m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt()); + geo = new KeyframeEdit(pa, m_in, m_out, m_timecode, d.attribute("active_keyframe", "-1").toInt()); } m_vbox->addWidget(geo); m_valueItems[paramName+"keyframe"] = geo; @@ -383,10 +448,8 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool m_keyframeEditor->addParameter(pa); } } else if (type == "color") { - if (value.startsWith('#')) - value = value.replace('#', "0x"); - bool ok; - ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this); + ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, this); + choosecolor->setAlphaChannelEnabled(pa.attribute("alpha") == "1"); m_vbox->addWidget(choosecolor); m_valueItems[paramName] = choosecolor; connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int))); @@ -407,7 +470,12 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool KisCurveWidget *curve = new KisCurveWidget(this); curve->setMaxPoints(pa.attribute("max").toInt()); QList points; - int number = EffectsList::parameter(e, pa.attribute("number")).toInt(); + int number; + if (d.attribute("version").toDouble() > 0.2) { + number = EffectsList::parameter(d, pa.attribute("number")).toDouble() * 10; + } else { + number = EffectsList::parameter(d, pa.attribute("number")).toInt(); + } QString inName = pa.attribute("inpoints"); QString outName = pa.attribute("outpoints"); int start = pa.attribute("min").toInt(); @@ -416,7 +484,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool in.replace("%i", QString::number(j)); QString out = outName; out.replace("%i", QString::number(j)); - points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble()); + points << QPointF(EffectsList::parameter(d, in).toDouble(), EffectsList::parameter(d, out).toDouble()); } if (!points.isEmpty()) curve->setCurve(KisCubicCurve(points)); @@ -434,7 +502,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool QString depends = pa.attribute("depends"); if (!depends.isEmpty()) - meetDependency(paramName, type, EffectsList::parameter(e, depends)); + meetDependency(paramName, type, EffectsList::parameter(d, depends)); } else if (type == "bezier_spline") { BezierSplineWidget *widget = new BezierSplineWidget(value, this); stretch = false; @@ -443,8 +511,8 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters())); QString depends = pa.attribute("depends"); if (!depends.isEmpty()) - meetDependency(paramName, type, EffectsList::parameter(e, depends)); -#ifdef QJSON + meetDependency(paramName, type, EffectsList::parameter(d, depends)); +#ifdef USE_QJSON } else if (type == "roto-spline") { RotoWidget *roto = new RotoWidget(value, m_monitor, info, m_timecode, this); roto->slotShowScene(!disable); @@ -458,7 +526,9 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool #endif } else if (type == "wipe") { Wipeval *wpval = new Wipeval; + QWidget * toFillin = new QWidget(m_baseWidget); wpval->setupUi(toFillin); + m_vbox->addWidget(toFillin); wipeInfo w = getWipeInfo(value); switch (w.start) { case UP: @@ -513,7 +583,9 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool m_uiItems.append(wpval); } else if (type == "url") { Urlval *cval = new Urlval; + QWidget * toFillin = new QWidget(m_baseWidget); cval->setupUi(toFillin); + m_vbox->addWidget(toFillin); cval->label->setText(paramName); cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions()); m_valueItems[paramName] = cval; @@ -521,13 +593,51 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters())); connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters())); m_uiItems.append(cval); - } else { - delete toFillin; - toFillin = NULL; - } - - if (toFillin) + } else if (type == "keywords") { + Keywordval* kval = new Keywordval; + QWidget * toFillin = new QWidget(m_baseWidget); + kval->setupUi(toFillin); + m_vbox->addWidget(toFillin); + kval->label->setText(paramName); + kval->lineeditwidget->setText(value); + QDomElement klistelem = pa.firstChildElement("keywords"); + QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay"); + QStringList keywordlist; + QStringList keyworddisplaylist; + if (!klistelem.isNull()) { + keywordlist = klistelem.text().split(';'); + keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';'); + } + if (keyworddisplaylist.count() != keywordlist.count()) { + keyworddisplaylist = keywordlist; + } + for (int i = 0; i < keywordlist.count(); i++) { + kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i)); + } + // Add disabled user prompt at index 0 + kval->comboboxwidget->insertItem(0, i18n("