Plan document export success messages
This commit is contained in:
@@ -168,6 +168,12 @@ struct PlanExportTargetArgs {
|
||||
std::string suffix;
|
||||
};
|
||||
|
||||
struct PlanExportMessageArgs {
|
||||
std::string kind = "equirectangular";
|
||||
std::string destination = "work";
|
||||
std::string detail = "D:/Paint";
|
||||
};
|
||||
|
||||
struct PlanExportStartArgs {
|
||||
bool requires_license = false;
|
||||
bool license_valid = true;
|
||||
@@ -1943,6 +1949,123 @@ pp::foundation::Result<pp::app::DocumentExportMenuKind> parse_document_export_me
|
||||
pp::foundation::Status::invalid_argument("unknown export menu kind"));
|
||||
}
|
||||
|
||||
const char* document_export_success_kind_name(pp::app::DocumentExportSuccessKind kind) noexcept
|
||||
{
|
||||
switch (kind) {
|
||||
case pp::app::DocumentExportSuccessKind::equirectangular:
|
||||
return "equirectangular";
|
||||
case pp::app::DocumentExportSuccessKind::layers:
|
||||
return "layers";
|
||||
case pp::app::DocumentExportSuccessKind::animation_frames:
|
||||
return "animation-frames";
|
||||
case pp::app::DocumentExportSuccessKind::depth:
|
||||
return "depth";
|
||||
case pp::app::DocumentExportSuccessKind::cube_faces:
|
||||
return "cube-faces";
|
||||
case pp::app::DocumentExportSuccessKind::animation_mp4:
|
||||
return "animation-mp4";
|
||||
case pp::app::DocumentExportSuccessKind::timelapse:
|
||||
return "timelapse";
|
||||
}
|
||||
|
||||
return "equirectangular";
|
||||
}
|
||||
|
||||
const char* document_export_success_destination_name(
|
||||
pp::app::DocumentExportSuccessDestination destination) noexcept
|
||||
{
|
||||
switch (destination) {
|
||||
case pp::app::DocumentExportSuccessDestination::suppressed:
|
||||
return "suppressed";
|
||||
case pp::app::DocumentExportSuccessDestination::photos:
|
||||
return "photos";
|
||||
case pp::app::DocumentExportSuccessDestination::pictures_panopainter:
|
||||
return "pictures-panopainter";
|
||||
case pp::app::DocumentExportSuccessDestination::files_panopainter:
|
||||
return "files-panopainter";
|
||||
case pp::app::DocumentExportSuccessDestination::work_directory:
|
||||
return "work-directory";
|
||||
case pp::app::DocumentExportSuccessDestination::path:
|
||||
return "path";
|
||||
case pp::app::DocumentExportSuccessDestination::generic_success:
|
||||
return "generic-success";
|
||||
}
|
||||
|
||||
return "suppressed";
|
||||
}
|
||||
|
||||
pp::foundation::Result<pp::app::DocumentExportSuccessKind> parse_document_export_success_kind(
|
||||
std::string_view kind)
|
||||
{
|
||||
if (kind == "equirectangular" || kind == "equirect" || kind == "image") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::equirectangular);
|
||||
}
|
||||
if (kind == "layers") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::layers);
|
||||
}
|
||||
if (kind == "animation-frames" || kind == "frames") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::animation_frames);
|
||||
}
|
||||
if (kind == "depth") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::depth);
|
||||
}
|
||||
if (kind == "cube-faces" || kind == "cube") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::cube_faces);
|
||||
}
|
||||
if (kind == "animation-mp4" || kind == "mp4") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::animation_mp4);
|
||||
}
|
||||
if (kind == "timelapse") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::success(
|
||||
pp::app::DocumentExportSuccessKind::timelapse);
|
||||
}
|
||||
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessKind>::failure(
|
||||
pp::foundation::Status::invalid_argument("unknown export message kind"));
|
||||
}
|
||||
|
||||
pp::foundation::Result<pp::app::DocumentExportSuccessDestination> parse_document_export_success_destination(
|
||||
std::string_view destination)
|
||||
{
|
||||
if (destination == "suppressed" || destination == "none") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::suppressed);
|
||||
}
|
||||
if (destination == "photos") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::photos);
|
||||
}
|
||||
if (destination == "pictures" || destination == "pictures-panopainter") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::pictures_panopainter);
|
||||
}
|
||||
if (destination == "files" || destination == "files-panopainter") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::files_panopainter);
|
||||
}
|
||||
if (destination == "work" || destination == "work-directory") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::work_directory);
|
||||
}
|
||||
if (destination == "path") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::path);
|
||||
}
|
||||
if (destination == "success" || destination == "generic-success") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::success(
|
||||
pp::app::DocumentExportSuccessDestination::generic_success);
|
||||
}
|
||||
|
||||
return pp::foundation::Result<pp::app::DocumentExportSuccessDestination>::failure(
|
||||
pp::foundation::Status::invalid_argument("unknown export message destination"));
|
||||
}
|
||||
|
||||
const char* cloud_upload_action_name(pp::app::CloudUploadAction action) noexcept
|
||||
{
|
||||
switch (action) {
|
||||
@@ -2234,6 +2357,7 @@ void print_help()
|
||||
<< " plan-export-start [--requires-license] [--demo] [--no-canvas]\n"
|
||||
<< " plan-export-menu --kind jpeg|png|layers|cube-faces|depth|animation-frames|animation-mp4|timelapse [--demo] [--no-canvas]\n"
|
||||
<< " plan-export-target --kind file|collection|stem|name --doc-name NAME [--work-dir DIR] [--directory DIR] [--extension EXT] [--suffix SUFFIX]\n"
|
||||
<< " plan-export-message --kind equirectangular|layers|animation-frames|depth|cube-faces|animation-mp4|timelapse --destination photos|pictures|files|work|path|success|suppressed [--detail TEXT]\n"
|
||||
<< " plan-cloud-upload [--no-canvas] [--new-document] [--unsaved]\n"
|
||||
<< " plan-cloud-browse [--no-canvas] [--selected-file FILE]\n"
|
||||
<< " plan-cloud-upload-all [--file-count N] [--no-progress-ui]\n"
|
||||
@@ -3588,6 +3712,74 @@ int plan_export_menu(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_export_message_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
PlanExportMessageArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string_view key(argv[i]);
|
||||
if (key == "--kind") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
args.kind = argv[++i];
|
||||
} else if (key == "--destination") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
args.destination = argv[++i];
|
||||
} else if (key == "--detail") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
args.detail = argv[++i];
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
int plan_export_message(int argc, char** argv)
|
||||
{
|
||||
PlanExportMessageArgs args;
|
||||
const auto status = parse_plan_export_message_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("plan-export-message", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto kind = parse_document_export_success_kind(args.kind);
|
||||
if (!kind) {
|
||||
print_error("plan-export-message", kind.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto destination = parse_document_export_success_destination(args.destination);
|
||||
if (!destination) {
|
||||
print_error("plan-export-message", destination.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto plan = pp::app::plan_document_export_success_dialog(
|
||||
kind.value(),
|
||||
destination.value(),
|
||||
args.detail);
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-export-message\""
|
||||
<< ",\"state\":{\"kind\":\"" << json_escape(args.kind)
|
||||
<< "\",\"destination\":\"" << json_escape(args.destination)
|
||||
<< "\",\"detail\":\"" << json_escape(args.detail)
|
||||
<< "\"},\"plan\":{\"kind\":\"" << document_export_success_kind_name(plan.kind)
|
||||
<< "\",\"destination\":\"" << document_export_success_destination_name(plan.destination)
|
||||
<< "\",\"showDialog\":" << json_bool(plan.show_dialog)
|
||||
<< ",\"title\":\"" << json_escape(plan.dialog.title)
|
||||
<< "\",\"message\":\"" << json_escape(plan.dialog.message)
|
||||
<< "\"}}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_cloud_upload_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
@@ -11187,6 +11379,10 @@ int main(int argc, char** argv)
|
||||
return plan_export_target(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-export-message") {
|
||||
return plan_export_message(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-cloud-upload") {
|
||||
return plan_cloud_upload(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user