Make document session history effects explicit

This commit is contained in:
2026-06-12 19:16:24 +02:00
parent a4cc251c68
commit 34a9e91099
5 changed files with 247 additions and 4 deletions

View File

@@ -2,10 +2,10 @@
#include "legacy_document_open_services.h"
#include "action.h"
#include "app.h"
#include "legacy_brush_package_import_services.h"
#include "legacy_canvas_view_services.h"
#include "legacy_history_services.h"
#include "legacy_ui_overlay_services.h"
#include "log.h"
#include "node_panel_brush.h"
@@ -14,6 +14,30 @@
namespace pp::panopainter {
namespace {
class LegacyDocumentHistoryServices final : public pp::app::HistoryUiServices {
public:
void invoke_undo() override
{
ActionManager::undo();
}
void invoke_redo() override
{
ActionManager::redo();
}
void clear_history() override
{
ActionManager::clear();
}
};
pp::foundation::Status apply_document_history(const pp::app::HistoryUiPlan& plan)
{
LegacyDocumentHistoryServices services;
return pp::app::execute_history_ui_plan(plan, services);
}
void open_legacy_project(App& app, const pp::app::DocumentOpenRoute& route)
{
app.doc_name = route.name;
@@ -41,7 +65,10 @@ void open_legacy_project(App& app, const pp::app::DocumentOpenRoute& route)
"It may be inaccessible or corrupted.");
}
});
pp::panopainter::clear_legacy_history();
const auto history_status = apply_document_history(pp::app::plan_document_open_history(route));
if (!history_status.ok()) {
LOG("Project open history effect failed: %s", history_status.message);
}
}
class LegacyDocumentOpenServices final : public pp::app::DocumentOpenServices {