Plan document open actions in app core

This commit is contained in:
2026-06-02 23:06:36 +02:00
parent 1df506a176
commit fd1772a417
9 changed files with 179 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "app_core/document_route.h"
#include "foundation/result.h"
#include <cctype>
@@ -46,6 +47,13 @@ enum class DocumentFileWriteDecision {
prompt_overwrite,
};
enum class DocumentOpenPlanAction {
open_project_now,
prompt_discard_unsaved_project,
prompt_import_abr,
prompt_import_ppbr,
};
struct DocumentFileTarget {
std::string name;
std::string directory;
@@ -64,6 +72,24 @@ struct DocumentVersionTarget {
: ProjectOpenDecision::open_now;
}
[[nodiscard]] constexpr DocumentOpenPlanAction plan_document_open(
DocumentOpenKind kind,
bool has_unsaved_changes) noexcept
{
switch (kind) {
case DocumentOpenKind::import_abr:
return DocumentOpenPlanAction::prompt_import_abr;
case DocumentOpenKind::import_ppbr:
return DocumentOpenPlanAction::prompt_import_ppbr;
case DocumentOpenKind::open_project:
return has_unsaved_changes
? DocumentOpenPlanAction::prompt_discard_unsaved_project
: DocumentOpenPlanAction::open_project_now;
}
return DocumentOpenPlanAction::open_project_now;
}
[[nodiscard]] constexpr CloseRequestDecision plan_close_request(
bool has_unsaved_changes,
bool close_prompt_already_open) noexcept