summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-10-10 13:58:07 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-10-10 13:58:07 (GMT)
commite20ef96051d98d0caf615c4dae0c40875b9c521a (patch)
treefc58d57edb123c46b940fd68b2544173c9ed7097
parentdece85bd3d6d7b4d612dd86a1b3db353fb62ccb9 (diff)
Library widget: accept drops from Project Bin and Clip monitor
-rw-r--r--src/bin/bin.cpp11
-rw-r--r--src/bin/bin.h4
-rw-r--r--src/library/librarywidget.cpp41
-rw-r--r--src/library/librarywidget.h2
-rw-r--r--src/mltcontroller/clipcontroller.cpp17
-rw-r--r--src/mltcontroller/clipcontroller.h3
-rw-r--r--src/project/projectmanager.cpp4
-rw-r--r--src/project/projectmanager.h1
8 files changed, 77 insertions, 6 deletions
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 8c6bd4f..20a4516 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -3554,3 +3554,14 @@ void Bin::showClearButton(bool show)
m_searchLine->setClearButtonEnabled(show);
}
+void Bin::saveZone(QStringList info, QDir dir)
+{
+ if (info.size() != 3) {
+ return;
+ }
+ ProjectClip *clip = getBinClip(info.first());
+ if (clip && clip->controller()) {
+ QPoint zone(info.at(1).toInt(), info.at(2).toInt());
+ clip->controller()->saveZone(zone, dir);
+ }
+}
diff --git a/src/bin/bin.h b/src/bin/bin.h
index 1d830ed..0a3c489 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -531,8 +531,10 @@ public:
void rebuildProxies();
/** @brief Return a list of all clips hashes used in this project */
QStringList getProxyHashList();
- /** @brief Get info (id, name) of a folder (or the currently selected one) */
+ /** @brief Get info (id, name) of a folder (or the currently selected one) */
const QStringList getFolderInfo(QModelIndex selectedIx = QModelIndex());
+ /** @brief Save a clip zone as MLT playlist */
+ void saveZone(QStringList info, QDir dir);
private slots:
void slotAddClip();
diff --git a/src/library/librarywidget.cpp b/src/library/librarywidget.cpp
index 229f0f5..392e8b1 100644
--- a/src/library/librarywidget.cpp
+++ b/src/library/librarywidget.cpp
@@ -74,7 +74,7 @@ QMimeData * LibraryTree::mimeData(const QList<QTreeWidgetItem *> list) const
QStringList LibraryTree::mimeTypes() const
{
- return QStringList() << QString("text/uri-list");;
+ return QStringList() << QStringLiteral("text/uri-list") << QStringLiteral("kdenlive/clip") << QStringLiteral("kdenlive/producerslist");
}
void LibraryTree::slotUpdateThumb(const QString &path, const QString &iconPath)
@@ -130,10 +130,8 @@ void LibraryTree::mousePressEvent(QMouseEvent * event)
void LibraryTree::dropEvent(QDropEvent *event)
{
- const QMimeData* qMimeData = event->mimeData();
- if (!qMimeData->hasUrls()) return;
//QTreeWidget::dropEvent(event);
- QList <QUrl> urls = qMimeData->urls();
+ const QMimeData* qMimeData = event->mimeData();
QTreeWidgetItem *dropped = this->itemAt(event->pos());
QString dest;
if (dropped) {
@@ -142,8 +140,28 @@ void LibraryTree::dropEvent(QDropEvent *event)
dest = QUrl::fromLocalFile(dest).adjusted(QUrl::RemoveFilename).path();
}
}
+ if (qMimeData->hasUrls()) {
+ QList <QUrl> urls = qMimeData->urls();
+ emit moveData(urls, dest);
+ } else if (qMimeData->hasFormat(QStringLiteral("kdenlive/clip"))) {
+ emit importSequence(QString(qMimeData->data(QStringLiteral("kdenlive/clip"))).split(';'), dest);
+ } else if (qMimeData->hasFormat(QStringLiteral("kdenlive/producerslist"))) {
+ QStringList list = QString(qMimeData->data(QStringLiteral("kdenlive/producerslist"))).split(';');
+ foreach(QString data, list) {
+ if (data.startsWith(QLatin1Char('#'))) {
+ // Bin folder, not supported yet
+ continue;
+ }
+ if (data.contains(QLatin1Char('/'))) {
+ // Clip zone
+ emit importSequence(data.split(QLatin1Char('/')), dest);
+ } else {
+ // Full clip
+ emit importSequence(QStringList() << data << QStringLiteral("-1") << QStringLiteral("-1"), dest);
+ }
+ }
+ }
event->accept();
- emit moveData(urls, dest);
}
@@ -198,6 +216,7 @@ LibraryWidget::LibraryWidget(ProjectManager *manager, QWidget *parent) : QWidget
m_timer.setInterval(4000);
connect(&m_timer, &QTimer::timeout, m_infoWidget, &KMessageWidget::animatedHide);
connect(m_libraryTree, &LibraryTree::moveData, this, &LibraryWidget::slotMoveData);
+ connect(m_libraryTree, &LibraryTree::importSequence, this, &LibraryWidget::slotSaveSequence);
m_coreLister = new KCoreDirLister(this);
m_coreLister->setDelayedMimeTypes(false);
@@ -398,6 +417,18 @@ void LibraryWidget::slotMoveData(QList <QUrl> urls, QString dest)
}
}
+void LibraryWidget::slotSaveSequence(QStringList info, QString dest)
+{
+ if (info.isEmpty()) return;
+ if (dest .isEmpty()) {
+ // moving to library's root
+ dest = m_directory.absolutePath();
+ }
+ QDir dir(dest);
+ if (!dir.exists()) return;
+ m_manager->saveZone(info, dir);
+}
+
void LibraryWidget::slotItemEdited(QTreeWidgetItem *item, int column)
{
if (!item || column != 0) return;
diff --git a/src/library/librarywidget.h b/src/library/librarywidget.h
index f5002c6..8f39932 100644
--- a/src/library/librarywidget.h
+++ b/src/library/librarywidget.h
@@ -155,6 +155,7 @@ public slots:
signals:
void moveData(QList <QUrl>, QString);
+ void importSequence(QStringList, QString);
};
@@ -177,6 +178,7 @@ private slots:
void slotAddFolder();
void slotRenameItem();
void slotMoveData(QList <QUrl>, QString);
+ void slotSaveSequence(QStringList info, QString dest);
void slotItemEdited(QTreeWidgetItem *item, int column);
void slotDownloadFinished(KJob *);
void slotDownloadProgress(KJob *, unsigned long);
diff --git a/src/mltcontroller/clipcontroller.cpp b/src/mltcontroller/clipcontroller.cpp
index 3f08f39..8177d9a 100644
--- a/src/mltcontroller/clipcontroller.cpp
+++ b/src/mltcontroller/clipcontroller.cpp
@@ -819,3 +819,20 @@ void ClipController::disableEffects(bool disable)
if (changed) m_binController->updateTrackProducer(clipId());
}
+void ClipController::saveZone(QPoint zone, QDir dir)
+{
+ QString path = QString(clipName() + "_" + QString::number(zone.x()) + ".mlt");
+ if (dir.exists(path)) {
+ //TODO ask for overwrite
+ }
+ Mlt::Consumer xmlConsumer(*profile(), ("xml:" + dir.absoluteFilePath(path)).toUtf8().constData());
+ xmlConsumer.set("terminate_on_pause", 1);
+ Mlt::Producer prod(m_masterProducer->get_producer());
+ Mlt::Producer *prod2 = prod.cut(zone.x(), zone.y());
+ Mlt::Playlist list(*profile());
+ list.insert_at(0, *prod2, 0);
+ //list.set("title", desc.toUtf8().constData());
+ xmlConsumer.connect(list);
+ xmlConsumer.run();
+ delete prod2;
+}
diff --git a/src/mltcontroller/clipcontroller.h b/src/mltcontroller/clipcontroller.h
index 9a1bcf1..6b9f008 100644
--- a/src/mltcontroller/clipcontroller.h
+++ b/src/mltcontroller/clipcontroller.h
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QUrl>
#include <QMutex>
#include <QDateTime>
+#include <QDir>
class QPixmap;
class BinController;
@@ -194,6 +195,8 @@ public:
void moveEffect(int oldPos, int newPos);
/** @brief Request an update of all track producers */
void reloadTrackProducers();
+ /** @brief Save an xml playlist of current clip with in/out points as zone.x()/y() */
+ void saveZone(QPoint zone, QDir dir);
private:
Mlt::Producer *m_masterProducer;
diff --git a/src/project/projectmanager.cpp b/src/project/projectmanager.cpp
index f1b9eb1..c92fa00 100644
--- a/src/project/projectmanager.cpp
+++ b/src/project/projectmanager.cpp
@@ -774,3 +774,7 @@ QString ProjectManager::getDefaultProjectFormat()
return QStringLiteral("atsc_1080p_2997");
}
+void ProjectManager::saveZone(QStringList info, QDir dir)
+{
+ pCore->bin()->saveZone(info, dir);
+}
diff --git a/src/project/projectmanager.h b/src/project/projectmanager.h
index 7a68e98..8db84d0 100644
--- a/src/project/projectmanager.h
+++ b/src/project/projectmanager.h
@@ -62,6 +62,7 @@ public:
QString projectSceneList();
/** @brief returns a default hd profile depending on timezone*/
static QString getDefaultProjectFormat();
+ void saveZone(QStringList info, QDir dir);
public slots:
void newFile(bool showProjectSettings = true, bool force = false);