X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Feffectstackedit.cpp;h=24bc2275f3493c127896547a7a212b996c53d012;hb=f53571700a2b48f5322432f5f896f5ab36b23ab9;hp=d156ff709710f45b6882691cd06e66ea06d48ef2;hpb=b55458213a809ce0b2605cf59968b0bde316d32b;p=kdenlive diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index d156ff70..24bc2275 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,9 @@ #include #include +// For QDomNode debugging (output into files); leaving here as sample code. +//#define DEBUG_ESE + class Boolval: public QWidget, public Ui::Boolval_UI { @@ -74,20 +78,30 @@ EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) : m_out(0), m_frameSize(QPoint()), m_keyframeEditor(NULL), - m_monitor(monitor) + m_monitor(monitor), + m_geometryWidget(NULL) { m_baseWidget = new QWidget(this); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 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); m_vbox->setContentsMargins(0, 0, 0, 0); - m_vbox->setSpacing(0); - //wid->show(); + m_vbox->setSpacing(2); } EffectStackEdit::~EffectStackEdit() @@ -106,10 +120,16 @@ void EffectStackEdit::setFrameSize(QPoint p) QString type = pa.attributes().namedItem("type").nodeValue(); QString paramName = i18n(na.toElement().text().toUtf8().data()); - if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) { - Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); - geom->setFrameSize(m_frameSize); - break; + if (type == "geometry") { + if (!KdenliveSettings::on_monitor_effects()) { + Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); + geom->setFrameSize(m_frameSize); + break; + } + else { + if (m_geometryWidget) m_geometryWidget->setFrameSize(m_frameSize); + break; + } } } } @@ -128,8 +148,7 @@ void EffectStackEdit::updateTimecodeFormat() if (type == "geometry") { if (KdenliveSettings::on_monitor_effects()) { - GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"]; - geom->updateTimecodeFormat(); + if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat(); } else { Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); geom->updateTimecodeFormat(); @@ -192,6 +211,19 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in } QDomNodeList namenode = m_params.elementsByTagName("parameter"); +#ifdef DEBUG_ESE + QFile debugFile("/tmp/namenodes.txt"); + if (debugFile.open(QFile::WriteOnly | QFile::Truncate)) { + QTextStream out(&debugFile); + QTextStream out2(stdout); + for (int i = 0; i < namenode.size(); i++) { + out << i << ": \n"; + namenode.at(i).save(out, 2); + out2 << i << ": \n"; + namenode.at(i).save(out2, 2); + } + } +#endif QDomElement e = m_params.toElement(); const int minFrame = e.attribute("start").toInt(); const int maxFrame = e.attribute("end").toInt(); @@ -241,7 +273,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in max = pa.attribute("max").toInt(); DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max, - pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this); + pa.attribute("default").toInt(), comment, -1, pa.attribute("suffix"), this); m_vbox->addWidget(doubleparam); m_valueItems[paramName] = doubleparam; connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters())); @@ -297,20 +329,21 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); } else if (type == "geometry") { if (KdenliveSettings::on_monitor_effects()) { - GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this); - geometry->slotShowScene(!disable); + m_geometryWidget = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, m_params.hasAttribute("showrotation"), this); + m_geometryWidget->setFrameSize(m_frameSize); + m_geometryWidget->slotShowScene(!disable); // connect this before setupParam to make sure the monitor scene shows up at startup - connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); - connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); + connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); + connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); if (minFrame == maxFrame) - geometry->setupParam(pa, m_in, m_out); + m_geometryWidget->setupParam(pa, m_in, m_out); else - geometry->setupParam(pa, minFrame, maxFrame); - m_vbox->addWidget(geometry); - m_valueItems[paramName+"geometry"] = geometry; - connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); - connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int))); - connect(this, SIGNAL(effectStateChanged(bool)), geometry, SLOT(slotShowScene(bool))); + m_geometryWidget->setupParam(pa, minFrame, maxFrame); + m_vbox->addWidget(m_geometryWidget); + m_valueItems[paramName+"geometry"] = m_geometryWidget; + connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); + connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int))); + connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool))); } else { Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos); if (minFrame == maxFrame) @@ -323,6 +356,9 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int))); } + } else if (type == "addedgeometry") { + // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ... + if (m_geometryWidget) m_geometryWidget->addParameter(pa); } else if (type == "keyframe" || type == "simplekeyframe") { // keyframe editor widget if (m_keyframeEditor == NULL) { @@ -412,10 +448,11 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in meetDependency(paramName, type, EffectsList::parameter(e, depends)); #ifdef QJSON } else if (type == "roto-spline") { - RotoWidget *roto = new RotoWidget(value, m_monitor, m_in, m_out, this); + RotoWidget *roto = new RotoWidget(value, m_monitor, m_in, m_out, m_timecode, this); roto->slotShowScene(!disable); connect(roto, SIGNAL(valueChanged()), this, SLOT(collectAllParameters())); connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); + connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int))); connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool))); m_vbox->addWidget(roto); @@ -500,6 +537,16 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in if (m_keyframeEditor) m_keyframeEditor->checkVisibleParam(); + + // Make sure all doubleparam spinboxes have the same width, looks much better + QList allWidgets = findChildren(); + int minSize = 0; + for (int i = 0; i < allWidgets.count(); i++) { + if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize(); + } + for (int i = 0; i < allWidgets.count(); i++) { + allWidgets.at(i)->setSpinSize(minSize); + } } wipeInfo EffectStackEdit::getWipeInfo(QString value) @@ -608,7 +655,7 @@ void EffectStackEdit::collectAllParameters() paramName.append("geometry"); else if (type == "keyframe") paramName.append("keyframe"); - if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) { + if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) { kDebug() << "// Param: " << paramName << " NOT FOUND"; continue; } @@ -631,12 +678,13 @@ void EffectStackEdit::collectAllParameters() namenode.item(i) = complex->getParamDesc(); } else if (type == "geometry") { if (KdenliveSettings::on_monitor_effects()) { - GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName)); - namenode.item(i).toElement().setAttribute("value", geometry->getValue()); + if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue()); } else { Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName)); namenode.item(i).toElement().setAttribute("value", geom->getValue()); } + } else if (type == "addedgeometry") { + namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name"))); } else if (type == "position") { PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName)); int pos = pedit->getPosition(); @@ -763,6 +811,7 @@ void EffectStackEdit::clearAllItems() if (wid) delete wid; } m_keyframeEditor = NULL; + m_geometryWidget = NULL; blockSignals(false); }