]> git.sesse.net Git - kdenlive/blobdiff - src/effectslistview.cpp
Improve the export audio automatic setting:
[kdenlive] / src / effectslistview.cpp
index 9769ac355d36a61ffb7cebd0fa6b90b22e1e08d6..9e1dd726cbc6e4709a02ef738bf357c107312bcc 100644 (file)
@@ -41,12 +41,18 @@ EffectsListView::EffectsListView(QWidget *parent) :
     lyr->addWidget(m_effectsList);
     lyr->setContentsMargins(0, 0, 0, 0);
     search_effect->setTreeWidget(m_effectsList);
+    search_effect->setToolTip(i18n("Search in the effect list"));
     buttonInfo->setIcon(KIcon("help-about"));
+    buttonInfo->setToolTip(i18n("Show/Hide the effect description"));
     setFocusPolicy(Qt::StrongFocus);
+    setFocusProxy(search_effect);
+    m_effectsList->setFocusProxy(search_effect);
 
-    if (KdenliveSettings::showeffectinfo()) {
+    if (KdenliveSettings::showeffectinfo())
         buttonInfo->setDown(true);
-    } else infopanel->hide();
+    else
+        infopanel->hide();
+
     menu->addAction(KIcon("edit-delete"), i18n("Delete effect"), this, SLOT(slotRemoveEffect()));
 
     connect(type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterList(int)));
@@ -54,15 +60,10 @@ EffectsListView::EffectsListView(QWidget *parent) :
     connect(m_effectsList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
     connect(m_effectsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotEffectSelected()));
     connect(search_effect, SIGNAL(hiddenChanged(QTreeWidgetItem *, bool)), this, SLOT(slotUpdateSearch(QTreeWidgetItem *, bool)));
+    connect(search_effect, SIGNAL(textChanged(QString)), this, SLOT(slotAutoExpand(QString)));
     //m_effectsList->setCurrentRow(0);
 }
 
-
-void EffectsListView::focusInEvent(QFocusEvent * /*event*/)
-{
-    search_effect->setFocus();
-}
-
 void EffectsListView::filterList(int pos)
 {
     for (int i = 0; i < m_effectsList->topLevelItemCount(); i++) {
@@ -85,6 +86,7 @@ void EffectsListView::filterList(int pos)
     // make sure we don't show anything not matching the search expression
     search_effect->updateSearch();
 
+
     /*item = m_effectsList->currentItem();
     if (item) {
         if (item->isHidden()) {
@@ -97,21 +99,17 @@ void EffectsListView::filterList(int pos)
 
 void EffectsListView::showInfoPanel()
 {
-    if (infopanel->isVisible()) {
-        infopanel->setVisible(false);
-        buttonInfo->setDown(false);
-        KdenliveSettings::setShoweffectinfo(false);
-    } else {
-        infopanel->setVisible(true);
-        buttonInfo->setDown(true);
-        KdenliveSettings::setShoweffectinfo(true);
-    }
+    bool show = !infopanel->isVisible();
+    infopanel->setVisible(show);
+    buttonInfo->setDown(show);
+    KdenliveSettings::setShoweffectinfo(show);
 }
 
 void EffectsListView::slotEffectSelected()
 {
     QDomElement effect = m_effectsList->currentEffect();
-    if (!effect.isNull()) emit addEffect(effect);
+    if (!effect.isNull())
+        emit addEffect(effect);
 }
 
 void EffectsListView::slotUpdateInfo()
@@ -159,7 +157,8 @@ void EffectsListView::slotUpdateSearch(QTreeWidgetItem *item, bool hidden)
 {
     if (!hidden) {
         if (item->data(0, Qt::UserRole).toInt() == type_combo->currentIndex()) {
-            item->parent()->setHidden(false);
+            if (item->parent())
+                item->parent()->setHidden(false);
         } else {
             if (type_combo->currentIndex() != 0)
                 item->setHidden(true);
@@ -167,4 +166,24 @@ void EffectsListView::slotUpdateSearch(QTreeWidgetItem *item, bool hidden)
     }
 }
 
+void EffectsListView::slotAutoExpand(QString text)
+{
+    search_effect->updateSearch();
+
+    for (int i = 0; i < m_effectsList->topLevelItemCount(); ++i) {
+        QTreeWidgetItem *folder = m_effectsList->topLevelItem(i);
+        bool expandFolder = false;
+        /*if (folder->isHidden())
+            continue;*/
+        if (!text.isEmpty()) {
+            for (int j = 0; j < folder->childCount(); j++) {
+                QTreeWidgetItem *item = folder->child(j);
+                if (!item->isHidden())
+                    expandFolder = true;
+            }
+        }
+        folder->setExpanded(expandFolder);
+    }
+}
+
 #include "effectslistview.moc"