From 50c0d0a3b0e4734b611e1db862c70891da242b08 Mon Sep 17 00:00:00 2001 From: Evan Smal Date: Sun, 1 Jan 2023 21:04:08 -0500 Subject: [PATCH] Solitaire: Add link to help page --- Userland/Games/Solitaire/CMakeLists.txt | 2 +- Userland/Games/Solitaire/main.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Userland/Games/Solitaire/CMakeLists.txt b/Userland/Games/Solitaire/CMakeLists.txt index e27cf0daf90..dc4307266da 100644 --- a/Userland/Games/Solitaire/CMakeLists.txt +++ b/Userland/Games/Solitaire/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(Solitaire ICON app-solitaire) -target_link_libraries(Solitaire PRIVATE LibCards LibConfig LibGUI LibGfx LibCore LibMain) +target_link_libraries(Solitaire PRIVATE LibCards LibConfig LibGUI LibDesktop LibGfx LibCore LibMain) diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 2d52635479a..8d7e3b1123d 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -7,10 +7,12 @@ */ #include "Game.h" +#include #include #include #include #include +#include #include #include #include @@ -30,6 +32,11 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-solitaire"sv)); + auto const man_file = "/usr/share/man/man6/Solitaire.md"sv; + + TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_scheme(man_file) })); + TRY(Desktop::Launcher::seal_allowlist()); + Config::pledge_domains({ "Games", "Solitaire" }); Config::monitor_domain("Games"); @@ -208,6 +215,10 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window))); TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Solitaire", app_icon, window))); + TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([&man_file](auto&) { + Desktop::Launcher::open(URL::create_with_file_scheme(man_file), "/bin/Help"); + }))); + window->set_resizable(false); window->resize(Solitaire::Game::width, Solitaire::Game::height + statusbar.max_height().as_int()); window->set_icon(app_icon.bitmap_for_size(16));