diff --git a/src/core/atcore.cpp b/src/core/atcore.cpp --- a/src/core/atcore.cpp +++ b/src/core/atcore.cpp @@ -611,27 +611,13 @@ QMap AtCore::findFirmwarePlugins(const QString &path) { QMap detectedPlugins; - QStringList files = QDir(path).entryList(QDir::Files); - for (const QString &f : files) { + for (const QString &f : QDir(path).entryList({AtCoreDirectories::pluginExtFilter}, QDir::Files)) { QString file = f; -#if defined(Q_OS_WIN) - if (file.endsWith(QStringLiteral(".dll"))) -#elif defined(Q_OS_MAC) - if (file.endsWith(QStringLiteral(".dylib"))) -#else - if (file.endsWith(QStringLiteral(".so"))) -#endif - file = file.split(QChar::fromLatin1('.')).at(0); - else { - continue; - } + file = file.split(QStringLiteral(".")).at(0).toLower().simplified(); if (file.startsWith(QStringLiteral("lib"))) { file = file.remove(QStringLiteral("lib")); } - file = file.toLower().simplified(); - QString pluginString = path; - pluginString.append(QChar::fromLatin1('/')); - pluginString.append(f); + QString pluginString = QStringLiteral("%1/%2").arg(path, f); detectedPlugins[file] = pluginString; qCDebug(ATCORE_PLUGIN) << QStringLiteral("Plugin:[%1]=%2").arg(file, pluginString); } diff --git a/src/core/atcore_default_folders.h.in b/src/core/atcore_default_folders.h.in --- a/src/core/atcore_default_folders.h.in +++ b/src/core/atcore_default_folders.h.in @@ -29,4 +29,12 @@ , QStringLiteral("@KDE_INSTALL_PLUGINDIR@/AtCore") , QStringLiteral("@CMAKE_CURRENT_BINARY_DIR@/../plugins") }; + const QString pluginExtFilter = + #if defined(Q_OS_WIN) + QStringLiteral("*.dll"); + #elif defined(Q_OS_MAC) + QStringLiteral("*.dylib"); + #else + QStringLiteral("*.so"); + #endif } diff --git a/src/widgets/profilemanager.cpp b/src/widgets/profilemanager.cpp --- a/src/widgets/profilemanager.cpp +++ b/src/widgets/profilemanager.cpp @@ -313,23 +313,11 @@ QStringList ProfileManager::firmwaresInPath(const QString &path) { QStringList firmwares; - QStringList files = QDir(path).entryList(QDir::Files); - for (QString file : files) { -#if defined(Q_OS_WIN) - if (file.endsWith(QStringLiteral(".dll"))) -#elif defined(Q_OS_MAC) - if (file.endsWith(QStringLiteral(".dylib"))) -#else - if (file.endsWith(QStringLiteral(".so"))) -#endif - file = file.split(QChar::fromLatin1('.')).at(0); - else { - continue; - } + for (QString file : QDir(path).entryList({AtCoreDirectories::pluginExtFilter}, QDir::Files)) { + file = file.split(QStringLiteral(".")).at(0).toLower().simplified(); if (file.startsWith(QStringLiteral("lib"))) { file = file.remove(QStringLiteral("lib")); } - file = file.toLower().simplified(); firmwares.append(file); } return firmwares;