summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere96@gmail.com>2022-07-17 23:29:44 +0200
committerTim Flynn <trflynn89@pm.me>2022-09-20 13:12:00 -0400
commitd3601aedc5a8126a80da4fabc8c841d1fad13b57 (patch)
tree35612a4ad2ff65d27db74153237e750ddc7558da
parent6f69f4bb5e790b80a0314a8d80bffba3351c966d (diff)
downloadserenity-d3601aedc5a8126a80da4fabc8c841d1fad13b57.zip
Calendar: Add Settings button to configure the Calendar
-rw-r--r--Userland/Applications/Calendar/main.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Applications/Calendar/main.cpp b/Userland/Applications/Calendar/main.cpp
index a69474281c..94515e1065 100644
--- a/Userland/Applications/Calendar/main.cpp
+++ b/Userland/Applications/Calendar/main.cpp
@@ -16,22 +16,24 @@
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Menubar.h>
+#include <LibGUI/Process.h>
#include <LibGUI/Toolbar.h>
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- TRY(Core::System::pledge("stdio recvfd sendfd rpath unix"));
+ TRY(Core::System::pledge("stdio recvfd sendfd rpath proc exec unix"));
auto app = TRY(GUI::Application::try_create(arguments));
Config::pledge_domain("Calendar");
Config::monitor_domain("Calendar");
- TRY(Core::System::pledge("stdio recvfd sendfd rpath"));
+ TRY(Core::System::pledge("stdio recvfd sendfd rpath proc exec"));
TRY(Core::System::unveil("/etc/timezone", "r"));
TRY(Core::System::unveil("/res", "r"));
+ TRY(Core::System::unveil("/bin/CalendarSettings", "x"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-calendar"sv));
@@ -104,6 +106,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (default_view == "Year")
view_year_action->set_checked(true);
+ auto open_settings_action = GUI::Action::create("&Settings", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png"sv)), [&](GUI::Action const&) {
+ GUI::Process::spawn_or_show_error(window, "/bin/CalendarSettings"sv);
+ });
+
(void)TRY(toolbar->try_add_action(prev_date_action));
(void)TRY(toolbar->try_add_action(next_date_action));
TRY(toolbar->try_add_separator());
@@ -112,6 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(toolbar->try_add_separator());
(void)TRY(toolbar->try_add_action(view_month_action));
(void)TRY(toolbar->try_add_action(view_year_action));
+ (void)TRY(toolbar->try_add_action(open_settings_action));
calendar->on_tile_doubleclick = [&] {
AddEventDialog::show(calendar->selected_date(), window);
@@ -126,6 +133,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
[&](const GUI::Action&) {
AddEventDialog::show(calendar->selected_date(), window);
}));
+ file_menu.add_action(open_settings_action);
TRY(file_menu.try_add_separator());