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"
21 #include "kdenlivesettings.h"
25 #include <KFileDialog>
28 #include <QVBoxLayout>
30 #include <QPushButton>
32 #include <QScrollArea>
34 #include <QProgressBar>
35 #include <QWheelEvent>
37 // For QDomNode debugging (output into files); leaving here as sample code.
41 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
47 m_baseWidget = new QWidget(this);
48 m_metaInfo.monitor = monitor;
49 m_metaInfo.trackMode = false;
50 setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
51 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
52 setFrameStyle(QFrame::NoFrame);
53 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
55 setStyleSheet(EffectStackView2::getStyleSheet());
56 setWidget(m_baseWidget);
57 /*m_vbox = new QVBoxLayout(m_baseWidget);
58 m_vbox->setContentsMargins(0, 0, 0, 0);
59 m_vbox->setSpacing(2); */
60 setWidgetResizable(true);
63 EffectStackEdit::~EffectStackEdit()
68 Monitor *EffectStackEdit::monitor()
70 return m_metaInfo.monitor;
73 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
75 m_metaInfo.profile = profile;
76 m_metaInfo.timecode = t;
79 void EffectStackEdit::setFrameSize(QPoint p)
81 m_metaInfo.frameSize = p;
84 void EffectStackEdit::updateTimecodeFormat()
86 if (m_paramWidget) m_paramWidget->updateTimecodeFormat();
89 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
91 m_paramWidget->updateParameter(name, value);
93 if (name == "disable") {
94 // if effect is disabled, disable parameters widget
95 bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters();
97 emit effectStateChanged(enabled);
101 bool EffectStackEdit::eventFilter( QObject * o, QEvent * e )
103 if (e->type() == QEvent::Wheel) {
104 QWheelEvent *we = static_cast<QWheelEvent *>(e);
105 bool filterWheel = verticalScrollBar() && verticalScrollBar()->isVisible();
106 if (!filterWheel || we->modifiers() != Qt::NoModifier) {
110 if (qobject_cast<QAbstractSpinBox*>(o)) {
111 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
122 if (qobject_cast<KComboBox*>(o)) {
123 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
134 if (qobject_cast<QProgressBar*>(o)) {
135 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
147 return QWidget::eventFilter(o, e);
150 void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, bool /*isEffect*/)
152 if (m_paramWidget) delete m_paramWidget;
153 m_paramWidget = new ParameterContainer(d, info, &m_metaInfo, m_baseWidget);
154 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
156 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
158 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
159 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
160 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
163 Q_FOREACH( QSpinBox * sp, m_baseWidget->findChildren<QSpinBox*>() ) {
164 sp->installEventFilter( this );
165 sp->setFocusPolicy( Qt::StrongFocus );
167 Q_FOREACH( KComboBox * cb, m_baseWidget->findChildren<KComboBox*>() ) {
168 cb->installEventFilter( this );
169 cb->setFocusPolicy( Qt::StrongFocus );
171 Q_FOREACH( QProgressBar * cb, m_baseWidget->findChildren<QProgressBar*>() ) {
172 cb->installEventFilter( this );
173 cb->setFocusPolicy( Qt::StrongFocus );
179 void EffectStackEdit::slotSyncEffectsPos(int pos)
181 emit syncEffectsPos(pos);