]> git.sesse.net Git - kdenlive/commitdiff
Remember effect group state (collapsed)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 13 Apr 2012 19:01:47 +0000 (21:01 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 13 Apr 2012 19:01:47 +0000 (21:01 +0200)
src/definitions.h
src/effectstack/collapsibleeffect.cpp
src/effectstack/collapsibleeffect.h
src/effectstack/collapsiblegroup.cpp
src/effectstack/collapsiblegroup.h
src/effectstack/effectstackview2.cpp

index da7b3148037195b55dbcc0b90c2ae88aeeca8efb..0c521ce18df7546337f469136f7b954dac7138f2 100644 (file)
@@ -147,19 +147,25 @@ struct MltVideoProfile {
 class EffectInfo
 {
 public:
-    EffectInfo() {isCollapsed = false; groupIndex = -1;}
+    EffectInfo() {isCollapsed = false; groupIndex = -1; groupIsCollapsed = false;}
     bool isCollapsed;
+    bool groupIsCollapsed;
     int groupIndex;
     QString groupName;
     QString toString() const {
         QStringList data;
-       data << QString::number(isCollapsed) << QString::number(groupIndex) << groupName;
+       // effect collapsed state: 0 = effect not collapsed, 1 = effect collapsed, 
+       // 2 = group collapsed - effect not, 3 = group and effect collapsed
+       int collapsedState = (int) isCollapsed;
+       if (groupIsCollapsed) collapsedState += 2;
+       data << QString::number(collapsedState) << QString::number(groupIndex) << groupName;
        return data.join("/");
     }
     void fromString(QString value) {
        if (value.isEmpty()) return;
        QStringList data = value.split("/");
-       isCollapsed = data.at(0).toInt();
+       isCollapsed = data.at(0).toInt() == 1 || data.at(0).toInt() == 3;
+       groupIsCollapsed = data.at(0).toInt() == 3;
        if (data.count() > 1) groupIndex = data.at(1).toInt();
        if (data.count() > 2) groupName = data.at(2);
     }
index e8d1d82770f588fdae643888d65b0bfe5cd15307..b6a96ecfb6d8a627576afb2e99d359e3c48e1b94 100644 (file)
@@ -456,8 +456,22 @@ void CollapsibleEffect::slotShow(bool show)
         collapseButton->setArrowType(Qt::RightArrow);
         m_info.isCollapsed = true;
     }
-    m_effect.setAttribute("kdenlive_info", m_info.toString());
-    emit parameterChanged(m_original_effect, m_effect, effectIndex());   
+    updateCollapsedState();
+}
+
+void CollapsibleEffect::groupStateChanged(bool collapsed)
+{
+    m_info.groupIsCollapsed = collapsed;
+    updateCollapsedState();
+}
+
+void CollapsibleEffect::updateCollapsedState()
+{
+    QString info = m_info.toString();
+    if (info != m_effect.attribute("kdenlive_info")) {
+       m_effect.setAttribute("kdenlive_info", info);
+       emit parameterChanged(m_original_effect, m_effect, effectIndex());   
+    }
 }
 
 void CollapsibleEffect::setGroupIndex(int ix)
index 35bafcc53b60da952df23a9062674c70c6b26724..d0215c8690162f6ce3cde0f87c927a6dc4888be6 100644 (file)
@@ -144,9 +144,10 @@ public:
     bool isActive() const;
     /** @brief Should the wheel event be sent to parent widget for scrolling. */
     bool filterWheelEvent;
-    
     /** @brief Return the stylesheet required for effect parameters. */
     static const QString getStyleSheet();
+    /** @brief Parent group was collapsed, update. */
+    void groupStateChanged(bool collapsed);
 
 public slots:
     void slotSyncEffectsPos(int pos);
@@ -180,6 +181,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 Check if collapsed state changed and inform MLT. */
+    void updateCollapsedState();
     
 protected:
     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
index 7f89038f89503ba310603da0034bdef02b516da3..ab1152ea80af1155feed1117eb6e888758a72e65 100644 (file)
@@ -53,17 +53,18 @@ void MyEditableLabel::mouseDoubleClickEvent ( QMouseEvent * e )
 }
 
 
-CollapsibleGroup::CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, QString groupName, QWidget * parent) :
+CollapsibleGroup::CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, EffectInfo info, QWidget * parent) :
         AbstractCollapsibleWidget(parent),
         m_index(ix)
 {
     setupUi(this);
+    
     m_subWidgets = QList <CollapsibleEffect *> ();
     setFont(KGlobalSettings::smallestReadableFont());
     QHBoxLayout *l = static_cast <QHBoxLayout *>(framegroup->layout());
     m_title = new MyEditableLabel(this);
     l->insertWidget(3, m_title);
-    m_title->setText(groupName.isEmpty() ? i18n("Effect Group") : groupName);
+    m_title->setText(info.groupName.isEmpty() ? i18n("Effect Group") : info.groupName);
     connect(m_title, SIGNAL(editingFinished()), this, SLOT(slotRenameGroup()));
     buttonUp->setIcon(KIcon("kdenlive-up"));
     buttonUp->setToolTip(i18n("Move effect up"));
@@ -85,6 +86,10 @@ CollapsibleGroup::CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, QStr
     
     enabledButton->setChecked(false);
     enabledButton->setIcon(KIcon("visible"));
+    
+    if (info.groupIsCollapsed) {
+       slotShow(false);
+    }
 
     connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
     connect(enabledButton, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
@@ -208,13 +213,13 @@ void CollapsibleGroup::slotShow(bool show)
     widgetFrame->setVisible(show);
     if (show) {
         collapseButton->setArrowType(Qt::DownArrow);
-       m_info.isCollapsed = false;
+       m_info.groupIsCollapsed = false;
     }
     else {
         collapseButton->setArrowType(Qt::RightArrow);
-       m_info.isCollapsed = true;
+       m_info.groupIsCollapsed = true;
     }
-    //emit parameterChanged(m_original_effect, m_effect, effectIndex());   
+    if (!m_subWidgets.isEmpty()) m_subWidgets.at(0)->groupStateChanged(m_info.groupIsCollapsed);
 }
 
 QWidget *CollapsibleGroup::title() const
index bab2fe611e7c5f5581bea035993fe9d8c5eb94e5..b8e973dfc4143f62d1da5c62bfe797f1ea17de14 100644 (file)
@@ -59,7 +59,7 @@ class CollapsibleGroup : public AbstractCollapsibleWidget, public Ui::Collapsibl
     Q_OBJECT
 
 public:
-    CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, QString groupName = QString(), QWidget * parent = 0);
+    CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, EffectInfo info, QWidget * parent = 0);
     ~CollapsibleGroup();
     void updateTimecodeFormat();
     void setActive(bool activate);
index 22b9f91c1e10f8f4fb5ae361d1ed7ed2bbac84d9..79794738c84995b49371ce3c51801cea9a9200ca 100644 (file)
@@ -183,7 +183,7 @@ void EffectStackView2::setupListView()
            }
            
            if (group == NULL) {
-               group = new CollapsibleGroup(effectInfo.groupIndex, i == 0, i == m_currentEffectList.count() - 1, effectInfo.groupName, m_ui.container->widget());
+               group = new CollapsibleGroup(effectInfo.groupIndex, i == 0, i == m_currentEffectList.count() - 1, effectInfo, m_ui.container->widget());
                connect(group, SIGNAL(moveEffect(int,int,int,QString)), this, SLOT(slotMoveEffect(int,int,int,QString)));
                connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*)));
                connect(group, SIGNAL(groupRenamed(CollapsibleGroup *)), this, SLOT(slotRenameGroup(CollapsibleGroup*)));
@@ -719,7 +719,7 @@ void EffectStackView2::slotCreateGroup(int ix)
        }
     }
     
-    CollapsibleGroup *group = new CollapsibleGroup(m_groupIndex, ix == 1, ix == m_currentEffectList.count() - 2, QString(), m_ui.container->widget());
+    CollapsibleGroup *group = new CollapsibleGroup(m_groupIndex, ix == 1, ix == m_currentEffectList.count() - 2, effectinfo, m_ui.container->widget());
     m_groupIndex++;
     connect(group, SIGNAL(moveEffect(int,int,int,QString)), this , SLOT(slotMoveEffect(int,int,int,QString)));
     connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*)));
@@ -744,19 +744,22 @@ void EffectStackView2::slotMoveEffect(int currentIndex, int newIndex, int groupI
     effectinfo.groupIndex = groupIndex;
     effectinfo.groupName = groupName;
     neweffect.setAttribute("kdenlive_info", effectinfo.toString());
-
-    ItemInfo info;
-    if (m_effectMetaInfo.trackMode) { 
-       info.track = m_trackInfo.type;
-        info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
-        info.cropStart = GenTime(0);
-        info.startPos = GenTime(-1);
-        info.track = 0;
-       emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->effectIndex(),false);
-    } else {
-       emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->effectIndex(),false);
+    
+    if (oldeffect.attribute("kdenlive_info") != effectinfo.toString()) {
+       // effect's group info or collapsed state changed
+       ItemInfo info;
+       if (m_effectMetaInfo.trackMode) { 
+           info.track = m_trackInfo.type;
+           info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
+           info.cropStart = GenTime(0);
+           info.startPos = GenTime(-1);
+           info.track = 0;
+           emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->effectIndex(),false);
+       } else {
+           emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->effectIndex(),false);
+       }
     }
-    //if (currentIndex == newIndex) return;
+
     // Update effect index with new position
     if (m_effectMetaInfo.trackMode) {
        emit changeEffectPosition(NULL, m_trackindex, currentIndex, newIndex);
@@ -820,9 +823,10 @@ void EffectStackView2::dropEvent(QDropEvent *event)
            slotAddEffect(e);
            return;
        }
-       for (int i = 0; i < effects.count(); i++) {
+       // 
+       for (int i = effects.count() - 1; i >= 0; i--) {
            //TODO: not working because wee need to move all effects in one go
-           slotMoveEffect(effects.at(i).toElement().attribute("kdenlive_ix").toInt(), m_currentEffectList.count() + 1 + i, info.groupIndex, info.groupName);
+           slotMoveEffect(effects.at(i).toElement().attribute("kdenlive_ix").toInt(), m_currentEffectList.count(), info.groupIndex, info.groupName);
        }
     }
     else if (ix == 0) {