summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere96@gmail.com>2022-09-19 21:23:40 +0200
committerTim Flynn <trflynn89@pm.me>2022-09-20 13:12:00 -0400
commit6f69f4bb5e790b80a0314a8d80bffba3351c966d (patch)
tree9e68623682c6ceec1ad596ca0bcb193d4f34d1c6 /Userland
parenta1d98b825d0255d4d35f435d8381d541fc56f48b (diff)
downloadserenity-6f69f4bb5e790b80a0314a8d80bffba3351c966d.zip
Calendar: Update month view on first_day_of_week setting change
Now when the user changes their preferred first day of the week in the Calendar Settings, the Calendar application and applet views are update accordingly without needing to restart them.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Calendar/main.cpp1
-rw-r--r--Userland/Libraries/LibGUI/Calendar.cpp9
-rw-r--r--Userland/Libraries/LibGUI/Calendar.h7
-rw-r--r--Userland/Services/Taskbar/main.cpp1
4 files changed, 17 insertions, 1 deletions
diff --git a/Userland/Applications/Calendar/main.cpp b/Userland/Applications/Calendar/main.cpp
index 54f0e56042..a69474281c 100644
--- a/Userland/Applications/Calendar/main.cpp
+++ b/Userland/Applications/Calendar/main.cpp
@@ -27,6 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
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::unveil("/etc/timezone", "r"));
diff --git a/Userland/Libraries/LibGUI/Calendar.cpp b/Userland/Libraries/LibGUI/Calendar.cpp
index a9be42687f..7c12e45deb 100644
--- a/Userland/Libraries/LibGUI/Calendar.cpp
+++ b/Userland/Libraries/LibGUI/Calendar.cpp
@@ -754,4 +754,13 @@ size_t Calendar::day_of_week_index(String const& day_name)
auto const& day_names = AK::long_day_names;
return AK::find_index(day_names.begin(), day_names.end(), day_name);
}
+
+void Calendar::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
+{
+ VERIFY(domain == "Calendar");
+ if (group == "View" && key == "FirstDayOfWeek") {
+ m_first_day_of_week = static_cast<DayOfWeek>(day_of_week_index(value));
+ update_tiles(m_view_year, m_view_month);
+ }
+}
}
diff --git a/Userland/Libraries/LibGUI/Calendar.h b/Userland/Libraries/LibGUI/Calendar.h
index 79c105d913..56a2c394bf 100644
--- a/Userland/Libraries/LibGUI/Calendar.h
+++ b/Userland/Libraries/LibGUI/Calendar.h
@@ -8,13 +8,16 @@
#pragma once
#include <AK/String.h>
+#include <LibConfig/Listener.h>
#include <LibCore/DateTime.h>
#include <LibGUI/Frame.h>
#include <LibGUI/Widget.h>
namespace GUI {
-class Calendar final : public GUI::Frame {
+class Calendar final
+ : public GUI::Frame
+ , public Config::Listener {
C_OBJECT(Calendar)
public:
@@ -67,6 +70,8 @@ public:
m_unadjusted_tile_size.set_height(height);
}
+ virtual void config_string_did_change(String const&, String const&, String const&, String const&) override;
+
Function<void()> on_tile_click;
Function<void()> on_tile_doubleclick;
Function<void()> on_month_click;
diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp
index 25b817ccff..6777fda649 100644
--- a/Userland/Services/Taskbar/main.cpp
+++ b/Userland/Services/Taskbar/main.cpp
@@ -50,6 +50,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app = TRY(GUI::Application::try_create(arguments));
Config::pledge_domains({ "Taskbar", "Calendar" });
Config::monitor_domain("Taskbar");
+ Config::monitor_domain("Calendar");
app->event_loop().register_signal(SIGCHLD, [](int) {
// Wait all available children
while (waitpid(-1, nullptr, WNOHANG) > 0)