| 36 | } |
| 37 | |
| 38 | void SelectCoreDialog::validateSelection() |
| 39 | { |
| 40 | const auto reportError = [this](const QString& errorMessage) { |
| 41 | m_ui.selectionValidWidget->setText(errorMessage); |
| 42 | m_ui.selectionValidWidget->animatedShow(); |
| 43 | m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); |
| 44 | }; |
| 45 | |
| 46 | // an empty executable is acceptable |
| 47 | if (const auto executableUrl = executableFile(); !executableUrl.isEmpty()) { |
| 48 | if (!executableUrl.isValid()) { |
| 49 | reportError(i18n("Invalid executable file name")); |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | const QFileInfo executableInfo(executableUrl.toLocalFile()); |
| 54 | if (!executableInfo.exists()) { |
| 55 | reportError(i18n("Executable file does not exist")); |
| 56 | return; |
| 57 | } |
| 58 | if (!executableInfo.isFile()) { |
| 59 | reportError(i18n("Executable is not a file")); |
| 60 | return; |
| 61 | } |
| 62 | if (!executableInfo.isReadable()) { |
| 63 | reportError(i18n("Executable file is not readable")); |
| 64 | return; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | const auto coreUrl = core(); |
| 69 | if (coreUrl.isEmpty()) { |
| 70 | reportError(i18n("Empty core file name")); |
| 71 | return; |
| 72 | } |
| 73 | if (!coreUrl.isValid()) { |
| 74 | reportError(i18n("Invalid core file name")); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | const QFileInfo coreInfo(coreUrl.toLocalFile()); |
| 79 | if (!coreInfo.exists()) { |
| 80 | reportError(i18n("Core file does not exist")); |
| 81 | return; |
| 82 | } |
| 83 | if (!coreInfo.isFile()) { |
| 84 | reportError(i18n("Core is not a file")); |
| 85 | return; |
| 86 | } |
| 87 | if (!coreInfo.isReadable()) { |
| 88 | reportError(i18n("Core file is not readable")); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | m_ui.selectionValidWidget->animatedHide(); |
| 93 | m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); |
| 94 | } |
| 95 |
nothing calls this directly
no test coverage detected