| 261 | } |
| 262 | |
| 263 | void FileTree::addAsExecutable(FileTreeItem* item) |
| 264 | { |
| 265 | if (!item) { |
| 266 | item = singleSelection(); |
| 267 | |
| 268 | if (!item) { |
| 269 | return; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | const QString path = item->realPath(); |
| 274 | const QFileInfo target(path); |
| 275 | const auto fec = spawn::getFileExecutionContext(m_tree->window(), target); |
| 276 | |
| 277 | switch (fec.type) { |
| 278 | case spawn::FileExecutionTypes::Executable: { |
| 279 | const QString name = QInputDialog::getText( |
| 280 | m_tree->window(), tr("Enter Name"), tr("Enter a name for the executable"), |
| 281 | QLineEdit::Normal, target.completeBaseName()); |
| 282 | |
| 283 | if (!name.isEmpty()) { |
| 284 | // Note: If this already exists, you'll lose custom settings |
| 285 | m_core.executablesList()->setExecutable( |
| 286 | Executable() |
| 287 | .title(name) |
| 288 | .binaryInfo(fec.binary) |
| 289 | .arguments(fec.arguments) |
| 290 | .workingDirectory(target.absolutePath())); |
| 291 | |
| 292 | emit executablesChanged(); |
| 293 | } |
| 294 | |
| 295 | break; |
| 296 | } |
| 297 | |
| 298 | case spawn::FileExecutionTypes::Other: // fall-through |
| 299 | default: { |
| 300 | QMessageBox::information(m_tree->window(), tr("Not an executable"), |
| 301 | tr("This is not a recognized executable.")); |
| 302 | |
| 303 | break; |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | void FileTree::exploreOrigin(FileTreeItem* item) |
| 309 | { |
nothing calls this directly
no test coverage detected