| 224 | } // namespace |
| 225 | |
| 226 | void MainWindow::showFlexControlDialog() |
| 227 | { |
| 228 | const bool wasFresh = !m_flexControlDialog; |
| 229 | showOrRaisePersistent(m_flexControlDialog); |
| 230 | if (wasFresh && m_flexControlDialog) { |
| 231 | connect(m_flexControlDialog, &FlexControlDialog::virtualWheelSteps, |
| 232 | this, &MainWindow::handleVirtualFlexControlWheel); |
| 233 | connect(m_flexControlDialog, &FlexControlDialog::virtualButtonPressed, |
| 234 | this, &MainWindow::handleFlexControlButton); |
| 235 | connect(m_flexControlDialog, &FlexControlDialog::virtualButtonPressed, |
| 236 | this, [this](int button, int action) { |
| 237 | if (m_flexControlDialog) |
| 238 | m_flexControlDialog->reflectButtonPress(button, action); |
| 239 | }); |
| 240 | connect(m_flexControlDialog, &FlexControlDialog::flexControlSettingsChanged, |
| 241 | this, [this] { |
| 242 | if (m_radioSetupDialog) |
| 243 | m_radioSetupDialog->refreshFlexControlButtonActions(); |
| 244 | syncFlexControlIndicatorForSettings(); |
| 245 | #ifdef HAVE_SERIALPORT |
| 246 | const bool invert = AppSettings::instance() |
| 247 | .value("FlexControlInvertDir", "False").toString() == "True"; |
| 248 | QMetaObject::invokeMethod(m_flexControl, [this, invert] { |
| 249 | m_flexControl->setInvertDirection(invert); |
| 250 | }); |
| 251 | #endif |
| 252 | }); |
| 253 | connect(m_flexControlDialog, &FlexControlDialog::physicalDetectRequested, |
| 254 | this, [this] { |
| 255 | #ifdef HAVE_SERIALPORT |
| 256 | const QString port = FlexControlManager::detectPort(); |
| 257 | if (port.isEmpty()) { |
| 258 | m_flexControlConnected = false; |
| 259 | if (m_flexControlDialog) |
| 260 | m_flexControlDialog->setPhysicalReady(false); |
| 261 | if (m_radioSetupDialog) |
| 262 | m_radioSetupDialog->setFlexControlConnectionStatus(false); |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | auto& settings = AppSettings::instance(); |
| 267 | settings.setValue("FlexControlPort", port); |
| 268 | settings.setValue("FlexControlOpen", "True"); |
| 269 | settings.save(); |
| 270 | |
| 271 | const bool invert = settings.value("FlexControlInvertDir", "False").toString() == "True"; |
| 272 | QMetaObject::invokeMethod(m_flexControl, [this, port, invert] { |
| 273 | m_flexControl->setInvertDirection(invert); |
| 274 | m_flexControl->open(port); |
| 275 | }); |
| 276 | #else |
| 277 | if (m_flexControlDialog) |
| 278 | m_flexControlDialog->setPhysicalReady(false); |
| 279 | #endif |
| 280 | }); |
| 281 | connect(m_flexControlDialog, &FlexControlDialog::physicalDisconnectRequested, |
| 282 | this, [this] { |
| 283 | #ifdef HAVE_SERIALPORT |
nothing calls this directly
no test coverage detected