Extract open legacy project result helper
This commit is contained in:
@@ -38,6 +38,26 @@ pp::foundation::Status apply_document_history(const pp::app::HistoryUiPlan& plan
|
|||||||
return pp::app::execute_history_ui_plan(plan, services);
|
return pp::app::execute_history_ui_plan(plan, services);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handle_open_legacy_project_result(App& app, bool success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
app.title_update();
|
||||||
|
for (std::size_t layer_index = 0; layer_index < app.canvas->m_canvas->m_layers.size(); ++layer_index)
|
||||||
|
{
|
||||||
|
auto layer = app.layers->add_layer(app.canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false);
|
||||||
|
layer->m_visibility->set_value(app.canvas->m_canvas->m_layers[layer_index]->m_visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app.message_box(
|
||||||
|
"Open Document Error",
|
||||||
|
"There was an error opening the document.\n"
|
||||||
|
"It may be inaccessible or corrupted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void open_legacy_project(App& app, const pp::app::DocumentOpenRoute& route)
|
void open_legacy_project(App& app, const pp::app::DocumentOpenRoute& route)
|
||||||
{
|
{
|
||||||
app.doc_name = route.name;
|
app.doc_name = route.name;
|
||||||
@@ -48,22 +68,7 @@ void open_legacy_project(App& app, const pp::app::DocumentOpenRoute& route)
|
|||||||
LOG("Project open camera reset failed: %s", reset_status.message);
|
LOG("Project open camera reset failed: %s", reset_status.message);
|
||||||
app.layers->clear();
|
app.layers->clear();
|
||||||
app.canvas->m_canvas->project_open(route.path, [&app](bool success) {
|
app.canvas->m_canvas->project_open(route.path, [&app](bool success) {
|
||||||
if (success)
|
handle_open_legacy_project_result(app, success);
|
||||||
{
|
|
||||||
app.title_update();
|
|
||||||
for (std::size_t layer_index = 0; layer_index < app.canvas->m_canvas->m_layers.size(); ++layer_index)
|
|
||||||
{
|
|
||||||
auto layer = app.layers->add_layer(app.canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false);
|
|
||||||
layer->m_visibility->set_value(app.canvas->m_canvas->m_layers[layer_index]->m_visible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
app.message_box(
|
|
||||||
"Open Document Error",
|
|
||||||
"There was an error opening the document.\n"
|
|
||||||
"It may be inaccessible or corrupted.");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
const auto history_status = apply_document_history(pp::app::plan_document_open_history(route));
|
const auto history_status = apply_document_history(pp::app::plan_document_open_history(route));
|
||||||
if (!history_status.ok()) {
|
if (!history_status.ok()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user