diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-26 19:15:55 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-26 23:41:38 +0200 |
commit | 696dbc889f8aefd394e32aafe50e2d166c57cf02 (patch) | |
tree | 80c76bc8147825cfa2feda55684053892b4ab30c /Userland | |
parent | c8c58626e9eb09136ea7a558e681ce6e98510690 (diff) | |
download | serenity-696dbc889f8aefd394e32aafe50e2d166c57cf02.zip |
FileManager: Make DirectoryView listen for configuration changes
DirectoryView now inherits from Config::Listener and will update its
view mode immediately if changed from elsewhere.
This is pretty neat. :^)
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/FileManager/DirectoryView.cpp | 11 | ||||
-rw-r--r-- | Userland/Applications/FileManager/DirectoryView.h | 7 | ||||
-rw-r--r-- | Userland/Applications/FileManager/main.cpp | 1 |
3 files changed, 18 insertions, 1 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 45dc8cf635..25dab439b2 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -340,6 +340,17 @@ void DirectoryView::set_view_mode_from_string(String const& mode) } } +void DirectoryView::config_string_did_change(String const& domain, String const& group, String const& key, String const& value) +{ + if (domain != "FileManager" || group != "DirectoryView") + return; + + if (key == "ViewMode") { + set_view_mode_from_string(value); + return; + } +} + void DirectoryView::set_view_mode(ViewMode mode) { if (m_view_mode == mode) diff --git a/Userland/Applications/FileManager/DirectoryView.h b/Userland/Applications/FileManager/DirectoryView.h index e652bfe9d6..1983479595 100644 --- a/Userland/Applications/FileManager/DirectoryView.h +++ b/Userland/Applications/FileManager/DirectoryView.h @@ -8,6 +8,7 @@ #include <AK/URL.h> #include <AK/Vector.h> +#include <LibConfig/Listener.h> #include <LibDesktop/Launcher.h> #include <LibGUI/Action.h> #include <LibGUI/ColumnsView.h> @@ -38,7 +39,8 @@ private: class DirectoryView final : public GUI::StackWidget - , private GUI::ModelClient { + , private GUI::ModelClient + , public Config::Listener { C_OBJECT(DirectoryView); public: @@ -130,6 +132,9 @@ public: GUI::Action& view_as_table_action() { return *m_view_as_table_action; } GUI::Action& view_as_columns_action() { return *m_view_as_columns_action; } + // ^Config::Listener + virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override; + private: explicit DirectoryView(Mode); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 0de4992110..cd84bd754b 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -92,6 +92,7 @@ int main(int argc, char** argv) } Config::pledge_domains({ "FileManager", "WindowManager" }); + Config::monitor_domain("FileManager"); if (is_desktop_mode) return run_in_desktop_mode(); |