| 151 | std::size_t ExecutableManager::Size() const { return this->data.size(); } |
| 152 | |
| 153 | bool ExecutableManager::Load(const QJsonObject& json_root_object, ConfiguratorMode configurator_mode) { |
| 154 | (void)configurator_mode; |
| 155 | |
| 156 | // applications json object |
| 157 | const QJsonObject& json_executables_object = json_root_object.value("executables").toObject(); |
| 158 | |
| 159 | if (json_executables_object.value("active_executable") != QJsonValue::Undefined) { |
| 160 | this->active_executable = Path(json_executables_object.value("active_executable").toString().toStdString()); |
| 161 | } |
| 162 | |
| 163 | if (json_executables_object.value("last_path_executable") != QJsonValue::Undefined) { |
| 164 | this->last_path_executable = json_executables_object.value("last_path_executable").toString().toStdString(); |
| 165 | } |
| 166 | |
| 167 | if (json_executables_object.value("clear_on_launch") != QJsonValue::Undefined) { |
| 168 | this->launcher_clear_on_launch = json_executables_object.value("clear_on_launch").toBool(); |
| 169 | } |
| 170 | |
| 171 | const QJsonObject& json_list_object = json_executables_object.value("list").toObject(); |
| 172 | |
| 173 | const QStringList& json_list_keys = json_list_object.keys(); |
| 174 | |
| 175 | this->data.clear(); |
| 176 | for (int i = 0, n = json_list_keys.length(); i < n; ++i) { |
| 177 | Executable executable; |
| 178 | |
| 179 | const QJsonObject& json_application_object = json_list_object.value(json_list_keys[i]).toObject(); |
| 180 | executable.path = json_list_keys[i].toStdString(); |
| 181 | executable.enabled = json_application_object.value("enabled").toBool(); |
| 182 | if (json_application_object.value("removable") != QJsonValue::Undefined) { |
| 183 | executable.removable = json_application_object.value("removable").toBool(); |
| 184 | } |
| 185 | if (json_application_object.value("configuration") != QJsonValue::Undefined) { |
| 186 | executable.configuration = json_application_object.value("configuration").toString().toStdString(); |
| 187 | } |
| 188 | |
| 189 | const QJsonArray& json_options_array = json_application_object.value("options").toArray(); |
| 190 | for (int j = 0, o = json_options_array.size(); j < o; ++j) { |
| 191 | const QJsonObject& json_options_object = json_options_array[j].toObject(); |
| 192 | |
| 193 | ExecutableOptions executable_options; |
| 194 | |
| 195 | executable_options.label = json_options_object.value("label").toString().toStdString(); |
| 196 | executable_options.working_folder = json_options_object.value("working_folder").toString().toStdString(); |
| 197 | |
| 198 | std::vector<std::string> args; |
| 199 | const QJsonArray& json_command_lines_array = json_options_object.value("arguments").toArray(); |
| 200 | for (int k = 0, p = json_command_lines_array.size(); k < p; ++k) { |
| 201 | args.push_back(json_command_lines_array[k].toString().toStdString()); |
| 202 | } |
| 203 | // Workaround to resolved badly stored arguments when we were using SplitSpace instead of SplitArgs to fill the |
| 204 | // executable arguments option in the UI |
| 205 | executable_options.args = SplitArgs(Merge(args, " ")); |
| 206 | |
| 207 | const QJsonArray& json_environment_variables_array = json_options_object.value("environment_variables").toArray(); |
| 208 | for (int k = 0, p = json_environment_variables_array.size(); k < p; ++k) { |
| 209 | executable_options.envs.push_back(json_environment_variables_array[k].toString().toStdString()); |
| 210 | } |
nothing calls this directly
no test coverage detected