mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
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.
This commit is contained in:
parent
1032ae0140
commit
705cee528a
Notes:
sideshowbarker
2024-07-19 07:24:49 +09:00
Author: https://github.com/awesomekling
Commit: 705cee528a
18 changed files with 135 additions and 158 deletions
|
@ -199,11 +199,9 @@ Menu& AbstractTableView::ensure_header_context_menu()
|
|||
for (int column = 0; column < model()->column_count(); ++column) {
|
||||
auto& column_data = this->column_data(column);
|
||||
auto name = model()->column_name(column);
|
||||
column_data.visibility_action = Action::create(name, [this, column](Action& action) {
|
||||
action.set_checked(!action.is_checked());
|
||||
column_data.visibility_action = Action::create_checkable(name, [this, column](auto& action) {
|
||||
set_column_hidden(column, !action.is_checked());
|
||||
});
|
||||
column_data.visibility_action->set_checkable(true);
|
||||
column_data.visibility_action->set_checked(true);
|
||||
|
||||
m_header_context_menu->add_action(*column_data.visibility_action);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue