From: Jean-Baptiste Mardelle Date: Mon, 26 Mar 2012 12:19:07 +0000 (+0200) Subject: Effect stack: mouse wheel changes parameter when no scrolling is possible X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f43b9b5cd63600898402f0c693801a7afff9dfc0;p=kdenlive Effect stack: mouse wheel changes parameter when no scrolling is possible --- diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 58a2d1b1..e60c8365 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1842,7 +1842,7 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) clip->setSelected(true); } clip->setSelectedEffect(clip->effectsCount() - 1); - emit clipItemSelected(clip, clip->selectedEffectIndex()); + //emit clipItemSelected(clip, clip->selectedEffectIndex()); break; } } diff --git a/src/effectstack/collapsibleeffect.cpp b/src/effectstack/collapsibleeffect.cpp index 5e459c29..4d49f10d 100644 --- a/src/effectstack/collapsibleeffect.cpp +++ b/src/effectstack/collapsibleeffect.cpp @@ -128,6 +128,7 @@ CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_ef { //setMouseTracking(true); setupUi(this); + filterWheelEvent = true; m_info.fromString(effect.attribute("kdenlive_info")); frame->setBackgroundRole(QPalette::Midlight); frame->setAutoFillBackground(true); @@ -225,7 +226,7 @@ bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e ) { if (e->type() == QEvent::Wheel) { QWheelEvent *we = static_cast(e); - if (we->modifiers() != Qt::NoModifier) { + if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) { e->accept(); return false; } @@ -274,6 +275,11 @@ QDomElement CollapsibleEffect::effect() const return m_effect; } +bool CollapsibleEffect::isActive() const +{ + return m_active; +} + void CollapsibleEffect::setActive(bool activate, bool focused) { m_active = activate; @@ -314,6 +320,9 @@ void CollapsibleEffect::leaveEvent ( QEvent * event ) void CollapsibleEffect::slotEnable(bool enable) { title->setEnabled(enable); + enabledBox->blockSignals(true); + enabledBox->setChecked(enable); + enabledBox->blockSignals(false); if (m_isGroup) { QVBoxLayout *vbox = static_cast(widgetFrame->layout()); if (vbox == NULL) return; diff --git a/src/effectstack/collapsibleeffect.h b/src/effectstack/collapsibleeffect.h index 5b7df1cb..d58cd555 100644 --- a/src/effectstack/collapsibleeffect.h +++ b/src/effectstack/collapsibleeffect.h @@ -131,13 +131,16 @@ public: void setGroupIndex(int ix); void removeGroup(int ix, QVBoxLayout *layout); QString infoString() const; + bool isActive() const; + /** @brief Should the wheel event be sent to parent widget for scrolling. */ + bool filterWheelEvent; public slots: void slotSyncEffectsPos(int pos); + void slotEnable(bool enable); private slots: void slotSwitch(); - void slotEnable(bool enable); void slotShow(bool show); void slotDeleteEffect(); void slotEffectUp(); diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index 4aa4d4ef..c65e1565 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -38,6 +38,7 @@ #include #include #include +#include EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) : @@ -56,6 +57,8 @@ 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); @@ -91,11 +94,6 @@ void EffectStackView2::slotRenderPos(int pos) 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; @@ -113,6 +111,7 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix) 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(); @@ -150,8 +149,6 @@ void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info) void EffectStackView2::setupListView(int ix) { - //TODO: clear list - blockSignals(true); m_draggedEffect = NULL; disconnect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int))); @@ -164,6 +161,7 @@ void EffectStackView2::setupListView(int ix) 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); @@ -180,10 +178,9 @@ void EffectStackView2::setupListView(int ix) EffectInfo effectInfo; effectInfo.fromString(d.attribute("kdenlive_info")); if (effectInfo.groupIndex >= 0) { - for (int j = 0; j < vbox1->count(); j++) { - CollapsibleEffect *gp = static_cast(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; } } @@ -242,6 +239,30 @@ void EffectStackView2::setupListView(int ix) } 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 ) @@ -317,6 +338,7 @@ void EffectStackView2::slotUpdateEffectState(bool disable, int index) emit changeEffectState(NULL, m_trackindex, index, disable); else emit changeEffectState(m_clipref, -1, index, disable); + slotUpdateCheckAllButton(); } @@ -367,18 +389,61 @@ void EffectStackView2::clear() } 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() @@ -406,6 +471,7 @@ void EffectStackView2::slotUpdateEffectParams(const QDomElement old, const QDomE // Make sure the changed effect is currently displayed slotSetCurrentEffect(ix); } + QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter())); } void EffectStackView2::slotSetCurrentEffect(int ix) @@ -515,14 +581,12 @@ void EffectStackView2::slotCreateGroup(int ix) QVBoxLayout *l = static_cast(m_ui.container->widget()->layout()); int groupPos = 0; - CollapsibleEffect *effectToMove = NULL; - for (int j = 0; j < l->count(); j++) { - CollapsibleEffect *gp = static_cast(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; } } diff --git a/src/effectstack/effectstackview2.h b/src/effectstack/effectstackview2.h index 2f7a6ba3..ae966bb7 100644 --- a/src/effectstack/effectstackview2.h +++ b/src/effectstack/effectstackview2.h @@ -45,10 +45,6 @@ public: /** @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; @@ -66,10 +62,14 @@ public: 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; @@ -109,9 +109,9 @@ public slots: 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: @@ -162,7 +162,14 @@ 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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5f6db6c7..6e48f3db 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -520,8 +520,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *))); connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *))); - m_effectStack->setMenu(m_effectsMenu); - QMenu *viewMenu = static_cast(factory()->container("dockwindows", this)); const QList viewActions = createPopupMenu()->actions(); viewMenu->insertActions(NULL, viewActions); @@ -2741,7 +2739,7 @@ void MainWindow::slotDeleteItem() QWidget *widget = QApplication::focusWidget(); while (widget) { if (widget == m_effectStackDock) { - m_effectStack->slotItemDel(); + m_effectStack->deleteCurrentEffect(); return; } widget = widget->parentWidget();