* @brief Persists the device-control gate, warning the user before enabling it. */
| 209 | * @brief Persists the device-control gate, warning the user before enabling it. |
| 210 | */ |
| 211 | void AI::Assistant::setAllowDeviceControl(bool enabled) |
| 212 | { |
| 213 | if (m_allowDeviceControl == enabled) |
| 214 | return; |
| 215 | |
| 216 | if (enabled) { |
| 217 | const int result = Misc::Utilities::showMessageBox( |
| 218 | tr("Allow AI Device Control?"), |
| 219 | tr("This lets the AI assistant configure devices, open and close connections, " |
| 220 | "and send data to your hardware.\n\n" |
| 221 | "Every device action still requires your explicit per-call approval in the " |
| 222 | "chat, even when auto-approve is enabled. Only enable this if you trust the " |
| 223 | "configured AI provider with hardware access."), |
| 224 | QMessageBox::Warning, |
| 225 | QString(), |
| 226 | QMessageBox::Yes | QMessageBox::No, |
| 227 | QMessageBox::No); |
| 228 | |
| 229 | if (result == QMessageBox::No) { |
| 230 | m_allowDeviceControl = false; |
| 231 | m_settings.setValue(QStringLiteral("ai/allowDeviceControl"), false); |
| 232 | Q_EMIT allowDeviceControlChanged(); |
| 233 | return; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | m_allowDeviceControl = enabled; |
| 238 | m_settings.setValue(QStringLiteral("ai/allowDeviceControl"), m_allowDeviceControl); |
| 239 | CommandRegistry::instance().setDeviceControlAllowed(m_allowDeviceControl); |
| 240 | Q_EMIT allowDeviceControlChanged(); |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * @brief Returns the display names of the registered providers in order. |
nothing calls this directly
no test coverage detected