Add about menu service boundary

This commit is contained in:
2026-06-03 12:47:15 +02:00
parent fb111dcdc9
commit b67f3d63cf
5 changed files with 219 additions and 46 deletions

View File

@@ -1,5 +1,7 @@
#pragma once
#include "foundation/result.h"
#include <string>
namespace pp::app {
@@ -31,6 +33,17 @@ struct AboutMenuPlan {
int performance_updates_per_iteration = 0;
};
class AboutMenuServices {
public:
virtual ~AboutMenuServices() = default;
virtual void show_user_manual() = 0;
virtual void show_about_dialog() = 0;
virtual void show_whats_new_dialog() = 0;
virtual void trigger_crash_test() = 0;
virtual void run_performance_test(const AboutMenuPlan& plan) = 0;
};
[[nodiscard]] inline AboutMenuPlan plan_about_menu_command(
AboutMenuCommand command,
int version_major,
@@ -83,4 +96,31 @@ struct AboutMenuPlan {
return plan;
}
[[nodiscard]] inline pp::foundation::Status execute_about_menu_plan(
const AboutMenuPlan& plan,
AboutMenuServices& services)
{
switch (plan.action) {
case AboutMenuAction::show_user_manual:
services.show_user_manual();
return pp::foundation::Status::success();
case AboutMenuAction::show_about_dialog:
services.show_about_dialog();
return pp::foundation::Status::success();
case AboutMenuAction::show_whats_new_dialog:
services.show_whats_new_dialog();
return pp::foundation::Status::success();
case AboutMenuAction::trigger_crash_test:
services.trigger_crash_test();
return pp::foundation::Status::success();
case AboutMenuAction::run_performance_test:
services.run_performance_test(plan);
return pp::foundation::Status::success();
case AboutMenuAction::no_op_unavailable:
return pp::foundation::Status::success();
}
return pp::foundation::Status::invalid_argument("unknown about menu action");
}
}