#include <QTextStream>
#include <QFile>
#include <QInputDialog>
+#include <QScrollBar>
EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) :
m_ui.checkAll->setToolTip(i18n("Enable/Disable all effects"));
m_ui.buttonShowComments->setIcon(KIcon("help-about"));
m_ui.buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
+
+ connect(m_ui.checkAll, SIGNAL(stateChanged(int)), this, SLOT(slotCheckAll(int)));
setEnabled(false);
m_effects.at(i)->slotSyncEffectsPos(pos);
}
-void EffectStackView2::setMenu(QMenu *menu)
-{
- //m_ui.buttonNew->setMenu(menu);
-}
-
void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix)
{
if (c && !c->isEnabled()) return;
m_ui.checkAll->setToolTip(QString());
m_ui.checkAll->setText(i18n("Effects for %1").arg(cname));
}
+ m_ui.checkAll->setEnabled(true);
ix = c->selectedEffectIndex();
QString size = c->baseClip()->getProperty("frame_size");
double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
void EffectStackView2::setupListView(int ix)
{
- //TODO: clear list
-
blockSignals(true);
m_draggedEffect = NULL;
disconnect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
blockSignals(false);
view = new QWidget(m_ui.container);
m_ui.container->setWidget(view);
+ slotUpdateCheckAllButton();
QVBoxLayout *vbox1 = new QVBoxLayout(view);
vbox1->setContentsMargins(0, 0, 0, 0);
EffectInfo effectInfo;
effectInfo.fromString(d.attribute("kdenlive_info"));
if (effectInfo.groupIndex >= 0) {
- for (int j = 0; j < vbox1->count(); j++) {
- CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(vbox1->itemAt(j)->widget());
- if (gp->groupIndex() == effectInfo.groupIndex) {
- group = gp;
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->groupIndex() == effectInfo.groupIndex) {
+ group = m_effects.at(i);
break;
}
}
}
vbox1->addStretch(10);
connect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
+
+ // Wait a little bit for the new layout to be ready, then check if we have a scrollbar
+ QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter()));
+}
+
+
+void EffectStackView2::slotCheckWheelEventFilter()
+{
+ // If the effect stack widget has no scrollbar, we will not filter the
+ // mouse wheel events, so that user can easily adjust effect params
+ bool filterWheelEvent = false;
+ if (m_ui.container->verticalScrollBar() && m_ui.container->verticalScrollBar()->isVisible()) {
+ // widget has scroll bar,
+ filterWheelEvent = true;
+ }
+ for (int i = 0; i < m_effects.count(); i++) {
+ m_effects.at(i)->filterWheelEvent = filterWheelEvent;
+ }
+}
+
+void EffectStackView2::resizeEvent ( QResizeEvent * event )
+{
+ slotCheckWheelEventFilter();
+ QWidget::resizeEvent(event);
}
bool EffectStackView2::eventFilter( QObject * o, QEvent * e )
emit changeEffectState(NULL, m_trackindex, index, disable);
else
emit changeEffectState(m_clipref, -1, index, disable);
+ slotUpdateCheckAllButton();
}
}
m_ui.checkAll->setToolTip(QString());
m_ui.checkAll->setText(QString());
+ m_ui.checkAll->setEnabled(false);
setEnabled(false);
}
-void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t)
+void EffectStackView2::slotCheckAll(int state)
{
- m_effectMetaInfo.profile = profile;
- m_effectMetaInfo.timecode = t;
+ if (state == 1) {
+ state = 2;
+ m_ui.checkAll->blockSignals(true);
+ m_ui.checkAll->setCheckState(Qt::Checked);
+ m_ui.checkAll->blockSignals(false);
+ }
+
+ bool disabled = (state != 2);
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->groupIndex() == -1) {
+ m_effects.at(i)->slotEnable(disabled);
+ }
+ }
}
-void EffectStackView2::slotItemDel()
+void EffectStackView2::slotUpdateCheckAllButton()
{
+ bool hasEnabled = false;
+ bool hasDisabled = false;
+
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->enabledBox->isChecked()) hasEnabled = true;
+ else hasDisabled = true;
+ }
+ m_ui.checkAll->blockSignals(true);
+ if (hasEnabled && hasDisabled)
+ m_ui.checkAll->setCheckState(Qt::PartiallyChecked);
+ else if (hasEnabled)
+ m_ui.checkAll->setCheckState(Qt::Checked);
+ else
+ m_ui.checkAll->setCheckState(Qt::Unchecked);
+ m_ui.checkAll->blockSignals(false);
+}
+
+void EffectStackView2::deleteCurrentEffect()
+{
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->isActive()) {
+ slotDeleteEffect(m_effects.at(i)->effect());
+ break;
+ }
+ }
+}
+
+void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t)
+{
+ m_effectMetaInfo.profile = profile;
+ m_effectMetaInfo.timecode = t;
}
void EffectStackView2::updateTimecodeFormat()
// Make sure the changed effect is currently displayed
slotSetCurrentEffect(ix);
}
+ QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter()));
}
void EffectStackView2::slotSetCurrentEffect(int ix)
QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
int groupPos = 0;
-
CollapsibleEffect *effectToMove = NULL;
- for (int j = 0; j < l->count(); j++) {
- CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(l->itemAt(j)->widget());
- if (gp->effectIndex() == ix) {
- effectToMove = gp;
- groupPos = l->indexOf(gp);
- l->removeWidget(gp);
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->effectIndex() == ix) {
+ effectToMove = m_effects.at(i);
+ groupPos = l->indexOf(effectToMove);
+ l->removeWidget(effectToMove);
break;
}
}
/** @brief Raises @param dock if a clip is loaded. */
void raiseWindow(QWidget* dock);
- /** @brief Sets the add effect button's menu to @param menu. */
- void setMenu(QMenu *menu);
-
-
/** @brief return the index of the track displayed in effect stack
** @param ok set to true if we are looking at a track's effects, otherwise false. */
int isTrackMode(bool *ok) const;
virtual bool eventFilter( QObject * o, QEvent * e );
CollapsibleEffect *getEffectByIndex(int ix);
+
+ /** @brief Delete currently selected effect. */
+ void deleteCurrentEffect();
protected:
virtual void mouseMoveEvent(QMouseEvent * event);
virtual void mouseReleaseEvent(QMouseEvent * event);
+ virtual void resizeEvent ( QResizeEvent * event );
private:
Ui::EffectStack2_UI m_ui;
void slotClipItemSelected(ClipItem* c, int ix);
void slotTrackItemSelected(int ix, const TrackInfo info);
-
- /** @brief Removes the selected effect. */
- void slotItemDel();
+
+ /** @brief Check if the mouse wheel events should be used for scrolling the widget view. */
+ void slotCheckWheelEventFilter();
private slots:
/** @brief Remove effects from a group */
void slotUnGroup(CollapsibleEffect* group);
+ /** @brief Add en effect to selected clip */
void slotAddEffect(QDomElement effect);
+
+ /** @brief Enable / disable all effects for the clip */
+ void slotCheckAll(int state);
+
+ /** @brief Update check all button status */
+ void slotUpdateCheckAllButton();
signals:
void removeEffect(ClipItem*, int, QDomElement);