| 6 | #include <QApplication> |
| 7 | |
| 8 | ControllerMappingDialog::ControllerMappingDialog(SDLControllerManager *controllerManager, QWidget *parent) |
| 9 | : QDialog(parent), controller(controllerManager) { |
| 10 | |
| 11 | setWindowTitle(tr("Controller Button Mapping")); |
| 12 | setModal(true); |
| 13 | resize(600, 500); |
| 14 | |
| 15 | // Setup timeout timer for button mapping |
| 16 | mappingTimeoutTimer = new QTimer(this); |
| 17 | mappingTimeoutTimer->setSingleShot(true); |
| 18 | mappingTimeoutTimer->setInterval(10000); // 10 second timeout |
| 19 | |
| 20 | connect(mappingTimeoutTimer, &QTimer::timeout, this, [this]() { |
| 21 | if (!currentMappingButton.isEmpty()) { |
| 22 | QMessageBox::information(this, tr("Mapping Timeout"), |
| 23 | tr("Button mapping timed out. Please try again.")); |
| 24 | |
| 25 | // Reset the button text |
| 26 | if (mappingButtons.contains(currentMappingButton)) { |
| 27 | mappingButtons[currentMappingButton]->setText(tr("Click to Map")); |
| 28 | mappingButtons[currentMappingButton]->setEnabled(true); |
| 29 | } |
| 30 | |
| 31 | currentMappingButton.clear(); |
| 32 | controller->stopButtonDetection(); |
| 33 | } |
| 34 | }); |
| 35 | |
| 36 | // Connect to controller signals |
| 37 | connect(controller, &SDLControllerManager::rawButtonPressed, |
| 38 | this, &ControllerMappingDialog::onRawButtonPressed); |
| 39 | |
| 40 | setupUI(); |
| 41 | loadCurrentMappings(); |
| 42 | } |
| 43 | |
| 44 | void ControllerMappingDialog::setupUI() { |
| 45 | QVBoxLayout *mainLayout = new QVBoxLayout(this); |
nothing calls this directly
no test coverage detected