From 960999fb8d54a67f78b0007dad41826952ea4a5f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 16 Apr 2012 23:43:43 +0200 Subject: [PATCH] Hide/show up and down buttons only if required --- src/effectstack/collapsibleeffect.cpp | 24 ++++++++++++++++++++++-- src/effectstack/collapsibleeffect.h | 4 ++++ src/effectstack/collapsiblegroup.cpp | 7 +++++++ src/effectstack/collapsiblegroup.h | 2 ++ src/effectstack/effectstackview2.cpp | 7 +++++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/effectstack/collapsibleeffect.cpp b/src/effectstack/collapsibleeffect.cpp index 0fe942b1..dc5ff8c5 100644 --- a/src/effectstack/collapsibleeffect.cpp +++ b/src/effectstack/collapsibleeffect.cpp @@ -179,9 +179,10 @@ CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_ef else if (type == "custom") icon = KIcon("kdenlive-custom-effect"); else icon = KIcon("kdenlive-show-video"); effecticon->setPixmap(icon.pixmap(16,16));*/ - + m_groupAction = new QAction(KIcon("folder-new"), i18n("Create Group"), this); + connect(m_groupAction, SIGNAL(triggered(bool)), this, SLOT(slotCreateGroup())); if (!m_regionEffect) { - m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup())); + if (m_info.groupIndex == -1) m_menu->addAction(m_groupAction); m_menu->addAction(KIcon("folder-new"), i18n("Create Region"), this, SLOT(slotCreateRegion())); } setupWidget(info, metaInfo); @@ -480,6 +481,12 @@ void CollapsibleEffect::updateCollapsedState() void CollapsibleEffect::setGroupIndex(int ix) { + if (m_info.groupIndex == -1 && ix != -1) { + m_menu->removeAction(m_groupAction); + } + else if (m_info.groupIndex != -1 && ix == -1) { + m_menu->addAction(m_groupAction); + } m_info.groupIndex = ix; m_effect.setAttribute("kdenlive_info", m_info.toString()); } @@ -497,6 +504,9 @@ QString CollapsibleEffect::infoString() const void CollapsibleEffect::removeFromGroup() { + if (m_info.groupIndex != -1) { + m_menu->addAction(m_groupAction); + } m_info.groupIndex = -1; m_info.groupName.clear(); m_effect.setAttribute("kdenlive_info", m_info.toString()); @@ -683,6 +693,13 @@ void CollapsibleEffect::dropEvent(QDropEvent *event) event->accept(); } + +void CollapsibleEffect::adjustButtons(int ix, int max) +{ + buttonUp->setVisible(ix > 0); + buttonDown->setVisible(ix < max - 1); +} + ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent) : m_keyframeEditor(NULL), m_geometryWidget(NULL), @@ -1408,3 +1425,6 @@ void ParameterContainer::slotStartFilterJobAction() } } } + + + diff --git a/src/effectstack/collapsibleeffect.h b/src/effectstack/collapsibleeffect.h index b6766d7f..59cf5956 100644 --- a/src/effectstack/collapsibleeffect.h +++ b/src/effectstack/collapsibleeffect.h @@ -149,6 +149,8 @@ public: static const QString getStyleSheet(); /** @brief Parent group was collapsed, update. */ void groupStateChanged(bool collapsed); + /** @brief Show / hide up / down buttons. */ + void adjustButtons(int ix, int max); public slots: void slotSyncEffectsPos(int pos); @@ -182,6 +184,8 @@ private: EffectInfo m_info; /** @brief True if this is a region effect, which behaves in a special way, like a group. */ bool m_regionEffect; + /** @brief The add group action. */ + QAction *m_groupAction; /** @brief Check if collapsed state changed and inform MLT. */ void updateCollapsedState(); diff --git a/src/effectstack/collapsiblegroup.cpp b/src/effectstack/collapsiblegroup.cpp index 3d7b9297..aaf35b18 100644 --- a/src/effectstack/collapsiblegroup.cpp +++ b/src/effectstack/collapsiblegroup.cpp @@ -403,3 +403,10 @@ QDomDocument CollapsibleGroup::effectsData() return doc; } +void CollapsibleGroup::adjustEffects() +{ + for (int i = 0; i < m_subWidgets.count(); i++) { + m_subWidgets.at(i)->adjustButtons(i, m_subWidgets.count()); + } +} + diff --git a/src/effectstack/collapsiblegroup.h b/src/effectstack/collapsiblegroup.h index 703812d8..ed54c246 100644 --- a/src/effectstack/collapsiblegroup.h +++ b/src/effectstack/collapsiblegroup.h @@ -73,6 +73,8 @@ public: QWidget *title() const; /** @brief Return the XML data describing all effects in group. */ QDomDocument effectsData(); + /** @brief Adjust sub effects buttons. */ + void adjustEffects(); public slots: void slotEnable(bool enable); diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index 831e066e..993c0e06 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -224,6 +224,13 @@ void EffectStackView2::setupListView() } connectEffect(currentEffect); } + + // Adjust group effects (up / down buttons) + QList allGroups = m_ui.container->widget()->findChildren(); + for (int i = 0; i < allGroups.count(); i++) { + allGroups.at(i)->adjustEffects(); + } + vbox1->addStretch(10); slotUpdateCheckAllButton(); connect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int))); -- 2.39.2