| 535 | } |
| 536 | |
| 537 | void ContainersView::deleteContainer(BoxedContainer* container) { |
| 538 | BString label; |
| 539 | if (!container->getApps().size()) { |
| 540 | label = getTranslationWithFormat(Msg::CONTAINER_VIEW_DELETE_CONFIRMATION, true, container->getName()); |
| 541 | } else { |
| 542 | label = ""; |
| 543 | |
| 544 | for (auto& app : container->getApps()) { |
| 545 | if (label.length() != 0) { |
| 546 | label += ", "; |
| 547 | } |
| 548 | label += app->getName(); |
| 549 | } |
| 550 | label = getTranslationWithFormat(Msg::CONTAINER_VIEW_DELETE_CONFIRMATION_WITH_APPS, true, container->getName(), label); |
| 551 | } |
| 552 | runOnMainUI([label, this, container]() { |
| 553 | new YesNoDlg(Msg::GENERIC_DLG_CONFIRM_TITLE, label, [this, container](bool yes) { |
| 554 | if (yes) { |
| 555 | runOnMainUI([this, container]() { |
| 556 | container->deleteContainerFromFilesystem(); |
| 557 | BString containerDir; |
| 558 | |
| 559 | if (currentContainer != container) { |
| 560 | containerDir = currentContainer->getDir(); |
| 561 | } |
| 562 | BoxedwineData::reloadContainers(); |
| 563 | gotoView(VIEW_CONTAINERS, containerDir); |
| 564 | return false; |
| 565 | }); |
| 566 | } |
| 567 | }); |
| 568 | return false; |
| 569 | }); |
| 570 | } |
| 571 | |
| 572 | bool ContainersView::saveChanges() { |
| 573 | if (this->currentContainer && containerNameControl->getText().length() == 0) { |
no test coverage detected