From 05b414a8e0ea4cefe3b14ea2b6ac5340d12ea1d4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 16 Sep 2010 16:08:17 +0000 Subject: [PATCH] Allow importing of clips into project from command line: http://kdenlive.org/mantis/view.php?id=1812 svn path=/trunk/kdenlive/; revision=4901 --- src/main.cpp | 5 +++-- src/mainwindow.cpp | 12 +++++++++++- src/mainwindow.h | 3 ++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a225c4ef..7b53e653 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,6 +54,7 @@ int main(int argc, char *argv[]) KCmdLineOptions options; options.add("mlt-path ", ki18n("Set the path for MLT environment")); options.add("+[file]", ki18n("Document to open")); //new + options.add("i ", ki18n("Comma separated list of clips to add")); //new KCmdLineArgs::addCmdLineOptions(options); //new KApplication app; @@ -74,13 +75,13 @@ int main(int argc, char *argv[]) } } else { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); //new - + QString clipsToLoad = args->getOption("i"); QString mltPath = args->getOption("mlt-path"); KUrl url; if (args->count()) { url = args->url(0); } - window = new MainWindow(mltPath, url); + window = new MainWindow(mltPath, url, clipsToLoad); window->show(); args->clear(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 053d177e..f544335a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -120,7 +120,7 @@ EffectsList MainWindow::audioEffects; EffectsList MainWindow::customEffects; EffectsList MainWindow::transitions; -MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) : +MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) : KXmlGuiWindow(parent), m_activeDocument(NULL), m_activeTimeline(NULL), @@ -469,6 +469,16 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent newFile(false); } + if (!clipsToLoad.isEmpty() && m_activeDocument) { + QStringList list = clipsToLoad.split(','); + QList urls; + foreach(QString path, list) { + kDebug() << QDir::current().absoluteFilePath(path); + urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path)); + } + m_projectList->slotAddClip(urls); + } + #ifndef NO_JOGSHUTTLE activateShuttleDevice(); #endif /* NO_JOGSHUTTLE */ diff --git a/src/mainwindow.h b/src/mainwindow.h index eee703f2..9d8b5b48 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -78,12 +78,13 @@ public: /** @brief Initialises the main window. * @param MltPath (optional) path to MLT environment * @param Url (optional) file to open + * @param clipsToLoad (optional) a comma separated list of clips to import in project * * If Url is present, it will be opened, otherwhise, if openlastproject is * set, latest project will be opened. If no file is open after trying this, * a default new file will be created. */ explicit MainWindow(const QString &MltPath = QString(), - const KUrl &Url = KUrl(), QWidget *parent = 0); + const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0); virtual ~MainWindow(); /** @brief Locates the MLT environment. -- 2.39.2