diff options
author | Marcus Nilsson <brainbomb@gmail.com> | 2022-01-09 00:28:05 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-09 20:24:02 +0100 |
commit | 708ec90bbaba6469b289db9b99ff65ff908d78e3 (patch) | |
tree | e47b2b6afee7a9c4d61afc1a83bbb2d2e9063ff6 /Userland | |
parent | 18e6da6d4d150a997290fc98ddc4a80cc2aaa9fc (diff) | |
download | serenity-708ec90bbaba6469b289db9b99ff65ff908d78e3.zip |
LibGUI: Add Menu::set_children_actions_enabled() helper
This adds a helper function to Menu that allows us to set all the
children enabled/disabled.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/Menu.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Menu.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index d5e6da3dd9..9764e64855 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -164,6 +164,14 @@ Action* Menu::action_at(size_t index) return m_items[index].action(); } +void Menu::set_children_actions_enabled(bool enabled) +{ + for (auto& item : m_items) { + if (item.action()) + item.action()->set_enabled(enabled); + } +} + void Menu::visibility_did_change(Badge<WindowServerConnection>, bool visible) { if (m_visible == visible) diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h index de83bdb167..690e814c50 100644 --- a/Userland/Libraries/LibGUI/Menu.h +++ b/Userland/Libraries/LibGUI/Menu.h @@ -45,6 +45,8 @@ public: void visibility_did_change(Badge<WindowServerConnection>, bool visible); + void set_children_actions_enabled(bool enabled); + Function<void(bool)> on_visibility_change; bool is_visible() const { return m_visible; } |