From: Nicolas C. <nu...@kd...> - 2017-03-22 01:16:41
|
Git commit 6391a4c0daab73675a569d275522ebcbe95dec50 by Nicolas Carion. Committed on 21/03/2017 at 13:05. Pushed by alcinos into branch 'refactoring_timeline'. Move some initialization logic to mltConnection M +38 -0 src/mltconnection.cpp M +5 -1 src/mltconnection.h https://commits.kde.org/kdenlive/6391a4c0daab73675a569d275522ebcbe95dec50 diff --git a/src/mltconnection.cpp b/src/mltconnection.cpp index 84617754e..772212e1e 100644 --- a/src/mltconnection.cpp +++ b/src/mltconnection.cpp @@ -36,6 +36,18 @@ MltConnection::MltConnection(const QString &mltPath) setenv("MLT_NO_VDPAU", "1", 1); m_repository = std::unique_ptr<Mlt::Repository>(Mlt::Factory::init()); locateMeltAndProfilesPath(mltPath); + + // Retrieve the list of available producers. + QScopedPointer<Mlt::Properties> producers(m_repository->producers()); + QStringList producersList; + int nb_producers = producers->count(); + producersList.reserve(nb_producers); + for (int i = 0; i < nb_producers; ++i) { + producersList << producers->get_name(i); + } + KdenliveSettings::setProducerslist(producersList); + + refreshLumas(); } void MltConnection::locateMeltAndProfilesPath(const QString &mltPath) @@ -138,3 +150,29 @@ std::unique_ptr<Mlt::Repository>& MltConnection::getMltRepository() { return m_repository; } + +void MltConnection::refreshLumas() +{ + // Check for Kdenlive installed luma files, add empty string at start for no luma + QStringList imagefiles; + QStringList fileFilters; + MainWindow::m_lumaFiles.clear(); + fileFilters << QStringLiteral("*.png") << QStringLiteral("*.pgm"); + QStringList customLumas = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("lumas"), QStandardPaths::LocateDirectory); + customLumas.append(QString(mlt_environment("MLT_DATA")) + QStringLiteral("/lumas")); + foreach (const QString &folder, customLumas) { + QDir topDir(folder); + QStringList folders = topDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + foreach (const QString &f, folders) { + QDir dir(topDir.absoluteFilePath(f)); + QStringList filesnames = dir.entryList(fileFilters, QDir::Files); + if (MainWindow::m_lumaFiles.contains(f)) { + imagefiles = MainWindow::m_lumaFiles.value(f); + } + foreach (const QString &fname, filesnames) { + imagefiles.append(dir.absoluteFilePath(fname)); + } + MainWindow::m_lumaFiles.insert(f, imagefiles); + } + } +} diff --git a/src/mltconnection.h b/src/mltconnection.h index 848222bd1..3af307d68 100644 --- a/src/mltconnection.h +++ b/src/mltconnection.h @@ -21,7 +21,7 @@ namespace Mlt { /** * @class MltConnection * @brief Initializes MLT and provides access to its API - * This is where the Mlt Factory is initialized + * This is where the Mlt Factory is initialized, as well as the producers */ class MltConnection @@ -46,6 +46,10 @@ protected: * user. It doesn't fill any list of profiles, while its name suggests so. */ void locateMeltAndProfilesPath(const QString &mltPath = QString()); + /** @brief Updates the list of available Lumas + */ + void refreshLumas(); + static int instanceCounter; /** @brief The MLT repository, useful for filter/producer requests */ |