Commit 69dc61d7 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Utilize KIO::PreviewJob::availableThumbnailerPlugins

This method caches the results internally and also takes care of converting legacy KServiceTypeTrader plugins.
parent bfb13d4b
Pipeline #197271 passed with stage
in 2 minutes and 50 seconds
......@@ -66,11 +66,6 @@ ecm_qt_declare_logging_category(kio_thumbnail
EXPORT KIO_EXTRAS
)
target_compile_definitions(kio_thumbnail
PRIVATE
-DKSERVICE_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055100 # KMimeTypeTrader
)
target_link_libraries(kio_thumbnail
KF5::CoreAddons
KF5::KIOCore
......
......@@ -38,8 +38,6 @@
#include <KConfigGroup>
#include <KFileItem>
#include <KLocalizedString>
#include <KPluginInfo>
#include <KServiceTypeTrader>
#include <KSharedConfig>
#include <kio/previewjob.h>
......@@ -334,25 +332,8 @@ void ThumbnailProtocol::get(const QUrl &url)
finished();
}
static QVector<KPluginMetaData> availablePlugins()
{
auto jsonMetaDataPlugins = KPluginMetaData::findPlugins(QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR) "/thumbcreator"));
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
// TODO KF6 remove this compat codepath
const KService::List plugins = KServiceTypeTrader::self()->query(QStringLiteral("ThumbCreator"));
for (const auto &plugin : plugins) {
if (KPluginInfo info(plugin); info.isValid()) {
jsonMetaDataPlugins << info.toMetaData();
}
}
QT_WARNING_POP
return jsonMetaDataPlugins;
}
KPluginMetaData ThumbnailProtocol::pluginForMimeType(const QString& mimeType) {
const static QVector<KPluginMetaData> plugins = availablePlugins();
const QVector<KPluginMetaData> plugins = KIO::PreviewJob::availableThumbnailerPlugins();
for (const KPluginMetaData &plugin : plugins) {
if (plugin.supportsMimeType(mimeType)) {
return plugin;
......@@ -678,16 +659,13 @@ ThumbCreatorWithMetadata* ThumbnailProtocol::getThumbCreator(const QString& plug
if (plugin.contains(QLatin1String("kf5") + QDir::separator() + QLatin1String("thumbcreator"))) {
data = KPluginMetaData(plugin);
} else {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
// TODO KF6 remove this compat codepath
const QString constraint = QStringLiteral("Library == '%1'").arg(QFileInfo(plugin).fileName());
const KService::List plugins = KServiceTypeTrader::self()->query(QStringLiteral("ThumbCreator"), constraint);
if (!plugins.isEmpty()) {
data = KPluginInfo(plugins.first()).toMetaData();
const QVector<KPluginMetaData> plugins = KIO::PreviewJob::availableThumbnailerPlugins();
auto findPluginIt = std::find_if(plugins.begin(), plugins.end(), [&plugin](const KPluginMetaData &data) {
return data.pluginId() == plugin;
});
if (findPluginIt != plugins.end()) {
data = *findPluginIt;
}
QT_WARNING_POP
}
if (!data.isValid()) {
qCWarning(KIO_THUMBNAIL_LOG) << "Plugin not found:" << plugin;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment