Extract document open unsaved prompt helper

This commit is contained in:
2026-06-15 22:31:04 +02:00
parent 459ace29e3
commit 39728e463a

View File

@@ -102,6 +102,18 @@ void prompt_import_brush_package(
};
}
void prompt_discard_unsaved_project(App& app, const pp::app::DocumentOpenRoute& route)
{
auto mb = app.message_box(
"Unsaved document",
"Do you want to close the unsaved document before opening the file?",
true);
mb->on_submit = [&app, route](Node* target) {
open_legacy_project(app, route);
pp::panopainter::close_legacy_dialog_node(*target);
};
}
class LegacyDocumentOpenServices final : public pp::app::DocumentOpenServices {
public:
explicit LegacyDocumentOpenServices(App& app) noexcept
@@ -136,15 +148,7 @@ public:
void prompt_discard_unsaved_project(const pp::app::DocumentOpenRoute& route) override
{
auto* app = &app_;
auto mb = app_.message_box(
"Unsaved document",
"Do you want to close the unsaved document before opening the file?",
true);
mb->on_submit = [app, route](Node* target) {
open_legacy_project(*app, route);
pp::panopainter::close_legacy_dialog_node(*target);
};
pp::panopainter::prompt_discard_unsaved_project(app_, route);
}
private: