Centralize legacy new document bridge
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#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"
|
||||
#include "node_dialog_browse.h"
|
||||
@@ -183,46 +182,9 @@ void App::dialog_newdoc()
|
||||
return;
|
||||
}
|
||||
|
||||
auto action = [this, dialog, plan = plan.value()] {
|
||||
doc_name = plan.target.name;
|
||||
doc_path = plan.target.path;
|
||||
doc_filename = plan.target.name + ".ppi";
|
||||
doc_dir = plan.target.directory;
|
||||
|
||||
layers->clear();
|
||||
canvas->m_canvas->m_layers.clear();
|
||||
canvas->m_canvas->resize(plan.resolution, plan.resolution);
|
||||
canvas->reset_camera();
|
||||
pp::panopainter::clear_legacy_history();
|
||||
|
||||
layers->add_layer("Default", false, true);
|
||||
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
canvas->m_canvas->m_newdoc = false;
|
||||
title_update();
|
||||
|
||||
dialog->destroy();
|
||||
App::I->hideKeyboard();
|
||||
};
|
||||
|
||||
if (plan.value().write_decision == pp::app::DocumentFileWriteDecision::prompt_overwrite)
|
||||
{
|
||||
// ask confirm is file already exist
|
||||
auto msgbox = new NodeMessageBox();
|
||||
msgbox->set_manager(&layout);
|
||||
msgbox->init();
|
||||
msgbox->m_title->set_text("Warning");
|
||||
msgbox->m_message->set_text("A document with this name already exists, continue?");
|
||||
msgbox->btn_ok->on_click = [this, msgbox, action](Node*) {
|
||||
action();
|
||||
msgbox->destroy();
|
||||
};
|
||||
layout[main_id]->add_child(msgbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
const auto status = pp::panopainter::execute_legacy_new_document_plan(*this, plan.value(), dialog);
|
||||
if (!status.ok())
|
||||
LOG("New document action failed: %s", status.message);
|
||||
|
||||
};
|
||||
dialog->btn_cancel->on_click = [this, dialog](Node*)
|
||||
|
||||
Reference in New Issue
Block a user