| 377 | } |
| 378 | |
| 379 | bool ExportInstanceDialog::doExport() |
| 380 | { |
| 381 | auto name = FS::RemoveInvalidFilenameChars(m_instance->name()); |
| 382 | |
| 383 | const QString output = QFileDialog::getSaveFileName( |
| 384 | this, tr("Export %1").arg(m_instance->name()), |
| 385 | FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr, QFileDialog::DontConfirmOverwrite); |
| 386 | if (output.isEmpty()) |
| 387 | { |
| 388 | return false; |
| 389 | } |
| 390 | if (QFile::exists(output)) |
| 391 | { |
| 392 | int ret = |
| 393 | QMessageBox::question(this, tr("Overwrite?"), |
| 394 | tr("This file already exists. Do you want to overwrite it?"), |
| 395 | QMessageBox::No, QMessageBox::Yes); |
| 396 | if (ret == QMessageBox::No) |
| 397 | { |
| 398 | return false; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | SaveIcon(m_instance); |
| 403 | |
| 404 | auto & blocked = proxyModel->blockedPaths(); |
| 405 | using std::placeholders::_1; |
| 406 | if (!JlCompress::compressDir(output, m_instance->instanceRoot(), name, std::bind(&SeparatorPrefixTree<'/'>::covers, blocked, _1))) |
| 407 | { |
| 408 | QMessageBox::warning(this, tr("Error"), tr("Unable to export instance")); |
| 409 | return false; |
| 410 | } |
| 411 | return true; |
| 412 | } |
| 413 | |
| 414 | void ExportInstanceDialog::done(int result) |
| 415 | { |
nothing calls this directly
no test coverage detected