diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-06-20 19:11:53 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-06-20 19:11:53 +0000 |
| commit | e439934003cd2746ff0f7df6d6312724e8665daf (patch) | |
| tree | 1b32a216add5b616ea53c63a4270bc6a058d2409 /src | |
| parent | 53d0591e3f54c89ed86a4a84ef0f425874d146a0 (diff) | |
| download | qmmp-e439934003cd2746ff0f7df6d6312724e8665daf.tar.gz qmmp-e439934003cd2746ff0f7df6d6312724e8665daf.tar.bz2 qmmp-e439934003cd2746ff0f7df6d6312724e8665daf.zip | |
added startup optimization
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@10073 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/General/mpris/root2object.cpp | 6 | ||||
| -rw-r--r-- | src/qmmp/abstractengine.cpp | 14 | ||||
| -rw-r--r-- | src/qmmp/abstractengine.h | 4 | ||||
| -rw-r--r-- | src/qmmp/decoder.cpp | 14 | ||||
| -rw-r--r-- | src/qmmp/decoder.h | 4 | ||||
| -rw-r--r-- | src/qmmp/qmmpplugincache.cpp | 13 | ||||
| -rw-r--r-- | src/qmmp/qmmpplugincache_p.h | 3 |
7 files changed, 51 insertions, 7 deletions
diff --git a/src/plugins/General/mpris/root2object.cpp b/src/plugins/General/mpris/root2object.cpp index 3de86711d..d453346e8 100644 --- a/src/plugins/General/mpris/root2object.cpp +++ b/src/plugins/General/mpris/root2object.cpp @@ -64,10 +64,8 @@ QString Root2Object::identity() const QStringList Root2Object::supportedMimeTypes() const { QStringList mimeTypes; - for(const DecoderFactory *factory : Decoder::enabledFactories()) - mimeTypes << factory->properties().contentTypes; - for(const EngineFactory *factory : AbstractEngine::enabledFactories()) - mimeTypes << factory->properties().contentTypes; + mimeTypes << Decoder::contentTypes(); + mimeTypes << AbstractEngine::contentTypes(); mimeTypes.removeDuplicates(); return mimeTypes; } diff --git a/src/qmmp/abstractengine.cpp b/src/qmmp/abstractengine.cpp index e3bda3114..2198154aa 100644 --- a/src/qmmp/abstractengine.cpp +++ b/src/qmmp/abstractengine.cpp @@ -139,6 +139,20 @@ QStringList AbstractEngine::nameFilters() return filters; } +QStringList AbstractEngine::contentTypes() +{ + loadPlugins(); + QStringList types; + for(QmmpPluginCache *item : qAsConst(*m_cache)) + { + if(m_disabledNames.contains(item->shortName())) + continue; + + types << item->contentTypes(); + } + return types; +} + EngineFactory *AbstractEngine::findByFilePath(const QString& source) { loadPlugins(); diff --git a/src/qmmp/abstractengine.h b/src/qmmp/abstractengine.h index e2455afaf..f35bef319 100644 --- a/src/qmmp/abstractengine.h +++ b/src/qmmp/abstractengine.h @@ -91,6 +91,10 @@ public: */ static QStringList nameFilters(); /*! + * Returns a list of the supported mime types. + */ + static QStringList contentTypes(); + /*! * Returns EngineFactory pointer which supports file \b path or 0 if file \b path is unsupported. */ static EngineFactory *findByFilePath(const QString &path); diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp index e03dfdc23..99aed4469 100644 --- a/src/qmmp/decoder.cpp +++ b/src/qmmp/decoder.cpp @@ -357,3 +357,17 @@ QStringList Decoder::nameFilters() } return filters; } + +QStringList Decoder::contentTypes() +{ + loadPlugins(); + QStringList types; + for(QmmpPluginCache *item : qAsConst(*m_cache)) + { + if(m_disabledNames.contains(item->shortName())) + continue; + + types << item->contentTypes(); + } + return types; +} diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h index ae3ec516f..ff74cf51c 100644 --- a/src/qmmp/decoder.h +++ b/src/qmmp/decoder.h @@ -157,6 +157,10 @@ public: */ static QStringList nameFilters(); /*! + * Returns a list of the supported mime types. + */ + static QStringList contentTypes(); + /*! * Returns plugin file path. * @param factory Decoder plugin factory. */ diff --git a/src/qmmp/qmmpplugincache.cpp b/src/qmmp/qmmpplugincache.cpp index 713436dbc..cd3c9f5e1 100644 --- a/src/qmmp/qmmpplugincache.cpp +++ b/src/qmmp/qmmpplugincache.cpp @@ -46,14 +46,15 @@ QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) { QStringList values = settings->value(m_path).toStringList(); - if(values.count() != 4) + if(values.count() != 5) update = true; else { m_shortName = values.at(0); m_priority = values.at(1).toInt(); m_filters = values.at(2).split(";"); - update = (info.lastModified().toString(Qt::ISODate) != values.at(3)); + m_contentTypes = values.at(3).split(";"); + update = (info.lastModified().toString(Qt::ISODate) != values.at(4)); } } else @@ -67,6 +68,7 @@ QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) m_shortName = factory->properties().shortName; m_priority = factory->properties().priority; m_filters = factory->properties().filters; + m_contentTypes = factory->properties().contentTypes; } else if(OutputFactory *factory = outputFactory()) { @@ -78,6 +80,7 @@ QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) m_shortName = factory->properties().shortName; m_priority = 0; m_filters = factory->properties().filters; + m_contentTypes = factory->properties().contentTypes; } else if(EffectFactory *factory = effectFactory()) { @@ -101,6 +104,7 @@ QmmpPluginCache::QmmpPluginCache(const QString &file, QSettings *settings) values << m_shortName; values << QString::number(m_priority); values << m_filters.join(";"); + values << m_contentTypes.join(";"); values << info.lastModified().toString(Qt::ISODate); settings->setValue(m_path, values); qDebug("QmmpPluginCache: added cache item \"%s=%s\"", @@ -125,6 +129,11 @@ const QStringList &QmmpPluginCache::filters() const return m_filters; } +const QStringList &QmmpPluginCache::contentTypes() const +{ + return m_contentTypes; +} + int QmmpPluginCache::priority() const { return m_priority; diff --git a/src/qmmp/qmmpplugincache_p.h b/src/qmmp/qmmpplugincache_p.h index dee5a0a7f..c800ae6c8 100644 --- a/src/qmmp/qmmpplugincache_p.h +++ b/src/qmmp/qmmpplugincache_p.h @@ -43,6 +43,7 @@ public: const QString shortName() const; const QString file() const; const QStringList &filters() const; + const QStringList &contentTypes() const; int priority() const; bool hasError() const; @@ -59,7 +60,7 @@ private: void loadTranslation(const QString &translation); QString m_path; QString m_shortName; - QStringList m_filters; + QStringList m_filters, m_contentTypes; bool m_error = false; QObject *m_instance = nullptr; DecoderFactory *m_decoderFactory = nullptr; |
