Extract document-session save dialog helper
This commit is contained in:
@@ -121,6 +121,37 @@ void start_document_export_collection(
|
||||
});
|
||||
}
|
||||
|
||||
void wire_document_save_dialog_buttons(
|
||||
App& app,
|
||||
const std::shared_ptr<NodeDialogSave>& dialog,
|
||||
std::function<void()> close_dialog)
|
||||
{
|
||||
dialog->btn_ok->on_click = [&app, dialog](Node*)
|
||||
{
|
||||
std::string name = dialog->input->m_text;
|
||||
const auto plan = pp::app::plan_document_file_save(
|
||||
app.work_path,
|
||||
name,
|
||||
[](const std::string& path) {
|
||||
return Asset::exist(path);
|
||||
});
|
||||
if (!plan)
|
||||
{
|
||||
app.message_box("Warning", "You need to specify a name to file.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto status =
|
||||
pp::panopainter::execute_legacy_document_file_save_plan(app, plan.value(), dialog);
|
||||
if (!status.ok())
|
||||
LOG("Document file save action failed: %s", status.message);
|
||||
};
|
||||
dialog->btn_cancel->on_click = [close_dialog](Node*)
|
||||
{
|
||||
close_dialog();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, int total /*= 0*/)
|
||||
@@ -464,29 +495,7 @@ void App::dialog_save()
|
||||
App::I->hideKeyboard();
|
||||
};
|
||||
|
||||
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||
{
|
||||
std::string name = dialog->input->m_text;
|
||||
const auto plan = pp::app::plan_document_file_save(
|
||||
work_path,
|
||||
name,
|
||||
[](const std::string& path) {
|
||||
return Asset::exist(path);
|
||||
});
|
||||
if (!plan)
|
||||
{
|
||||
message_box("Warning", "You need to specify a name to file.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto status = pp::panopainter::execute_legacy_document_file_save_plan(*this, plan.value(), dialog);
|
||||
if (!status.ok())
|
||||
LOG("Document file save action failed: %s", status.message);
|
||||
};
|
||||
dialog->btn_cancel->on_click = [close_dialog](Node*)
|
||||
{
|
||||
close_dialog();
|
||||
};
|
||||
wire_document_save_dialog_buttons(*this, dialog, close_dialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user