From 3e0775f80b929fbced7ba25e58e50973b3ae6563 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 13 Dec 2008 19:03:42 +0000 Subject: [PATCH] "Get New Lumas" option in settings menu to automatically download new transition luma files from kde-files.org svn path=/branches/KDE4/; revision=2786 --- src/CMakeLists.txt | 4 +++- src/initeffects.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- src/initeffects.h | 1 + src/kdenlive.knsrc | 4 ++++ src/kdenliveui.rc | 1 + src/mainwindow.cpp | 22 ++++++++++++++++++++++ src/mainwindow.h | 1 + 7 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/kdenlive.knsrc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34c80f92..c868d10d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -153,7 +153,8 @@ kde4_add_executable(kdenlive ${kdenlive_SRCS} ${kdenlive_UI}) target_link_libraries(kdenlive ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KNEWSTUFF2_LIBS} ${LIBMLTPLUS_LIBRARY} ${LIBMLT_LIBRARY} ${NEPOMUK_LIBRARIES} @@ -165,6 +166,7 @@ install( FILES kdenliveui.rc kdenlive.notifyrc DESTINATION ${DATA_INSTALL_DIR}/ install (FILES kdenlivesettings.kcfg DESTINATION share/config.kcfg) install (FILES kdenlive.desktop DESTINATION share/applications/kde) install (FILES application-x-kdenlive.svgz video-mlt-playlist.svgz DESTINATION share/icons/oxygen/scalable/mimetypes) +install( FILES kdenlive.knsrc DESTINATION ${CONFIG_INSTALL_DIR} ) kde4_install_icons( ${ICON_INSTALL_DIR} ) diff --git a/src/initeffects.cpp b/src/initeffects.cpp index fd4c46f1..1470cc48 100644 --- a/src/initeffects.cpp +++ b/src/initeffects.cpp @@ -66,6 +66,48 @@ initEffects::initEffects() { initEffects::~initEffects() { } + +// static +void initEffects::refreshLumas() { + + // Check for Kdenlive installed luma files + QStringList imagenamelist; + QStringList imagefiles; + QStringList filters; + filters << "*.pgm" << "*.png"; + + QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas"); + foreach(const QString &folder, customLumas) { + QStringList filesnames = QDir(folder).entryList(filters, QDir::Files); + foreach(const QString &fname, filesnames) { + imagenamelist.append(fname); + imagefiles.append(folder + '/' + fname); + } + } + + // Check for MLT lumas + QString folder = mlt_environment("MLT_DATA"); + folder.append("/lumas/").append(mlt_environment("MLT_NORMALISATION")); + QDir lumafolder(folder); + QStringList filesnames = lumafolder.entryList(filters, QDir::Files); + foreach(const QString &fname, filesnames) { + imagenamelist.append(fname); + imagefiles.append(folder + '/' + fname); + } + QDomElement lumaTransition = MainWindow::transitions.getEffectByTag("luma", QString()); + QDomNodeList params = lumaTransition.elementsByTagName("parameter"); + for (int i = 0; i < params.count(); i++) { + QDomElement e = params.item(i).toElement(); + if (e.attribute("tag") == "resource") { + e.setAttribute("paramlistdisplay", imagenamelist.join(",")); + e.setAttribute("paramlist", imagefiles.join(",")); + break; + } + } + + +} + //static Mlt::Repository *initEffects::parseEffectFiles() { QStringList::Iterator more; @@ -655,7 +697,7 @@ void initEffects::fillTransitionsList(Mlt::Repository * repository, EffectsList* transitions->append(ret.documentElement()); //kDebug() << "//// //// TRANSITON XML"; - //kDebug() << ret.toString(); + kDebug() << ret.toString(); /* diff --git a/src/initeffects.h b/src/initeffects.h index 01b3852d..3da9dd54 100644 --- a/src/initeffects.h +++ b/src/initeffects.h @@ -48,6 +48,7 @@ public: ~initEffects(); static Mlt::Repository *parseEffectFiles(); + static void refreshLumas(); static QDomDocument createDescriptionFromMlt(Mlt::Repository* repository, const QString& type, const QString& name); static void fillTransitionsList(Mlt::Repository *, EffectsList* transitions, QStringList names); static QDomElement quickParameterFill(QDomDocument & doc, QString name, QString tag, QString type, QString def = QString(), QString min = QString(), QString max = QString(), QString list = QString(), QString listdisplaynames = QString(), QString factor = QString(), QString namedesc = QString(), QString format = QString()); diff --git a/src/kdenlive.knsrc b/src/kdenlive.knsrc new file mode 100644 index 00000000..593662d5 --- /dev/null +++ b/src/kdenlive.knsrc @@ -0,0 +1,4 @@ +[KNewStuff2] +ProvidersUrl=http://download.kde.org/khotnewstuff/kdenlive-providers.xml +TargetDir=kdenlive/lumas +Uncompress=archive \ No newline at end of file diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index a1e2bf00..86996649 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -92,6 +92,7 @@ + \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 69c24e9d..96bcdca7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include @@ -690,6 +692,8 @@ void MainWindow::setupActions() { collection->addAction("manage_profiles", profilesAction); connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles())); + KAction* fileGHNS = KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewStuff()), actionCollection(), "get_new_stuff"); + KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this); collection->addAction("project_settings", projectAction); connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings())); @@ -1989,5 +1993,23 @@ void MainWindow::slotSetOutPoint() { } else m_activeTimeline->projectView()->setOutPoint(); } +void MainWindow::slotGetNewStuff() { + kDebug() << "// GET NEW STUFF"; + //KNS::Entry::List download(); + KNS::Entry::List entries = KNS::Engine::download(); + int numberInstalled = 0; + // list of changed entries + kDebug() << "// PARSING KNS"; + foreach(KNS::Entry* entry, entries) { + // care only about installed ones + if (entry->status() == KNS::Entry::Installed) { + foreach(const QString &file, entry->installedFiles()) { + kDebug() << "// CURRENTLY INSTALLED: " << file; + } + } + } + qDeleteAll(entries); + initEffects::refreshLumas(); +} #include "mainwindow.moc" diff --git a/src/mainwindow.h b/src/mainwindow.h index ca7d7a81..c9ef5e9f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -269,6 +269,7 @@ private slots: void slotInsertTrack(int ix = 0); void slotDeleteTrack(int ix = 0); void slotChangeTrack(int ix = 0); + void slotGetNewStuff(); }; -- 2.39.2