Centralize legacy document open bridge
This commit is contained in:
64
src/app.cpp
64
src/app.cpp
@@ -10,7 +10,7 @@
|
||||
#include "app_core/document_recording.h"
|
||||
#include "app_core/document_route.h"
|
||||
#include "app_core/document_session.h"
|
||||
#include "legacy_history_services.h"
|
||||
#include "legacy_document_open_services.h"
|
||||
#include "legacy_recording_services.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
@@ -197,65 +197,9 @@ void App::open_document(std::string path)
|
||||
const bool has_unsaved_project =
|
||||
route.value().kind == pp::app::DocumentOpenKind::open_project && Canvas::I->m_unsaved;
|
||||
const auto open_plan = pp::app::plan_document_open(route.value().kind, has_unsaved_project);
|
||||
if (open_plan == pp::app::DocumentOpenPlanAction::prompt_import_abr)
|
||||
{
|
||||
auto mb = message_box("Import ABR", "Would you like to import the brushes?", true);
|
||||
mb->on_submit = [this, path] (Node* target) {
|
||||
std::thread(&NodePanelBrushPreset::import_abr, presets, path).detach();
|
||||
target->destroy();
|
||||
};
|
||||
}
|
||||
else if (open_plan == pp::app::DocumentOpenPlanAction::prompt_import_ppbr)
|
||||
{
|
||||
auto mb = message_box("Import PPBR", "Would you like to import the brushes?", true);
|
||||
mb->on_submit = [this, path] (Node* target) {
|
||||
std::thread(&NodePanelBrushPreset::import_ppbr, presets, path).detach();
|
||||
target->destroy();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::string base = route.value().directory;
|
||||
const std::string name = route.value().name;
|
||||
auto open_action = [this, path, base, name] {
|
||||
doc_name = name;
|
||||
doc_dir = base;
|
||||
doc_path = path;
|
||||
canvas->reset_camera();
|
||||
layers->clear();
|
||||
canvas->m_canvas->project_open(path, [this](bool success){
|
||||
// on complete
|
||||
if (success)
|
||||
{
|
||||
title_update();
|
||||
for (int layer_index = 0; layer_index < canvas->m_canvas->m_layers.size(); layer_index++)
|
||||
{
|
||||
auto l = layers->add_layer(canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false);
|
||||
l->m_visibility->set_value(canvas->m_canvas->m_layers[layer_index]->m_visible);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message_box("Open Document Error",
|
||||
"There was an error opening the document.\n"
|
||||
"It may be inaccessible or corrupted.");
|
||||
}
|
||||
});
|
||||
pp::panopainter::clear_legacy_history();
|
||||
};
|
||||
if (open_plan == pp::app::DocumentOpenPlanAction::open_project_now)
|
||||
{
|
||||
open_action();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto mb = message_box("Unsaved document", "Do you want to close the unsaved document before opening the file?", true);
|
||||
mb->on_submit = [this, open_action] (Node* target) {
|
||||
open_action();
|
||||
target->destroy();
|
||||
};
|
||||
}
|
||||
}
|
||||
const auto status = pp::panopainter::execute_legacy_document_open_plan(*this, open_plan, route.value());
|
||||
if (!status.ok())
|
||||
LOG("Document open action failed: %s", status.message);
|
||||
}
|
||||
|
||||
bool App::request_close()
|
||||
|
||||
Reference in New Issue
Block a user