| 179 | } |
| 180 | |
| 181 | void SettingsFragment::refreshDevices() |
| 182 | { |
| 183 | _lockslot = true; |
| 184 | ui->dev_select->clear(); |
| 185 | |
| 186 | ui->dev_mode_auto->setChecked(AppConfig::instance().get<bool>(AppConfig::AudioOutputUseDefault)); |
| 187 | ui->dev_mode_manual->setChecked(!AppConfig::instance().get<bool>(AppConfig::AudioOutputUseDefault)); |
| 188 | ui->dev_select->setDisabled(ui->dev_mode_auto->isChecked()); |
| 189 | |
| 190 | auto devices = _audioService->sinkDevices(); |
| 191 | |
| 192 | ui->dev_select->addItem("...", 0); |
| 193 | for (const auto& device : devices) |
| 194 | { |
| 195 | ui->dev_select->addItem(QString("%1 (%2)") |
| 196 | .arg(QString::fromStdString(device.description)) |
| 197 | .arg(QString::fromStdString(device.name)), QString::fromStdString(device.name)); |
| 198 | } |
| 199 | |
| 200 | auto current = AppConfig::instance().get<QString>(AppConfig::AudioOutputDevice); |
| 201 | |
| 202 | bool notFound = true; |
| 203 | |
| 204 | for (int i = 0; i < ui->dev_select->count(); i++) |
| 205 | { |
| 206 | if (ui->dev_select->itemData(i) == current) |
| 207 | { |
| 208 | notFound = false; |
| 209 | ui->dev_select->setCurrentIndex(i); |
| 210 | break; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | if (notFound) |
| 215 | { |
| 216 | QString name = QString(tr("Unknown (%1)")).arg(current); |
| 217 | ui->dev_select->addItem(name, current); |
| 218 | ui->dev_select->setCurrentText(name); |
| 219 | } |
| 220 | _lockslot = false; |
| 221 | } |
| 222 | |
| 223 | void SettingsFragment::refreshAll() |
| 224 | { |
nothing calls this directly
no test coverage detected