From 33fd2c1af9dbecb627a091b34b33bd918fd1c6ab Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 4 Jan 2023 20:41:02 -0500 Subject: [PATCH] LibCards: Add a helper to create an action to open Cards Settings This is a useful shortcut to open the settings from within the game rather than having to go through the system menu. --- Userland/Libraries/LibCards/CardGame.cpp | 14 ++++++++++++++ Userland/Libraries/LibCards/CardGame.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/Userland/Libraries/LibCards/CardGame.cpp b/Userland/Libraries/LibCards/CardGame.cpp index f910003a8d..79410bc880 100644 --- a/Userland/Libraries/LibCards/CardGame.cpp +++ b/Userland/Libraries/LibCards/CardGame.cpp @@ -9,10 +9,24 @@ #include "CardGame.h" #include #include +#include +#include +#include #include namespace Cards { +ErrorOr> make_cards_settings_action(GUI::Window* parent) +{ + auto action = GUI::Action::create( + "&Cards Settings", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/games.png"sv)), [parent](auto&) { + GUI::Process::spawn_or_show_error(parent, "/bin/GamesSettings"sv, Array { "--open-tab", "cards" }); + }, + parent); + action->set_status_tip("Open the Game Settings for Cards"); + return action; +} + CardGame::CardGame() { auto background_color = Gfx::Color::from_string(Config::read_string("Games"sv, "Cards"sv, "BackgroundColor"sv)); diff --git a/Userland/Libraries/LibCards/CardGame.h b/Userland/Libraries/LibCards/CardGame.h index 44c43bbbc3..d739dc84a2 100644 --- a/Userland/Libraries/LibCards/CardGame.h +++ b/Userland/Libraries/LibCards/CardGame.h @@ -6,12 +6,16 @@ #pragma once +#include #include #include +#include #include namespace Cards { +ErrorOr> make_cards_settings_action(GUI::Window* parent = nullptr); + class CardGame : public GUI::Frame , public Config::Listener {