|
4 | 4 | #include <LibDraw/PNGLoader.h>
|
5 | 5 | #include <LibGUI/GAboutDialog.h>
|
6 | 6 | #include <LibGUI/GAction.h>
|
| 7 | +#include <LibGUI/GActionGroup.h> |
7 | 8 | #include <LibGUI/GApplication.h>
|
8 | 9 | #include <LibGUI/GBoxLayout.h>
|
9 | 10 | #include <LibGUI/GFontDatabase.h>
|
@@ -223,16 +224,25 @@ int main(int argc, char** argv)
|
223 | 224 | edit_menu->add_action(terminal->paste_action());
|
224 | 225 | menubar->add_menu(move(edit_menu));
|
225 | 226 |
|
| 227 | + |
| 228 | + GActionGroup font_action_group; |
| 229 | + font_action_group.set_exclusive(true); |
226 | 230 | auto font_menu = GMenu::construct("Font");
|
227 | 231 | GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
|
228 |
| - font_menu->add_action(GAction::create(font_name, [&](const GAction& action) { |
| 232 | + auto action = GAction::create(font_name, [&](GAction& action) { |
| 233 | + action.set_checked(true); |
229 | 234 | terminal->set_font(GFontDatabase::the().get_by_name(action.text()));
|
230 | 235 | auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
|
231 | 236 | ASSERT(metadata.has_value());
|
232 | 237 | config->write_entry("Text", "Font", metadata.value().path);
|
233 | 238 | config->sync();
|
234 | 239 | terminal->force_repaint();
|
235 |
| - })); |
| 240 | + }); |
| 241 | + font_action_group.add_action(*action); |
| 242 | + action->set_checkable(true); |
| 243 | + if (terminal->font().name() == font_name) |
| 244 | + action->set_checked(true); |
| 245 | + font_menu->add_action(*action); |
236 | 246 | });
|
237 | 247 | menubar->add_menu(move(font_menu));
|
238 | 248 |
|
|
0 commit comments