]> git.sesse.net Git - kdenlive/blobdiff - src/effectstack/collapsibleeffect.cpp
Hide/show up and down buttons only if required
[kdenlive] / src / effectstack / collapsibleeffect.cpp
index 0fe942b14a16a8cce8b1ce2fcdf7a40fa0c61cf9..dc5ff8c506c70ac3f649d5418960a749b4025e99 100644 (file)
@@ -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()
         }
     }
 }
+
+
+