]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Progress on stopmotion widget (make it possible to switch between HDMI and V4L)
[kdenlive] / src / projectlist.cpp
index c88815744a048ff82b5afa46dd65ebbb4a080998..66cf7d752b6e7960c7f0f0bd12543d918ea7f879 100644 (file)
@@ -31,6 +31,8 @@
 #include "renderer.h"
 #include "kthumb.h"
 #include "projectlistview.h"
+#include "timecodedisplay.h"
+#include "profilesdialog.h"
 #include "editclipcommand.h"
 #include "editclipcutcommand.h"
 #include "editfoldercommand.h"
@@ -46,6 +48,7 @@
 #include <KMessageBox>
 #include <KIO/NetAccess>
 #include <KFileItem>
+#include <KApplication>
 #ifdef NEPOMUK
 #include <nepomuk/global.h>
 #include <nepomuk/resourcemanager.h>
 #include <QMenu>
 #include <QProcess>
 #include <QHeaderView>
+#include <QInputDialog>
 
 ProjectList::ProjectList(QWidget *parent) :
-        QWidget(parent),
-        m_render(NULL),
-        m_fps(-1),
-        m_commandStack(NULL),
-        m_editAction(NULL),
-        m_deleteAction(NULL),
-        m_openAction(NULL),
-        m_reloadAction(NULL),
-        m_transcodeAction(NULL),
-        m_doc(NULL),
-        m_refreshed(false),
-        m_infoQueue(),
-        m_thumbnailQueue()
-{
-
-    m_listView = new ProjectListView(this);;
+    QWidget(parent),
+    m_render(NULL),
+    m_fps(-1),
+    m_commandStack(NULL),
+    m_openAction(NULL),
+    m_reloadAction(NULL),
+    m_transcodeAction(NULL),
+    m_doc(NULL),
+    m_refreshed(false),
+    m_infoQueue(),
+    m_thumbnailQueue()
+{
     QVBoxLayout *layout = new QVBoxLayout;
     layout->setContentsMargins(0, 0, 0, 0);
     layout->setSpacing(0);
 
     // setup toolbar
-    KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine(this);
-    m_toolbar = new QToolBar("projectToolBar", this);
-    m_toolbar->addWidget(searchView);
-    int s = style()->pixelMetric(QStyle::PM_SmallIconSize);
-    m_toolbar->setIconSize(QSize(s, s));
-    searchView->setTreeWidget(m_listView);
+    QFrame *frame = new QFrame;
+    frame->setFrameStyle(QFrame::NoFrame);
+    QHBoxLayout *box = new QHBoxLayout;
+    KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine;
 
-    m_addButton = new QToolButton(m_toolbar);
+    box->addWidget(searchView);
+    //int s = style()->pixelMetric(QStyle::PM_SmallIconSize);
+    //m_toolbar->setIconSize(QSize(s, s));
+
+    m_addButton = new QToolButton;
     m_addButton->setPopupMode(QToolButton::MenuButtonPopup);
-    m_toolbar->addWidget(m_addButton);
+    m_addButton->setAutoRaise(true);
+    box->addWidget(m_addButton);
+
+    m_editButton = new QToolButton;
+    m_editButton->setAutoRaise(true);
+    box->addWidget(m_editButton);
 
-    layout->addWidget(m_toolbar);
+    m_deleteButton = new QToolButton;
+    m_deleteButton->setAutoRaise(true);
+    box->addWidget(m_deleteButton);
+    frame->setLayout(box);
+    layout->addWidget(frame);
+
+    m_listView = new ProjectListView;
     layout->addWidget(m_listView);
     setLayout(layout);
+    searchView->setTreeWidget(m_listView);
 
     m_queueTimer.setInterval(100);
     connect(&m_queueTimer, SIGNAL(timeout()), this, SLOT(slotProcessNextClipInQueue()));
@@ -129,7 +143,6 @@ ProjectList::ProjectList(QWidget *parent) :
 ProjectList::~ProjectList()
 {
     delete m_menu;
-    delete m_toolbar;
     m_listView->blockSignals(true);
     m_listView->clear();
     delete m_listViewDelegate;
@@ -145,13 +158,11 @@ void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
     QList <QAction *> actions = addMenu->actions();
     for (int i = 0; i < actions.count(); i++) {
         if (actions.at(i)->data().toString() == "clip_properties") {
-            m_editAction = actions.at(i);
-            m_toolbar->addAction(m_editAction);
+            m_editButton->setDefaultAction(actions.at(i));
             actions.removeAt(i);
             i--;
         } else if (actions.at(i)->data().toString() == "delete_clip") {
-            m_deleteAction = actions.at(i);
-            m_toolbar->addAction(m_deleteAction);
+            m_deleteButton->setDefaultAction(actions.at(i));
             actions.removeAt(i);
             i--;
         } else if (actions.at(i)->data().toString() == "edit_clip") {
@@ -175,23 +186,26 @@ void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
 
 void ProjectList::setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu, QMenu *inTimelineMenu)
 {
-    if (!addMenu) return;
+    if (!addMenu)
+        return;
     QMenu *menu = m_addButton->menu();
     menu->addMenu(addMenu);
     m_addButton->setMenu(menu);
 
     m_menu->addMenu(addMenu);
-    if (addMenu->isEmpty()) addMenu->setEnabled(false);
+    if (addMenu->isEmpty())
+        addMenu->setEnabled(false);
     m_menu->addMenu(transcodeMenu);
-    if (transcodeMenu->isEmpty()) transcodeMenu->setEnabled(false);
+    if (transcodeMenu->isEmpty())
+        transcodeMenu->setEnabled(false);
     m_transcodeAction = transcodeMenu;
     m_menu->addAction(m_reloadAction);
     m_menu->addMenu(inTimelineMenu);
     inTimelineMenu->setEnabled(false);
-    m_menu->addAction(m_editAction);
+    m_menu->addAction(m_editButton->defaultAction());
     m_menu->addAction(m_openAction);
-    m_menu->addAction(m_deleteAction);
-    m_menu->insertSeparator(m_deleteAction);
+    m_menu->addAction(m_deleteButton->defaultAction());
+    m_menu->insertSeparator(m_deleteButton->defaultAction());
 }
 
 
@@ -218,12 +232,13 @@ void ProjectList::slotEditClip()
         return;
     }
     ProjectItem *item;
-    if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE) return;
-    if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
+    if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE)
+        return;
+    if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE)
         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
-    } else item = static_cast <ProjectItem*>(m_listView->currentItem());
-    if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
-    if (item) {
+    else
+        item = static_cast <ProjectItem*>(m_listView->currentItem());
+    if (item && (item->flags() & Qt::ItemIsDragEnabled)) {
         emit clipSelected(item->referencedClip());
         emit showClipProperties(item->referencedClip());
     }
@@ -240,30 +255,33 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
     commonproperties.insert("threads", "-");
     commonproperties.insert("video_index", "-");
     commonproperties.insert("audio_index", "-");
+    commonproperties.insert("force_colorspace", "-");
+    commonproperties.insert("full_luma", "-");
 
     bool allowDurationChange = true;
     int commonDuration = -1;
     ProjectItem *item;
     for (int i = 0; i < list.count(); i++) {
         item = NULL;
-        if (list.at(i)->type() == PROJECTFOLDERTYPE) continue;
-        if (list.at(i)->type() == PROJECTSUBCLIPTYPE) {
+        if (list.at(i)->type() == PROJECTFOLDERTYPE)
+            continue;
+        if (list.at(i)->type() == PROJECTSUBCLIPTYPE)
             item = static_cast <ProjectItem*>(list.at(i)->parent());
-        } else item = static_cast <ProjectItem*>(list.at(i));
-        if (!(item->flags() & Qt::ItemIsDragEnabled)) continue;
+        else
+            item = static_cast <ProjectItem*>(list.at(i));
+        if (!(item->flags() & Qt::ItemIsDragEnabled))
+            continue;
         if (item) {
             // check properties
             DocClipBase *clip = item->referencedClip();
             if (clipList.contains(clip)) continue;
-            if (clip->clipType() != COLOR && clip->clipType() != IMAGE && clip->clipType() != TEXT) {
+            if (clip->clipType() != COLOR && clip->clipType() != IMAGE && clip->clipType() != TEXT)
                 allowDurationChange = false;
-            }
             if (allowDurationChange && commonDuration != 0) {
-                if (commonDuration == -1) {
+                if (commonDuration == -1)
                     commonDuration = clip->duration().frames(m_fps);
-                } else if (commonDuration != clip->duration().frames(m_fps)) {
+                else if (commonDuration != clip->duration().frames(m_fps))
                     commonDuration = 0;
-                }
             }
             clipList.append(clip);
             QMap <QString, QString> clipprops = clip->properties();
@@ -272,13 +290,18 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
                 p.next();
                 if (p.value().isEmpty()) continue;
                 if (clipprops.contains(p.key())) {
-                    if (p.value() == "-") commonproperties.insert(p.key(), clipprops.value(p.key()));
-                    else if (p.value() != clipprops.value(p.key())) commonproperties.insert(p.key(), QString());
-                } else commonproperties.insert(p.key(), QString());
+                    if (p.value() == "-")
+                        commonproperties.insert(p.key(), clipprops.value(p.key()));
+                    else if (p.value() != clipprops.value(p.key()))
+                        commonproperties.insert(p.key(), QString());
+                } else {
+                    commonproperties.insert(p.key(), QString());
+                }
             }
         }
     }
-    if (allowDurationChange) commonproperties.insert("out", QString::number(commonDuration));
+    if (allowDurationChange)
+        commonproperties.insert("out", QString::number(commonDuration));
     QMapIterator<QString, QString> p(commonproperties);
     while (p.hasNext()) {
         p.next();
@@ -290,18 +313,24 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
 void ProjectList::slotOpenClip()
 {
     ProjectItem *item;
-    if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE) return;
-    if (m_listView->currentItem()->type() == QTreeWidgetItem::UserType + 1) {
+    if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE)
+        return;
+    if (m_listView->currentItem()->type() == QTreeWidgetItem::UserType + 1)
         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
-    } else item = static_cast <ProjectItem*>(m_listView->currentItem());
+    else
+        item = static_cast <ProjectItem*>(m_listView->currentItem());
     if (item) {
         if (item->clipType() == IMAGE) {
-            if (KdenliveSettings::defaultimageapp().isEmpty()) KMessageBox::sorry(this, i18n("Please set a default application to open images in the Settings dialog"));
-            else QProcess::startDetached(KdenliveSettings::defaultimageapp(), QStringList() << item->clipUrl().path());
+            if (KdenliveSettings::defaultimageapp().isEmpty())
+                KMessageBox::sorry(kapp->activeWindow(), i18n("Please set a default application to open images in the Settings dialog"));
+            else
+                QProcess::startDetached(KdenliveSettings::defaultimageapp(), QStringList() << item->clipUrl().path());
         }
         if (item->clipType() == AUDIO) {
-            if (KdenliveSettings::defaultaudioapp().isEmpty()) KMessageBox::sorry(this, i18n("Please set a default application to open audio files in the Settings dialog"));
-            else QProcess::startDetached(KdenliveSettings::defaultaudioapp(), QStringList() << item->clipUrl().path());
+            if (KdenliveSettings::defaultaudioapp().isEmpty())
+                KMessageBox::sorry(kapp->activeWindow(), i18n("Please set a default application to open audio files in the Settings dialog"));
+            else
+                QProcess::startDetached(KdenliveSettings::defaultaudioapp(), QStringList() << item->clipUrl().path());
         }
     }
 }
@@ -317,7 +346,8 @@ void ProjectList::cleanup()
             continue;
         }
         item = static_cast <ProjectItem *>(*it);
-        if (item->numReferences() == 0) item->setSelected(true);
+        if (item->numReferences() == 0)
+            item->setSelected(true);
         it++;
     }
     slotRemoveClip();
@@ -338,7 +368,8 @@ void ProjectList::trashUnusedClips()
         if (item->numReferences() == 0) {
             ids << item->clipId();
             KUrl url = item->clipUrl();
-            if (!url.isEmpty() && !urls.contains(url.path())) urls << url.path();
+            if (!url.isEmpty() && !urls.contains(url.path()))
+                urls << url.path();
         }
         it++;
     }
@@ -359,16 +390,17 @@ void ProjectList::trashUnusedClips()
     }
 
     emit deleteProjectClips(ids, QMap <QString, QString>());
-    for (int i = 0; i < urls.count(); i++) {
+    for (int i = 0; i < urls.count(); i++)
         KIO::NetAccess::del(KUrl(urls.at(i)), this);
-    }
 }
 
 void ProjectList::slotReloadClip(const QString &id)
 {
     QList<QTreeWidgetItem *> selected;
-    if (id.isEmpty()) selected = m_listView->selectedItems();
-    else selected.append(getItemById(id));
+    if (id.isEmpty())
+        selected = m_listView->selectedItems();
+    else
+        selected.append(getItemById(id));
     ProjectItem *item;
     for (int i = 0; i < selected.count(); i++) {
         if (selected.at(i)->type() != PROJECTCLIPTYPE) {
@@ -381,7 +413,8 @@ void ProjectList::slotReloadClip(const QString &id)
         item = static_cast <ProjectItem *>(selected.at(i));
         if (item) {
             if (item->clipType() == TEXT) {
-                if (!item->referencedClip()->getProperty("xmltemplate").isEmpty()) regenerateTemplate(item);
+                if (!item->referencedClip()->getProperty("xmltemplate").isEmpty())
+                    regenerateTemplate(item);
             } else if (item->clipType() != COLOR && item->clipType() != SLIDESHOW && item->referencedClip() &&  item->referencedClip()->checkHash() == false) {
                 item->referencedClip()->setPlaceHolder(true);
                 item->setProperty("file_hash", QString());
@@ -405,7 +438,9 @@ void ProjectList::slotModifiedClip(const QString &id)
             p.fillRect(0, 0, pixmap.width(), pixmap.height(), QColor(255, 255, 255, 200));
             p.drawPixmap(0, 0, KIcon("view-refresh").pixmap(m_listView->iconSize()));
             p.end();
-        } else pixmap = KIcon("view-refresh").pixmap(m_listView->iconSize());
+        } else {
+            pixmap = KIcon("view-refresh").pixmap(m_listView->iconSize());
+        }
         item->setData(0, Qt::DecorationRole, pixmap);
     }
 }
@@ -414,7 +449,7 @@ void ProjectList::slotMissingClip(const QString &id)
 {
     ProjectItem *item = getItemById(id);
     if (item) {
-        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
         if (item->referencedClip()) {
             item->referencedClip()->setPlaceHolder(true);
             if (m_render == NULL) kDebug() << "*********  ERROR, NULL RENDR";
@@ -431,8 +466,9 @@ void ProjectList::slotMissingClip(const QString &id)
 void ProjectList::slotAvailableClip(const QString &id)
 {
     ProjectItem *item = getItemById(id);
-    if (item == NULL) return;
-    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+    if (item == NULL)
+        return;
+    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
     if (item->referencedClip()) { // && item->referencedClip()->checkHash() == false) {
         item->setProperty("file_hash", QString());
         slotReloadClip(id);
@@ -471,8 +507,8 @@ void ProjectList::slotClipSelected()
     if (m_listView->currentItem()) {
         if (m_listView->currentItem()->type() == PROJECTFOLDERTYPE) {
             emit clipSelected(NULL);
-            m_editAction->setEnabled(false);
-            m_deleteAction->setEnabled(true);
+            m_editButton->defaultAction()->setEnabled(false);
+            m_deleteButton->defaultAction()->setEnabled(true);
             m_openAction->setEnabled(false);
             m_reloadAction->setEnabled(false);
             m_transcodeAction->setEnabled(false);
@@ -480,7 +516,7 @@ void ProjectList::slotClipSelected()
             ProjectItem *clip;
             if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
                 // this is a sub item, use base clip
-                m_deleteAction->setEnabled(true);
+                m_deleteButton->defaultAction()->setEnabled(true);
                 clip = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
                 if (clip == NULL) kDebug() << "-----------ERROR";
                 SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
@@ -489,9 +525,10 @@ void ProjectList::slotClipSelected()
                 return;
             }
             clip = static_cast <ProjectItem*>(m_listView->currentItem());
-            if (clip) emit clipSelected(clip->referencedClip());
-            m_editAction->setEnabled(true);
-            m_deleteAction->setEnabled(true);
+            if (clip)
+                emit clipSelected(clip->referencedClip());
+            m_editButton->defaultAction()->setEnabled(true);
+            m_deleteButton->defaultAction()->setEnabled(true);
             m_reloadAction->setEnabled(true);
             m_transcodeAction->setEnabled(true);
             if (clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
@@ -500,7 +537,9 @@ void ProjectList::slotClipSelected()
             } else if (clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
                 m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
                 m_openAction->setEnabled(true);
-            } else m_openAction->setEnabled(false);
+            } else {
+                m_openAction->setEnabled(false);
+            }
             // Display relevant transcoding actions only
             adjustTranscodeActions(clip);
             // Display uses in timeline
@@ -508,8 +547,8 @@ void ProjectList::slotClipSelected()
         }
     } else {
         emit clipSelected(NULL);
-        m_editAction->setEnabled(false);
-        m_deleteAction->setEnabled(false);
+        m_editButton->defaultAction()->setEnabled(false);
+        m_deleteButton->defaultAction()->setEnabled(false);
         m_openAction->setEnabled(false);
         m_reloadAction->setEnabled(false);
         m_transcodeAction->setEnabled(false);
@@ -530,8 +569,10 @@ void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
         data = transcodeActions.at(i)->data().toStringList();
         if (data.count() > 2) {
             condition = data.at(2);
-            if (condition.startsWith("vcodec")) transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
-            else if (condition.startsWith("acodec")) transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
+            if (condition.startsWith("vcodec"))
+                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section('=', 1, 1)));
+            else if (condition.startsWith("acodec"))
+                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section('=', 1, 1)));
         }
     }
 
@@ -539,7 +580,8 @@ void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
 
 void ProjectList::slotPauseMonitor()
 {
-    if (m_render) m_render->pause();
+    if (m_render)
+        m_render->pause();
 }
 
 void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QString> properties)
@@ -547,18 +589,21 @@ void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QSt
     ProjectItem *item = getItemById(id);
     if (item) {
         slotUpdateClipProperties(item, properties);
-        if (properties.contains("out") || properties.contains("force_fps")) {
+        if (properties.contains("out") || properties.contains("force_fps") || properties.contains("resource")) {
             slotReloadClip(id);
-        } else if (properties.contains("colour") || properties.contains("resource") || properties.contains("xmldata") || properties.contains("force_aspect_ratio") || properties.contains("templatetext")) {
+        } else if (properties.contains("colour") || properties.contains("xmldata") || properties.contains("force_aspect_ratio") || properties.contains("templatetext")) {
             slotRefreshClipThumbnail(item);
             emit refreshClip();
+        } else if (properties.contains("full_luma") || properties.contains("force_colorspace")) {
+            emit refreshClip();
         }
     }
 }
 
 void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties)
 {
-    if (!clip) return;
+    if (!clip)
+        return;
     clip->setProperties(properties);
     if (properties.contains("name")) {
         m_listView->blockSignals(true);
@@ -597,15 +642,16 @@ void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column)
         return;
     }
     if (item->type() == PROJECTFOLDERTYPE) {
-        if (column != 0) return;
-        FolderProjectItem *folder = static_cast <FolderProjectItem*>(item);
-        editFolder(item->text(0), folder->groupName(), folder->clipId());
-        folder->setGroupName(item->text(0));
-        m_doc->clipManager()->addFolder(folder->clipId(), item->text(0));
-        const int children = item->childCount();
-        for (int i = 0; i < children; i++) {
-            ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
-            child->setProperty("groupname", item->text(0));
+        if (column == 0) {
+            FolderProjectItem *folder = static_cast <FolderProjectItem*>(item);
+            editFolder(item->text(0), folder->groupName(), folder->clipId());
+            folder->setGroupName(item->text(0));
+            m_doc->clipManager()->addFolder(folder->clipId(), item->text(0));
+            const int children = item->childCount();
+            for (int i = 0; i < children; i++) {
+                ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+                child->setProperty("groupname", item->text(0));
+            }
         }
         return;
     }
@@ -645,12 +691,9 @@ void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column)
 
 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item)
 {
-    bool enable = false;
-    if (item) {
-        enable = true;
-    }
-    m_editAction->setEnabled(enable);
-    m_deleteAction->setEnabled(enable);
+    bool enable = item ? true : false;
+    m_editButton->defaultAction()->setEnabled(enable);
+    m_deleteButton->defaultAction()->setEnabled(enable);
     m_reloadAction->setEnabled(enable);
     m_transcodeAction->setEnabled(enable);
     if (enable) {
@@ -664,22 +707,29 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item)
             adjustTranscodeActions(clip);
             // Display uses in timeline
             emit findInTimeline(clip->clipId());
-        } else m_transcodeAction->setEnabled(false);
+        } else {
+            m_transcodeAction->setEnabled(false);
+        }
         if (clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
             m_openAction->setEnabled(true);
         } else if (clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
             m_openAction->setEnabled(true);
-        } else m_openAction->setEnabled(false);
+        } else {
+            m_openAction->setEnabled(false);
+        }
 
-    } else m_openAction->setEnabled(false);
+    } else {
+        m_openAction->setEnabled(false);
+    }
     m_menu->popup(pos);
 }
 
 void ProjectList::slotRemoveClip()
 {
-    if (!m_listView->currentItem()) return;
+    if (!m_listView->currentItem())
+        return;
     QStringList ids;
     QMap <QString, QString> folderids;
     QList<QTreeWidgetItem *> selected = m_listView->selectedItems();
@@ -699,7 +749,8 @@ void ProjectList::slotRemoveClip()
             folderids[folder->groupName()] = folder->clipId();
             int children = folder->childCount();
 
-            if (children > 0 && KMessageBox::questionYesNo(this, i18np("Delete folder <b>%2</b>?<br />This will also remove the clip in that folder", "Delete folder <b>%2</b>?<br />This will also remove the %1 clips in that folder",  children, folder->text(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
+            if (children > 0 && KMessageBox::questionYesNo(kapp->activeWindow(), i18np("Delete folder <b>%2</b>?<br />This will also remove the clip in that folder", "Delete folder <b>%2</b>?<br />This will also remove the %1 clips in that folder",  children, folder->text(1)), i18n("Delete Folder")) != KMessageBox::Yes)
+                return;
             for (int i = 0; i < children; ++i) {
                 ProjectItem *child = static_cast <ProjectItem *>(folder->child(i));
                 ids << child->clipId();
@@ -707,27 +758,29 @@ void ProjectList::slotRemoveClip()
         } else {
             ProjectItem *item = static_cast <ProjectItem *>(selected.at(i));
             ids << item->clipId();
-            if (item->numReferences() > 0) {
-                if (KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b>?<br />This will also remove the clip in timeline", "Delete clip <b>%2</b>?<br />This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
-            }
+            if (item->numReferences() > 0 && KMessageBox::questionYesNo(kapp->activeWindow(), i18np("Delete clip <b>%2</b>?<br />This will also remove the clip in timeline", "Delete clip <b>%2</b>?<br />This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes)
+                return;
         }
     }
 
-    if (delCommand->childCount() == 0) delete delCommand;
-    else m_commandStack->push(delCommand);
+    if (delCommand->childCount() == 0)
+        delete delCommand;
+    else
+        m_commandStack->push(delCommand);
     emit deleteProjectClips(ids, folderids);
 }
 
 void ProjectList::updateButtons() const
 {
     if (m_listView->topLevelItemCount() == 0) {
-        m_deleteAction->setEnabled(false);
+        m_deleteButton->defaultAction()->setEnabled(false);
     } else {
-        m_deleteAction->setEnabled(true);
-        if (!m_listView->currentItem()) m_listView->setCurrentItem(m_listView->topLevelItem(0));
+        m_deleteButton->defaultAction()->setEnabled(true);
+        if (!m_listView->currentItem())
+            m_listView->setCurrentItem(m_listView->topLevelItem(0));
         QTreeWidgetItem *item = m_listView->currentItem();
         if (item && item->type() == PROJECTCLIPTYPE) {
-            m_editAction->setEnabled(true);
+            m_editButton->defaultAction()->setEnabled(true);
             m_openAction->setEnabled(true);
             m_reloadAction->setEnabled(true);
             m_transcodeAction->setEnabled(true);
@@ -735,7 +788,7 @@ void ProjectList::updateButtons() const
         }
     }
 
-    m_editAction->setEnabled(false);
+    m_editButton->defaultAction()->setEnabled(false);
     m_openAction->setEnabled(false);
     m_reloadAction->setEnabled(false);
     m_transcodeAction->setEnabled(false);
@@ -744,7 +797,8 @@ void ProjectList::updateButtons() const
 void ProjectList::selectItemById(const QString &clipId)
 {
     ProjectItem *item = getItemById(clipId);
-    if (item) m_listView->setCurrentItem(item);
+    if (item)
+        m_listView->setCurrentItem(item);
 }
 
 
@@ -757,7 +811,8 @@ void ProjectList::slotDeleteClip(const QString &clipId)
     }
     m_listView->blockSignals(true);
     QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
-    if (!newSelectedItem) newSelectedItem = m_listView->itemBelow(item);
+    if (!newSelectedItem)
+        newSelectedItem = m_listView->itemBelow(item);
     delete item;
     m_doc->clipManager()->deleteClip(clipId);
     m_listView->blockSignals(false);
@@ -790,10 +845,13 @@ void ProjectList::slotAddFolder(const QString foldername, const QString &clipId,
         if (item) {
             m_doc->clipManager()->deleteFolder(clipId);
             QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
-            if (!newSelectedItem) newSelectedItem = m_listView->itemBelow(item);
+            if (!newSelectedItem)
+                newSelectedItem = m_listView->itemBelow(item);
             delete item;
-            if (newSelectedItem) m_listView->setCurrentItem(newSelectedItem);
-            else updateButtons();
+            if (newSelectedItem)
+                m_listView->setCurrentItem(newSelectedItem);
+            else
+                updateButtons();
         }
     } else {
         if (edit) {
@@ -859,19 +917,21 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
             if (groupName.isEmpty()) groupName = i18n("Folder");
             text << groupName;
             parentitem = new FolderProjectItem(m_listView, text, parent);
-        } else {
-            //kDebug() << "Adding clip to existing group: " << parentitem->groupName();
         }
-        if (parentitem) item = new ProjectItem(parentitem, clip);
+
+        if (parentitem)
+            item = new ProjectItem(parentitem, clip);
     }
-    if (item == NULL) item = new ProjectItem(m_listView, clip);
+    if (item == NULL)
+        item = new ProjectItem(m_listView, clip);
     KUrl url = clip->fileURL();
 
     if (getProperties == false && !clip->getClipHash().isEmpty()) {
         QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png";
         if (QFile::exists(cachedPixmap)) {
             QPixmap pix(cachedPixmap);
-            if (pix.isNull()) KIO::NetAccess::del(KUrl(cachedPixmap), this);
+            if (pix.isNull())
+                KIO::NetAccess::del(KUrl(cachedPixmap), this);
             item->setData(0, Qt::DecorationRole, pix);
         }
     }
@@ -893,7 +953,8 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
                 QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).zone.x()) + ".png";
                 if (QFile::exists(cachedPixmap)) {
                     QPixmap pix(cachedPixmap);
-                    if (pix.isNull()) KIO::NetAccess::del(KUrl(cachedPixmap), this);
+                    if (pix.isNull())
+                        KIO::NetAccess::del(KUrl(cachedPixmap), this);
                     sub->setData(0, Qt::DecorationRole, pix);
                 }
             }
@@ -901,9 +962,11 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     }
     if (m_listView->isEnabled()) {
         updateButtons();
-        if (getProperties) m_listView->blockSignals(false);
+        if (getProperties)
+            m_listView->blockSignals(false);
     }
-    if (getProperties && !m_queueTimer.isActive()) m_queueTimer.start();
+    if (getProperties && !m_queueTimer.isActive())
+        slotProcessNextClipInQueue();
 }
 
 void ProjectList::slotResetProjectList()
@@ -936,6 +999,7 @@ void ProjectList::slotProcessNextClipInQueue()
         m_infoQueue.remove(j.key());
         emit getFileProperties(dom, id, m_listView->iconSize().height(), false);
     }
+    if (!m_infoQueue.isEmpty()) m_queueTimer.start();
 }
 
 void ProjectList::slotUpdateClip(const QString &id)
@@ -973,55 +1037,102 @@ void ProjectList::updateAllClips()
             item = static_cast <ProjectItem *>(*it);
             clip = item->referencedClip();
             if (item->referencedClip()->producer() == NULL) {
-                if (clip->isPlaceHolder() == false) {
+                if (clip->isPlaceHolder() == false)
                     requestClipInfo(clip->toXML(), clip->getId());
-                } else if (!clip->isPlaceHolder()) item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+                else if (!clip->isPlaceHolder())
+                    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
             } else {
-                if (item->data(0, Qt::DecorationRole).isNull()) {
+                if (item->data(0, Qt::DecorationRole).isNull())
                     requestClipThumbnail(clip->getId());
-                }
-                if (item->data(0, DurationRole).toString().isEmpty()) {
+                if (item->data(0, DurationRole).toString().isEmpty())
                     item->changeDuration(item->referencedClip()->producer()->get_playtime());
-                }
             }
             item->setData(0, UsageRole, QString::number(item->numReferences()));
         }
         //qApp->processEvents();
         ++it;
     }
-    if (!m_queueTimer.isActive()) m_queueTimer.start();
-    if (m_listView->isEnabled()) m_listView->blockSignals(false);
+    if (!m_queueTimer.isActive())
+        m_queueTimer.start();
+    if (m_listView->isEnabled())
+        m_listView->blockSignals(false);
     m_listView->setSortingEnabled(true);
-    if (m_infoQueue.isEmpty()) slotProcessNextThumbnail();
+    if (m_infoQueue.isEmpty())
+        slotProcessNextThumbnail();
+}
+
+// static
+QString ProjectList::getExtensions()
+{
+    // Build list of mime types
+    QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"
+                            << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime"
+                            << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg" << "application/mxf"
+                            << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
+
+    QString allExtensions;
+    foreach(const QString & mimeType, mimeTypes) {
+        KMimeType::Ptr mime(KMimeType::mimeType(mimeType));
+        if (mime) {
+            allExtensions.append(mime->patterns().join(" "));
+            allExtensions.append(' ');
+        }
+    }
+    return allExtensions.simplified();
 }
 
 void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &groupName, const QString &groupId)
 {
-    if (!m_commandStack) {
+    if (!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
     KUrl::List list;
     if (givenList.isEmpty()) {
-        // Build list of mime types
-        QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mlt-playlist" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg" << "video/mp4" << "video/quicktime" << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
-
-        QString allExtensions;
-        foreach(const QString& mimeType, mimeTypes) {
-            KMimeType::Ptr mime(KMimeType::mimeType(mimeType));
-            if (mime) {
-                allExtensions.append(mime->patterns().join(" "));
-                allExtensions.append(' ');
+        QString allExtensions = getExtensions();
+        const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
+        QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
+        b->setChecked(KdenliveSettings::autoimagesequence());
+        KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), b);
+        d->setOperationMode(KFileDialog::Opening);
+        d->setMode(KFile::Files);
+        d->exec();
+        list = d->selectedUrls();
+        if (b->isChecked() && list.count() == 1) {
+            // Check for image sequence
+            KUrl url = list.at(0);
+            QString fileName = url.fileName().section('.', 0, -2);
+            if (fileName.at(fileName.size() - 1).isDigit()) {
+                KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
+                if (item.mimetype().startsWith("image")) {
+                    // import as sequence if we found more than one image in the sequence
+                    QStringList list;
+                    QString pattern = SlideshowClip::selectedPath(url.path(), false, QString(), &list);
+                    int count = list.count();
+                    if (count > 1) {
+                        delete d;
+                        QStringList groupInfo = getGroup();
+
+                        // get image sequence base name
+                        while (fileName.at(fileName.size() - 1).isDigit()) {
+                            fileName.chop(1);
+                        }
+
+                        m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()),
+                                                           false, false, false,
+                                                           m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0,
+                                                           QString(), groupInfo.at(0), groupInfo.at(1));
+                        return;
+                    }
+                }
             }
         }
-        const QString dialogFilter = allExtensions.simplified() + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
-        list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), dialogFilter, this);
-
+        delete d;
     } else {
         for (int i = 0; i < givenList.count(); i++)
             list << givenList.at(i);
     }
 
-    foreach(const KUrl &file, list) {
+    foreach(const KUrl & file, list) {
         // Check there is no folder here
         KMimeType::Ptr type = KMimeType::findByUrl(file);
         if (type->is("inode/directory")) {
@@ -1030,12 +1141,15 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
         }
     }
 
-    if (list.isEmpty()) return;
+    if (list.isEmpty())
+        return;
 
     if (givenList.isEmpty()) {
         QStringList groupInfo = getGroup();
         m_doc->slotAddClipList(list, groupInfo.at(0), groupInfo.at(1));
-    } else m_doc->slotAddClipList(list, groupName, groupId);
+    } else {
+        m_doc->slotAddClipList(list, groupName, groupId);
+    }
 }
 
 void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
@@ -1046,50 +1160,58 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
         const QString path = item->referencedClip()->fileURL().path();
         if (item->referencedClip()->isPlaceHolder()) replace = false;
         if (!path.isEmpty()) {
-            if (replace) KMessageBox::sorry(this, i18n("Clip <b>%1</b><br />is invalid, will be removed from project.", path));
-            else {
-                if (KMessageBox::questionYesNo(this, i18n("Clip <b>%1</b><br />is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes) replace = true;
-            }
+            if (replace)
+                KMessageBox::sorry(kapp->activeWindow(), i18n("Clip <b>%1</b><br />is invalid, will be removed from project.", path));
+            else if (KMessageBox::questionYesNo(kapp->activeWindow(), i18n("Clip <b>%1</b><br />is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes)
+                replace = true;
         }
-        QStringList ids;
-        ids << id;
-        if (replace) emit deleteProjectClips(ids, QMap <QString, QString>());
+        if (replace)
+            emit deleteProjectClips(QStringList() << id, QMap <QString, QString>());
     }
 }
 
 void ProjectList::slotAddColorClip()
 {
-    if (!m_commandStack) {
+    if (!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
     QDialog *dia = new QDialog(this);
     Ui::ColorClip_UI dia_ui;
     dia_ui.setupUi(dia);
     dia->setWindowTitle(i18n("Color Clip"));
     dia_ui.clip_name->setText(i18n("Color Clip"));
-    dia_ui.clip_duration->setInputMask("");
-    dia_ui.clip_duration->setValidator(m_timecode.validator());
-    dia_ui.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::color_duration()));
+
+    TimecodeDisplay *t = new TimecodeDisplay(m_timecode);
+    t->setValue(KdenliveSettings::color_duration());
+    t->setTimeCodeFormat(false);
+    dia_ui.clip_durationBox->addWidget(t);
+    dia_ui.clip_color->setColor(KdenliveSettings::colorclipcolor());
+
     if (dia->exec() == QDialog::Accepted) {
         QString color = dia_ui.clip_color->color().name();
+        KdenliveSettings::setColorclipcolor(color);
         color = color.replace(0, 1, "0x") + "ff";
         QStringList groupInfo = getGroup();
-        m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, dia_ui.clip_duration->text(), groupInfo.at(0), groupInfo.at(1));
+        m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, m_timecode.getTimecode(t->gentime()), groupInfo.at(0), groupInfo.at(1));
     }
+    delete t;
     delete dia;
 }
 
 
 void ProjectList::slotAddSlideshowClip()
 {
-    if (!m_commandStack) {
+    if (!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
     SlideshowClip *dia = new SlideshowClip(m_timecode, this);
 
     if (dia->exec() == QDialog::Accepted) {
         QStringList groupInfo = getGroup();
-        m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), groupInfo.at(0), groupInfo.at(1));
+        m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(),
+                                           dia->loop(), dia->crop(), dia->fade(),
+                                           dia->lumaDuration(), dia->lumaFile(), dia->softness(),
+                                           dia->animation(), groupInfo.at(0), groupInfo.at(1));
     }
     delete dia;
 }
@@ -1102,10 +1224,10 @@ void ProjectList::slotAddTitleClip()
 
 void ProjectList::slotAddTitleTemplateClip()
 {
-    QStringList groupInfo = getGroup();
-    if (!m_commandStack) {
+    if (!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
+    QStringList groupInfo = getGroup();
 
     // Get the list of existing templates
     QStringList filter;
@@ -1116,12 +1238,12 @@ void ProjectList::slotAddTitleTemplateClip()
     QDialog *dia = new QDialog(this);
     Ui::TemplateClip_UI dia_ui;
     dia_ui.setupUi(dia);
-    for (int i = 0; i < templateFiles.size(); ++i) {
+    for (int i = 0; i < templateFiles.size(); ++i)
         dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), path + templateFiles.at(i));
-    }
+
     if (!templateFiles.isEmpty())
         dia_ui.buttonBox->button(QDialogButtonBox::Ok)->setFocus();
-    dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
+    dia_ui.template_list->fileDialog()->setFilter("application/x-kdenlivetitle");
     //warning: setting base directory doesn't work??
     KUrl startDir(path);
     dia_ui.template_list->fileDialog()->setUrl(startDir);
@@ -1139,15 +1261,15 @@ QStringList ProjectList::getGroup() const
 {
     QStringList result;
     QTreeWidgetItem *item = m_listView->currentItem();
-    while (item && item->type() != PROJECTFOLDERTYPE) {
+    while (item && item->type() != PROJECTFOLDERTYPE)
         item = item->parent();
-    }
 
     if (item) {
         FolderProjectItem *folder = static_cast <FolderProjectItem *>(item);
-        result << folder->groupName();
-        result << folder->clipId();
-    } else result << QString() << QString();
+        result << folder->groupName() << folder->clipId();
+    } else {
+        result << QString() << QString();
+    }
     return result;
 }
 
@@ -1173,12 +1295,10 @@ void ProjectList::setDocument(KdenliveDoc *doc)
     }
 
     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
-    for (int i = 0; i < list.count(); i++) {
+    for (int i = 0; i < list.count(); i++)
         slotAddClip(list.at(i), false);
-    }
 
     m_listView->blockSignals(false);
-    m_toolbar->setEnabled(true);
     connect(m_doc->clipManager(), SIGNAL(reloadClip(const QString &)), this, SLOT(slotReloadClip(const QString &)));
     connect(m_doc->clipManager(), SIGNAL(modifiedClip(const QString &)), this, SLOT(slotModifiedClip(const QString &)));
     connect(m_doc->clipManager(), SIGNAL(missingClip(const QString &)), this, SLOT(slotMissingClip(const QString &)));
@@ -1188,7 +1308,9 @@ void ProjectList::setDocument(KdenliveDoc *doc)
 
 QList <DocClipBase*> ProjectList::documentClipList() const
 {
-    if (m_doc == NULL) return QList <DocClipBase*> ();
+    if (m_doc == NULL)
+        return QList <DocClipBase*> ();
+
     return m_doc->clipManager()->documentClipList();
 }
 
@@ -1197,7 +1319,7 @@ QDomElement ProjectList::producersList()
     QDomDocument doc;
     QDomElement prods = doc.createElement("producerlist");
     doc.appendChild(prods);
-    kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
+    kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
     QTreeWidgetItemIterator it(m_listView);
     while (*it) {
         if ((*it)->type() != PROJECTCLIPTYPE) {
@@ -1220,7 +1342,9 @@ void ProjectList::slotCheckForEmptyQueue()
         m_listView->blockSignals(false);
         m_listView->setEnabled(true);
         updateButtons();
-    } else if (!m_refreshed) QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
+    } else if (!m_refreshed) {
+        QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
+    }
 }
 
 void ProjectList::reloadClipThumbnails()
@@ -1265,8 +1389,10 @@ void ProjectList::slotProcessNextThumbnail()
 void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update)
 {
     QTreeWidgetItem *item = getAnyItemById(clipId);
-    if (item) slotRefreshClipThumbnail(item, update);
-    else slotProcessNextThumbnail();
+    if (item)
+        slotRefreshClipThumbnail(item, update);
+    else
+        slotProcessNextThumbnail();
 }
 
 void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
@@ -1294,18 +1420,25 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
         QPixmap pix;
         int height = m_listView->iconSize().height();
         int width = (int)(height  * m_render->dar());
-        if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
-        else if (clip->clipType() == IMAGE) pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height));
-        else pix = item->referencedClip()->thumbProducer()->extractImage(frame, width, height);
+        if (clip->clipType() == AUDIO)
+            pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
+        else if (clip->clipType() == IMAGE)
+            pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height));
+        else
+            pix = item->referencedClip()->thumbProducer()->extractImage(frame, width, height);
 
         if (!pix.isNull()) {
             m_listView->blockSignals(true);
             it->setData(0, Qt::DecorationRole, pix);
-            if (m_listView->isEnabled()) m_listView->blockSignals(false);
-            if (!isSubItem) m_doc->cachePixmap(item->getClipHash(), pix);
-            else m_doc->cachePixmap(item->getClipHash() + '#' + QString::number(frame), pix);
+            if (m_listView->isEnabled())
+                m_listView->blockSignals(false);
+            if (!isSubItem)
+                m_doc->cachePixmap(item->getClipHash(), pix);
+            else
+                m_doc->cachePixmap(item->getClipHash() + '#' + QString::number(frame), pix);
         }
-        if (update) emit projectModified();
+        if (update)
+            emit projectModified();
         QTimer::singleShot(30, this, SLOT(slotProcessNextThumbnail()));
     }
 }
@@ -1319,19 +1452,17 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         item->setProperties(properties, metadata);
         if (item->referencedClip()->isPlaceHolder() && producer->is_valid()) {
             item->referencedClip()->setValid();
-            item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+            item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
             toReload = clipId;
         }
         //Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
         item->referencedClip()->setProducer(producer, replace);
         item->referencedClip()->askForAudioThumbs();
-        if (!replace && item->data(0, Qt::DecorationRole).isNull()) {
+        if (!replace && item->data(0, Qt::DecorationRole).isNull())
             requestClipThumbnail(clipId);
-        }
-        if (!toReload.isEmpty()) {
+        if (!toReload.isEmpty())
             item->slotSetToolTip();
 
-        }
         //emit receivedClipDuration(clipId);
         if (m_listView->isEnabled() && replace) {
             // update clip in clip monitor
@@ -1345,7 +1476,8 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             emit receivedClipDuration(clipId);
             delete producer;
         }*/
-        if (m_listView->isEnabled()) m_listView->blockSignals(false);
+        if (m_listView->isEnabled())
+            m_listView->blockSignals(false);
         /*if (item->icon(0).isNull()) {
             requestClipThumbnail(clipId);
         }*/
@@ -1353,13 +1485,81 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     int max = m_doc->clipManager()->clipsCount();
     if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
         m_listView->setCurrentItem(item);
-        emit clipSelected(item->referencedClip());
-    } else emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
-    if (!toReload.isEmpty()) emit clipNeedsReload(toReload, true);
+        bool updatedProfile = false;
+        if (item->parent()) {
+            if (item->parent()->type() == PROJECTFOLDERTYPE)
+                static_cast <FolderProjectItem *>(item->parent())->switchIcon();
+        } else if (KdenliveSettings::checkfirstprojectclip() &&  m_listView->topLevelItemCount() == 1) {
+            // this is the first clip loaded in project, check if we want to adjust project settings to the clip
+            updatedProfile = adjustProjectProfileToItem(item);
+        }
+        if (updatedProfile == false) emit clipSelected(item->referencedClip());
+    } else {
+        emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
+    }
+    if (!toReload.isEmpty())
+        emit clipNeedsReload(toReload, true);
     // small delay so that the app can display the progress info
     QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
 }
 
+bool ProjectList::adjustProjectProfileToItem(ProjectItem *item)
+{
+    if (item == NULL) {
+        if (m_listView->currentItem() && m_listView->currentItem()->type() != PROJECTFOLDERTYPE)
+            item = static_cast <ProjectItem*>(m_listView->currentItem());
+    }
+    if (item == NULL || item->referencedClip() == NULL) {
+        KMessageBox::information(kapp->activeWindow(), i18n("Cannot find profile from current clip"));
+        return false;
+    }
+    bool profileUpdated = false;
+    QString size = item->referencedClip()->getProperty("frame_size");
+    int width = size.section('x', 0, 0).toInt();
+    int height = size.section('x', -1).toInt();
+    double fps = item->referencedClip()->getProperty("fps").toDouble();
+    double par = item->referencedClip()->getProperty("aspect_ratio").toDouble();
+    if (item->clipType() == IMAGE || item->clipType() == AV || item->clipType() == VIDEO) {
+        if (ProfilesDialog::matchProfile(width, height, fps, par, item->clipType() == IMAGE, m_doc->mltProfile()) == false) {
+            // get a list of compatible profiles
+            QMap <QString, QString> suggestedProfiles = ProfilesDialog::getProfilesFromProperties(width, height, fps, par, item->clipType() == IMAGE);
+            if (!suggestedProfiles.isEmpty()) {
+                KDialog *dialog = new KDialog(this);
+                dialog->setCaption(i18n("Change project profile"));
+                dialog->setButtons(KDialog::Ok | KDialog::Cancel);
+
+                QWidget container;
+                QVBoxLayout *l = new QVBoxLayout;
+                QLabel *label = new QLabel(i18n("Your clip does not match current project's profile.\nDo you want to change the project profile?\n\nThe following profiles match the clip (size: %1, fps: %2)", size, fps));
+                l->addWidget(label);
+                QListWidget *list = new QListWidget;
+                list->setAlternatingRowColors(true);
+                QMapIterator<QString, QString> i(suggestedProfiles);
+                while (i.hasNext()) {
+                    i.next();
+                    QListWidgetItem *item = new QListWidgetItem(i.value(), list);
+                    item->setData(Qt::UserRole, i.key());
+                    item->setToolTip(i.key());
+                }
+                list->setCurrentRow(0);
+                l->addWidget(list);
+                container.setLayout(l);
+                dialog->setButtonText(KDialog::Ok, i18n("Update profile"));
+                dialog->setMainWidget(&container);
+                if (dialog->exec() == QDialog::Accepted) {
+                    //Change project profile
+                    profileUpdated = true;
+                    if (list->currentItem())
+                        emit updateProfile(list->currentItem()->data(Qt::UserRole).toString());
+                }
+                delete list;
+                delete label;
+            } else KMessageBox::information(kapp->activeWindow(), i18n("Your clip does not match current project's profile.\nNo existing profile found to match the clip's properties.\nClip size: %1\nFps: %2\n", size, fps));
+        }
+    }
+    return profileUpdated;
+}
+
 void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
 {
     ProjectItem *item = getItemById(clipId);
@@ -1367,7 +1567,8 @@ void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
         m_listView->blockSignals(true);
         item->setData(0, Qt::DecorationRole, pix);
         m_doc->cachePixmap(item->getClipHash(), pix);
-        if (m_listView->isEnabled()) m_listView->blockSignals(false);
+        if (m_listView->isEnabled())
+            m_listView->blockSignals(false);
     }
 }
 
@@ -1375,9 +1576,8 @@ QTreeWidgetItem *ProjectList::getAnyItemById(const QString &id)
 {
     QTreeWidgetItemIterator it(m_listView);
     QString lookId = id;
-    if (id.contains('#')) {
+    if (id.contains('#'))
         lookId = id.section('#', 0, 0);
-    }
 
     ProjectItem *result = NULL;
     while (*it) {
@@ -1393,13 +1593,15 @@ QTreeWidgetItem *ProjectList::getAnyItemById(const QString &id)
         }
         ++it;
     }
-    if (result == NULL || !id.contains('#')) return result;
-    else for (int i = 0; i < result->childCount(); i++) {
+    if (result == NULL || !id.contains('#')) {
+        return result;
+    } else {
+        for (int i = 0; i < result->childCount(); i++) {
             SubProjectItem *sub = static_cast <SubProjectItem *>(result->child(i));
-            if (sub && sub->zone().x() == id.section('#', 1, 1).toInt()) {
+            if (sub && sub->zone().x() == id.section('#', 1, 1).toInt())
                 return sub;
-            }
         }
+    }
 
     return NULL;
 }
@@ -1430,7 +1632,8 @@ FolderProjectItem *ProjectList::getFolderItemById(const QString &id)
     while (*it) {
         if ((*it)->type() == PROJECTFOLDERTYPE) {
             item = static_cast<FolderProjectItem *>(*it);
-            if (item->clipId() == id) return item;
+            if (item->clipId() == id)
+                return item;
         }
         ++it;
     }
@@ -1443,8 +1646,8 @@ void ProjectList::slotSelectClip(const QString &ix)
     if (clip) {
         m_listView->setCurrentItem(clip);
         m_listView->scrollToItem(clip);
-        m_editAction->setEnabled(true);
-        m_deleteAction->setEnabled(true);
+        m_editButton->defaultAction()->setEnabled(true);
+        m_deleteButton->defaultAction()->setEnabled(true);
         m_reloadAction->setEnabled(true);
         m_transcodeAction->setEnabled(true);
         if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
@@ -1453,7 +1656,9 @@ void ProjectList::slotSelectClip(const QString &ix)
         } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
             m_openAction->setEnabled(true);
-        } else m_openAction->setEnabled(false);
+        } else {
+            m_openAction->setEnabled(false);
+        }
     }
 }
 
@@ -1464,8 +1669,11 @@ QString ProjectList::currentClipUrl() const
     if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
         // subitem
         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
-    } else item = static_cast <ProjectItem*>(m_listView->currentItem());
-    if (item == NULL) return QString();
+    } else {
+        item = static_cast <ProjectItem*>(m_listView->currentItem());
+    }
+    if (item == NULL)
+        return QString();
     return item->clipUrl().path();
 }
 
@@ -1475,17 +1683,22 @@ KUrl::List ProjectList::getConditionalUrls(const QString &condition) const
     ProjectItem *item;
     QList<QTreeWidgetItem *> list = m_listView->selectedItems();
     for (int i = 0; i < list.count(); i++) {
-        if (list.at(i)->type() == PROJECTFOLDERTYPE) continue;
+        if (list.at(i)->type() == PROJECTFOLDERTYPE)
+            continue;
         if (list.at(i)->type() == PROJECTSUBCLIPTYPE) {
             // subitem
             item = static_cast <ProjectItem*>(list.at(i)->parent());
-        } else item = static_cast <ProjectItem*>(list.at(i));
-        if (item == NULL) continue;
-        if (item->type() == COLOR || item->type() == SLIDESHOW || item->type() == TEXT) continue;
+        } else {
+            item = static_cast <ProjectItem*>(list.at(i));
+        }
+        if (item == NULL || item->type() == COLOR || item->type() == SLIDESHOW || item->type() == TEXT)
+            continue;
         DocClipBase *clip = item->referencedClip();
         if (!condition.isEmpty()) {
-            if (condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section("=", 1, 1))) continue;
-            else if (condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section("=", 1, 1))) continue;
+            if (condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section('=', 1, 1)))
+                continue;
+            else if (condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section('=', 1, 1)))
+                continue;
         }
         result.append(item->clipUrl());
     }
@@ -1495,7 +1708,8 @@ KUrl::List ProjectList::getConditionalUrls(const QString &condition) const
 void ProjectList::regenerateTemplate(const QString &id)
 {
     ProjectItem *clip = getItemById(id);
-    if (clip) regenerateTemplate(clip);
+    if (clip)
+        regenerateTemplate(clip);
 }
 
 void ProjectList::regenerateTemplate(ProjectItem *clip)
@@ -1531,8 +1745,8 @@ QDomDocument ProjectList::generateTemplateXml(QString path, const QString &repla
 void ProjectList::slotAddClipCut(const QString &id, int in, int out)
 {
     ProjectItem *clip = getItemById(id);
-    if (clip == NULL) return;
-    if (clip->referencedClip()->hasCutZone(QPoint(in, out))) return;
+    if (clip == NULL || clip->referencedClip()->hasCutZone(QPoint(in, out)))
+        return;
     AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, QString(), true, false);
     m_commandStack->push(command);
 }
@@ -1546,7 +1760,8 @@ void ProjectList::addClipCut(const QString &id, int in, int out, const QString d
         m_listView->blockSignals(true);
         SubProjectItem *sub = new SubProjectItem(clip, in, out, desc);
         if (newItem && desc.isEmpty() && !m_listView->isColumnHidden(1)) {
-            if (!clip->isExpanded()) clip->setExpanded(true);
+            if (!clip->isExpanded())
+                clip->setExpanded(true);
             m_listView->scrollToItem(sub);
             m_listView->editItem(sub, 1);
         }
@@ -1582,8 +1797,10 @@ SubProjectItem *ProjectList::getSubItem(ProjectItem *clip, QPoint zone)
             QTreeWidgetItem *it = clip->child(i);
             if (it->type() == PROJECTSUBCLIPTYPE) {
                 sub = static_cast <SubProjectItem*>(it);
-                if (sub->zone() == zone) break;
-                else sub = NULL;
+                if (sub->zone() == zone)
+                    break;
+                else
+                    sub = NULL;
             }
         }
     }
@@ -1592,7 +1809,8 @@ SubProjectItem *ProjectList::getSubItem(ProjectItem *clip, QPoint zone)
 
 void ProjectList::slotUpdateClipCut(QPoint p)
 {
-    if (!m_listView->currentItem() || m_listView->currentItem()->type() != PROJECTSUBCLIPTYPE) return;
+    if (!m_listView->currentItem() || m_listView->currentItem()->type() != PROJECTSUBCLIPTYPE)
+        return;
     SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
     ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
     EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), p, sub->text(1), sub->text(1), true);
@@ -1603,7 +1821,8 @@ void ProjectList::doUpdateClipCut(const QString &id, const QPoint oldzone, const
 {
     ProjectItem *clip = getItemById(id);
     SubProjectItem *sub = getSubItem(clip, oldzone);
-    if (sub == NULL || clip == NULL) return;
+    if (sub == NULL || clip == NULL)
+        return;
     DocClipBase *base = clip->referencedClip();
     base->updateCutZone(oldzone.x(), oldzone.y(), zone.x(), zone.y(), comment);
     m_listView->blockSignals(true);
@@ -1613,4 +1832,42 @@ void ProjectList::doUpdateClipCut(const QString &id, const QPoint oldzone, const
     emit projectModified();
 }
 
+void ProjectList::slotForceProcessing(const QString &id)
+{
+    while (m_infoQueue.contains(id)) {
+        slotProcessNextClipInQueue();
+    }
+}
+
+void ProjectList::slotAddOrUpdateSequence(const QString frameName)
+{
+    QString fileName = KUrl(frameName).fileName().section('_', 0, -2);
+    QStringList list;
+    QString pattern = SlideshowClip::selectedPath(frameName, false, QString(), &list);
+    int count = list.count();
+    if (count > 1) {
+        const QList <DocClipBase *> existing = m_doc->clipManager()->getClipByResource(pattern);
+        if (!existing.isEmpty()) {
+            // Sequence already exists, update
+            QString id = existing.at(0)->getId();
+            //ProjectItem *item = getItemById(id);
+            QMap <QString, QString> oldprops;
+            QMap <QString, QString> newprops;
+            int ttl = existing.at(0)->getProperty("ttl").toInt();
+            oldprops["out"] = existing.at(0)->getProperty("out");
+            newprops["out"] = QString::number(ttl * count - 1);
+            slotUpdateClipProperties(id, newprops);
+            EditClipCommand *command = new EditClipCommand(this, id, oldprops, newprops, false);
+            m_commandStack->push(command);
+        } else {
+            // Create sequence
+            QStringList groupInfo = getGroup();
+            m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()),
+                                               false, false, false,
+                                               m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0,
+                                               QString(), groupInfo.at(0), groupInfo.at(1));
+        }
+    } else emit displayMessage(i18n("Sequence not found"), -2);
+}
+
 #include "projectlist.moc"