Centralize legacy document session bridge
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "app_core/document_session.h"
|
||||
#include "legacy_document_canvas_services.h"
|
||||
#include "legacy_document_layer_services.h"
|
||||
#include "legacy_document_session_services.h"
|
||||
#include "legacy_history_services.h"
|
||||
#include "settings.h"
|
||||
#include "node_dialog_open.h"
|
||||
@@ -23,6 +24,8 @@
|
||||
#define MP4V2_NO_STDINT_DEFS
|
||||
#include <mp4v2/mp4v2.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#ifdef __QUEST__
|
||||
#include "oculus_vr.h"
|
||||
#elif __WEB__
|
||||
@@ -138,34 +141,12 @@ void App::continue_document_workflow_after_optional_save(std::function<void()> a
|
||||
const bool has_canvas = canvas != nullptr;
|
||||
const bool has_unsaved_changes = has_canvas && Canvas::I->m_unsaved;
|
||||
const auto decision = pp::app::plan_document_workflow(has_canvas, has_unsaved_changes);
|
||||
switch (decision) {
|
||||
case pp::app::DocumentWorkflowDecision::unavailable:
|
||||
return;
|
||||
case pp::app::DocumentWorkflowDecision::continue_now:
|
||||
action();
|
||||
return;
|
||||
case pp::app::DocumentWorkflowDecision::prompt_save_before_continue:
|
||||
break;
|
||||
}
|
||||
|
||||
auto m = layout[main_id]->add_child<NodeMessageBox>();
|
||||
m->m_title->set_text("Unsaved document");
|
||||
m->m_message->set_text("Would you like to save this document before closing?");
|
||||
m->btn_ok->m_text->set_text("Yes");
|
||||
m->btn_cancel->m_text->set_text("No");
|
||||
m->btn_ok->on_click = [this, m, action](Node*) {
|
||||
Canvas::I->project_save([this, m, action](bool success) {
|
||||
if (success)
|
||||
action();
|
||||
else
|
||||
message_box("Saving Error", "There was a problem saving the document");
|
||||
});
|
||||
m->destroy();
|
||||
};
|
||||
m->btn_cancel->on_click = [m, action](Node*) {
|
||||
action();
|
||||
m->destroy();
|
||||
};
|
||||
const auto status = pp::panopainter::execute_legacy_document_workflow_decision(
|
||||
*this,
|
||||
decision,
|
||||
std::move(action));
|
||||
if (!status.ok())
|
||||
LOG("Document workflow action failed: %s", status.message);
|
||||
}
|
||||
|
||||
void App::dialog_newdoc()
|
||||
@@ -350,19 +331,9 @@ void App::save_document(pp::app::DocumentSaveIntent intent)
|
||||
Canvas::I->m_newdoc,
|
||||
Canvas::I->m_unsaved,
|
||||
intent);
|
||||
switch (decision) {
|
||||
case pp::app::DocumentSaveDecision::show_save_dialog:
|
||||
dialog_save();
|
||||
break;
|
||||
case pp::app::DocumentSaveDecision::save_existing:
|
||||
Canvas::I->project_save();
|
||||
break;
|
||||
case pp::app::DocumentSaveDecision::save_version:
|
||||
dialog_save_ver();
|
||||
break;
|
||||
case pp::app::DocumentSaveDecision::no_op:
|
||||
break;
|
||||
}
|
||||
const auto status = pp::panopainter::execute_legacy_document_save_decision(*this, decision);
|
||||
if (!status.ok())
|
||||
LOG("Document save action failed: %s", status.message);
|
||||
}
|
||||
|
||||
void App::dialog_save()
|
||||
|
||||
Reference in New Issue
Block a user