| 95 | } |
| 96 | |
| 97 | void WidgetSettingFilesystem::LoadPath(const Path& path) { |
| 98 | switch (this->meta.type) { |
| 99 | case SETTING_LOAD_FILE: { |
| 100 | const SettingMetaFileLoad& setting_meta = static_cast<const SettingMetaFileLoad&>(this->meta); |
| 101 | if (setting_meta.format == "PROFILE") { |
| 102 | if (path.Empty()) { |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | SettingDataFileLoad& file_setting_data = static_cast<SettingDataFileLoad&>(this->data()); |
| 107 | file_setting_data.profile_names = CollectProfileNamesFromFile(path); |
| 108 | |
| 109 | SettingDataString* enum_setting_data = FindSetting<SettingDataString>(this->data_set, "profile_name"); |
| 110 | if (!file_setting_data.profile_names.empty() && enum_setting_data != nullptr) { |
| 111 | enum_setting_data->SetValue(file_setting_data.profile_names[0].c_str()); |
| 112 | } else { |
| 113 | enum_setting_data->SetValue(""); |
| 114 | } |
| 115 | } |
| 116 | break; |
| 117 | } |
| 118 | case SETTING_LOAD_FOLDER: { |
| 119 | const SettingMetaFolderLoad& setting_meta = static_cast<const SettingMetaFolderLoad&>(this->meta); |
| 120 | if (setting_meta.format == "PROFILE") { |
| 121 | if (path.Empty()) { |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | SettingDataFolderLoad& setting_data = static_cast<SettingDataFolderLoad&>(this->data()); |
| 126 | setting_data.profile_names = CollectProfileNamesFromDir(path); |
| 127 | |
| 128 | SettingDataString* enum_setting_data = FindSetting<SettingDataString>(this->data_set, "profile_name"); |
| 129 | if (enum_setting_data != nullptr) { |
| 130 | if (std::find(setting_data.profile_names.begin(), setting_data.profile_names.end(), |
| 131 | enum_setting_data->GetValue()) == setting_data.profile_names.end()) { |
| 132 | enum_setting_data->SetValue("${VP_DEFAULT}"); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | break; |
| 137 | } |
| 138 | default: |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | void WidgetSettingFilesystem::browseButtonClicked() { |
| 144 | Path path(this->field->text().toStdString()); |
no test coverage detected