mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:17:36 +00:00
LibGUI+Userland: Remove Toolbar::try_add_{action,separator}()
These calls largely occur during initialization before there's unsaved state worth preserving
This commit is contained in:
parent
eafdb06d87
commit
57f3b18109
10 changed files with 109 additions and 131 deletions
|
@ -104,33 +104,33 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
});
|
||||
|
||||
toggle_running_action->set_checkable(true);
|
||||
auto toggle_running_toolbar_button = TRY(main_toolbar.try_add_action(toggle_running_action));
|
||||
auto& toggle_running_toolbar_button = main_toolbar.add_action(toggle_running_action);
|
||||
|
||||
auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](const GUI::Action&) {
|
||||
statusbar.set_text(click_tip);
|
||||
board_widget->run_generation();
|
||||
});
|
||||
(void)TRY(main_toolbar.try_add_action(run_one_generation_action));
|
||||
main_toolbar.add_action(run_one_generation_action);
|
||||
|
||||
auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"sv)), [&](auto&) {
|
||||
statusbar.set_text(click_tip);
|
||||
board_widget->clear_cells();
|
||||
board_widget->update();
|
||||
});
|
||||
(void)TRY(main_toolbar.try_add_action(clear_board_action));
|
||||
main_toolbar.add_action(clear_board_action);
|
||||
|
||||
auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
statusbar.set_text(click_tip);
|
||||
board_widget->randomize_cells();
|
||||
board_widget->update();
|
||||
});
|
||||
(void)TRY(main_toolbar.try_add_action(randomize_cells_action));
|
||||
main_toolbar.add_action(randomize_cells_action);
|
||||
|
||||
auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"sv)), [&](auto&) {
|
||||
board_widget->selected_pattern()->rotate_clockwise();
|
||||
});
|
||||
rotate_pattern_action->set_enabled(false);
|
||||
(void)TRY(main_toolbar.try_add_action(rotate_pattern_action));
|
||||
main_toolbar.add_action(rotate_pattern_action);
|
||||
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
|
@ -154,11 +154,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
board_widget->on_running_state_change = [&]() {
|
||||
if (board_widget->is_running()) {
|
||||
statusbar.set_text("Running..."_string);
|
||||
toggle_running_toolbar_button->set_icon(*paused_icon);
|
||||
toggle_running_toolbar_button.set_icon(*paused_icon);
|
||||
main_widget->set_override_cursor(Gfx::StandardCursor::None);
|
||||
} else {
|
||||
statusbar.set_text(click_tip);
|
||||
toggle_running_toolbar_button->set_icon(*play_icon);
|
||||
toggle_running_toolbar_button.set_icon(*play_icon);
|
||||
main_widget->set_override_cursor(Gfx::StandardCursor::Drag);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue