Merge the file path into the (possibly empty) saved JSON config. Saved config carries the dialog state from the previous load (delimiter, time column, etc.) so the dialog opens pre-populated. If saved_config doesn't parse, treat it as empty rather than failing the import.
| 64 | // column, etc.) so the dialog opens pre-populated. If saved_config doesn't |
| 65 | // parse, treat it as empty rather than failing the import. |
| 66 | std::string buildLoadConfig(std::string_view saved_config, const QString& path) { |
| 67 | QJsonObject obj; |
| 68 | if (!saved_config.empty()) { |
| 69 | const QByteArray bytes(saved_config.data(), static_cast<qsizetype>(saved_config.size())); |
| 70 | const QJsonDocument doc = QJsonDocument::fromJson(bytes); |
| 71 | if (doc.isObject()) { |
| 72 | obj = doc.object(); |
| 73 | } |
| 74 | } |
| 75 | obj.insert(QStringLiteral("filepath"), path); |
| 76 | const QByteArray out = QJsonDocument(obj).toJson(QJsonDocument::Compact); |
| 77 | return std::string(out.constData(), static_cast<std::size_t>(out.size())); |
| 78 | } |
| 79 | |
| 80 | QString pluginConfigKey(const std::string& plugin_id) { |
| 81 | return QString::fromLatin1(kPluginConfigKeyPrefix) + QString::fromStdString(plugin_id); |