| 214 | } |
| 215 | |
| 216 | static void deviceProperties() |
| 217 | { |
| 218 | /* Device name */ |
| 219 | |
| 220 | std::set<int> applicableOptions = {ANY_SOURCESINK}; |
| 221 | auto deviceNameSetting = settings.get<std::string>("device"); |
| 222 | auto selectedDevice = findOrDefault(Datastore::getDevices(), |
| 223 | (std::string)deviceNameSetting, |
| 224 | {.label = "No device configured"}); |
| 225 | ImGui::TableNextRow(); |
| 226 | ImGui::TableNextColumn(); |
| 227 | ImGui::AlignTextToFramePadding(); |
| 228 | ImGui::Text("Device"); |
| 229 | |
| 230 | if ((std::string)deviceNameSetting == DEVICE_FLUXFILE) |
| 231 | applicableOptions.insert(FLUXFILE_SOURCESINK); |
| 232 | else if ((std::string)deviceNameSetting == DEVICE_MANUAL) |
| 233 | { |
| 234 | applicableOptions.insert(MANUAL_SOURCESINK); |
| 235 | applicableOptions.insert(HARDWARE_SOURCESINK); |
| 236 | } |
| 237 | else |
| 238 | applicableOptions.insert(HARDWARE_SOURCESINK); |
| 239 | |
| 240 | ImGui::TableNextColumn(); |
| 241 | ImGui::SetNextItemWidth(-FLT_MIN); |
| 242 | if (ImGui::BeginCombo("##devices", |
| 243 | selectedDevice.label.c_str(), |
| 244 | ImGuiComboFlags_HeightLargest)) |
| 245 | { |
| 246 | ON_SCOPE_EXIT |
| 247 | { |
| 248 | ImGui::EndCombo(); |
| 249 | }; |
| 250 | |
| 251 | for (auto& [name, device] : Datastore::getDevices()) |
| 252 | if (ImGui::Selectable(device.label.c_str(), false)) |
| 253 | deviceNameSetting = name; |
| 254 | } |
| 255 | |
| 256 | /* The rescan button. */ |
| 257 | |
| 258 | ImGui::TableNextRow(); |
| 259 | ImGui::TableNextColumn(); |
| 260 | ImGui::TableNextColumn(); |
| 261 | if (ImGui::Button("fluxengine.view.config.rescan"_lang)) |
| 262 | { |
| 263 | Datastore::probeDevices(); |
| 264 | } |
| 265 | |
| 266 | ImGui::SameLine(); |
| 267 | if (ImGui::Button("fluxengine.view.config.setupFluxFile"_lang)) |
| 268 | { |
| 269 | fs::openFileBrowser(fs::DialogMode::Open, |
| 270 | {}, |
| 271 | [](const auto& path) |
| 272 | { |
| 273 | settings.get<std::string>("device") = DEVICE_FLUXFILE; |
no test coverage detected