1 /***************************************************************************
2 effecstackedit.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "effectstackedit.h"
19 #include "effectstack/effectstackview2.h"
20 #include "effectslist.h"
22 #include "kdenlivesettings.h"
26 #include <KFileDialog>
29 #include <QVBoxLayout>
31 #include <QPushButton>
33 #include <QScrollArea>
35 #include <QProgressBar>
36 #include <QWheelEvent>
38 // For QDomNode debugging (output into files); leaving here as sample code.
42 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
46 m_baseWidget = new QWidget(this);
47 m_metaInfo.monitor = monitor;
48 m_metaInfo.trackMode = false;
49 setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
50 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
51 setFrameStyle(QFrame::NoFrame);
52 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
54 setStyleSheet(EffectStackView2::getStyleSheet());
55 setWidget(m_baseWidget);
56 /*m_vbox = new QVBoxLayout(m_baseWidget);
57 m_vbox->setContentsMargins(0, 0, 0, 0);
58 m_vbox->setSpacing(2); */
59 setWidgetResizable(true);
62 EffectStackEdit::~EffectStackEdit()
67 Monitor *EffectStackEdit::monitor()
69 return m_metaInfo.monitor;
72 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
74 m_metaInfo.profile = profile;
75 m_metaInfo.timecode = t;
78 void EffectStackEdit::setFrameSize(QPoint p)
80 m_metaInfo.frameSize = p;
83 void EffectStackEdit::updateTimecodeFormat()
85 if (m_paramWidget) m_paramWidget->updateTimecodeFormat();
88 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
90 m_paramWidget->updateParameter(name, value);
92 if (name == "disable") {
93 // if effect is disabled, disable parameters widget
94 bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters();
96 emit effectStateChanged(enabled);
100 bool EffectStackEdit::eventFilter( QObject * o, QEvent * e )
102 if (e->type() == QEvent::Wheel) {
103 QWheelEvent *we = static_cast<QWheelEvent *>(e);
104 bool filterWheel = verticalScrollBar() && verticalScrollBar()->isVisible();
105 if (!filterWheel || we->modifiers() != Qt::NoModifier) {
109 if (qobject_cast<QAbstractSpinBox*>(o)) {
110 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
121 if (qobject_cast<KComboBox*>(o)) {
122 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
133 if (qobject_cast<QProgressBar*>(o)) {
134 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
146 return QWidget::eventFilter(o, e);
149 void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, bool /*isEffect*/)
151 if (m_paramWidget) delete m_paramWidget;
152 m_paramWidget = new ParameterContainer(d, info, &m_metaInfo, m_baseWidget);
153 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
155 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,const QMap<QString, QString>)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,const QMap<QString, QString>)));
157 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
158 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
159 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
160 connect (m_paramWidget, SIGNAL(importClipKeyframes()), this, SIGNAL(importClipKeyframes()));
162 Q_FOREACH( QSpinBox * sp, m_baseWidget->findChildren<QSpinBox*>() ) {
163 sp->installEventFilter( this );
164 sp->setFocusPolicy( Qt::StrongFocus );
166 Q_FOREACH( KComboBox * cb, m_baseWidget->findChildren<KComboBox*>() ) {
167 cb->installEventFilter( this );
168 cb->setFocusPolicy( Qt::StrongFocus );
170 Q_FOREACH( QProgressBar * cb, m_baseWidget->findChildren<QProgressBar*>() ) {
171 cb->installEventFilter( this );
172 cb->setFocusPolicy( Qt::StrongFocus );
176 void EffectStackEdit::slotSyncEffectsPos(int pos)
178 emit syncEffectsPos(pos);
181 bool EffectStackEdit::needsMonitorEffectScene() const
183 if (!m_paramWidget) return false;
184 return m_paramWidget->needsMonitorEffectScene();
187 void EffectStackEdit::setKeyframes(const QString &data)
189 if (!m_paramWidget) return;
190 m_paramWidget->setKeyframes(data);