Extract document open unsaved prompt helper
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user