mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibGUI: Display hidden columns as hidden
Until now, hidden columns were displayed as visible in the context menu. An easy way to reproduce this is: - Open the TextEditor - Ctrl-O to open the file selector - Switch to table view - Right-click the header Expected behavior: Hidden columns like 'Owner' and 'Group' should not have a checkmark, because they are hidden. Actual behavior: They did have a checkmark. Clicking on it to 'hide' the already hidden column removed the checkmark, but was a no-op to the table view. This commit fixes this behavior, by correctly initializing the context menu, and properly updating the context menu if external code calls 'set_column_hidden' later.
This commit is contained in:
parent
55ff392835
commit
ebabce30bd
1 changed files with 4 additions and 1 deletions
|
@ -184,6 +184,9 @@ void AbstractTableView::set_column_hidden(int column, bool hidden)
|
||||||
if (column_data.visibility == !hidden)
|
if (column_data.visibility == !hidden)
|
||||||
return;
|
return;
|
||||||
column_data.visibility = !hidden;
|
column_data.visibility = !hidden;
|
||||||
|
if (column_data.visibility_action) {
|
||||||
|
column_data.visibility_action->set_checked(!hidden);
|
||||||
|
}
|
||||||
update_content_size();
|
update_content_size();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -202,7 +205,7 @@ Menu& AbstractTableView::ensure_header_context_menu()
|
||||||
column_data.visibility_action = Action::create_checkable(name, [this, column](auto& action) {
|
column_data.visibility_action = Action::create_checkable(name, [this, column](auto& action) {
|
||||||
set_column_hidden(column, !action.is_checked());
|
set_column_hidden(column, !action.is_checked());
|
||||||
});
|
});
|
||||||
column_data.visibility_action->set_checked(true);
|
column_data.visibility_action->set_checked(column_data.visibility);
|
||||||
|
|
||||||
m_header_context_menu->add_action(*column_data.visibility_action);
|
m_header_context_menu->add_action(*column_data.visibility_action);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue