summaryrefslogtreecommitdiff
path: root/Applications/Terminal
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-21 17:19:27 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-21 17:21:28 +0200
commit705cee528a803b1671d16eeaf222d3318708500b (patch)
treea80dc8135ed1a15fddd4c26c0e52fd2c241820e7 /Applications/Terminal
parent1032ae014053ccf5482b78465f02554165212ba9 (diff)
downloadserenity-705cee528a803b1671d16eeaf222d3318708500b.zip
LibGUI: Make it easier to create checkable GUI::Actions
This patch adds GUI::Action::create_checkable() helpers that work just like the existing create() helpers, but the actions become checkable(!) Clients are no longer required to manage the checked state of their actions manually, but instead they will be checked/unchecked as needed by GUI::Action itself before the activation hook is fired.
Diffstat (limited to 'Applications/Terminal')
-rw-r--r--Applications/Terminal/main.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp
index a89a5c3a79..1fda2345c1 100644
--- a/Applications/Terminal/main.cpp
+++ b/Applications/Terminal/main.cpp
@@ -278,8 +278,7 @@ int main(int argc, char** argv)
font_action_group.set_exclusive(true);
auto& font_menu = menubar->add_menu("Font");
GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
- auto action = GUI::Action::create(font_name, [&](GUI::Action& action) {
- action.set_checked(true);
+ auto action = GUI::Action::create_checkable(font_name, [&](auto& action) {
terminal.set_font(GUI::FontDatabase::the().get_by_name(action.text()));
auto metadata = GUI::FontDatabase::the().get_metadata_by_name(action.text());
ASSERT(metadata.has_value());
@@ -288,7 +287,6 @@ int main(int argc, char** argv)
terminal.force_repaint();
});
font_action_group.add_action(*action);
- action->set_checkable(true);
if (terminal.font().name() == font_name)
action->set_checked(true);
font_menu.add_action(*action);