mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
LibGUI: Show command name in GUI::TextEditor undo/redo action text
We can now show things like "Undo Insert Text" and "Redo Remove Text" instead of just "Undo" and "Redo" in menu items. Pretty neat! :^)
This commit is contained in:
parent
c670d8c56d
commit
ce90d87eb6
3 changed files with 27 additions and 0 deletions
|
@ -1636,9 +1636,22 @@ void TextEditor::document_did_change()
|
|||
|
||||
void TextEditor::document_did_update_undo_stack()
|
||||
{
|
||||
auto make_action_text = [](auto prefix, auto suffix) {
|
||||
StringBuilder builder;
|
||||
builder.append(prefix);
|
||||
if (suffix.has_value()) {
|
||||
builder.append(' ');
|
||||
builder.append(suffix.value());
|
||||
}
|
||||
return builder.to_string();
|
||||
};
|
||||
|
||||
m_undo_action->set_enabled(can_undo());
|
||||
m_redo_action->set_enabled(can_redo());
|
||||
|
||||
m_undo_action->set_text(make_action_text("&Undo", document().undo_stack().undo_action_text()));
|
||||
m_redo_action->set_text(make_action_text("&Redo", document().undo_stack().redo_action_text()));
|
||||
|
||||
// FIXME: This is currently firing more often than it should.
|
||||
// Ideally we'd only send this out when the undo stack modified state actually changes.
|
||||
if (on_modified_change)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue