| 111 | } |
| 112 | |
| 113 | static std::string getModuleInfoString(const std::string& path) |
| 114 | { |
| 115 | QString modPath = QString::fromStdString(path); |
| 116 | QFileInfo mod(modPath); |
| 117 | if (mod.isHidden()) { // Ignore hidden directories |
| 118 | return {}; |
| 119 | } |
| 120 | |
| 121 | std::string addonName = mod.isDir() ? QDir(modPath).dirName().toStdString() |
| 122 | : mod.fileName().toStdString(); |
| 123 | std::string versionString; |
| 124 | std::stringstream str; |
| 125 | try { |
| 126 | auto metadataFile = std::filesystem::path(mod.absoluteFilePath().toStdString()) |
| 127 | / "package.xml"; |
| 128 | if (std::filesystem::exists(metadataFile)) { |
| 129 | App::Metadata metadata(metadataFile); |
| 130 | if (!metadata.name().empty()) { |
| 131 | addonName = metadata.name(); |
| 132 | } |
| 133 | if (metadata.version() != App::Meta::Version()) { |
| 134 | versionString = " " + metadata.version().str(); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | catch (const Base::Exception& e) { |
| 139 | auto what = QString::fromUtf8(e.what()).trimmed().replace( |
| 140 | QChar::fromLatin1('\n'), |
| 141 | QChar::fromLatin1(' ') |
| 142 | ); |
| 143 | str << " (Malformed metadata: " << what << ")"; |
| 144 | } |
| 145 | str << " * " << addonName << versionString; |
| 146 | QFileInfo disablingFile(mod.absoluteFilePath(), QStringLiteral("ADDON_DISABLED")); |
| 147 | if (disablingFile.exists()) { |
| 148 | str << " (Disabled)"; |
| 149 | } |
| 150 | |
| 151 | str << "\n"; |
| 152 | return str.str(); |
| 153 | } |
| 154 | |
| 155 | std::string ProgramInformation::getValueOrEmpty( |
| 156 | const std::map<std::string, std::string>& map, |
no test coverage detected