summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorhuttongrabiel <huttonthomas@icloud.com>2023-04-02 16:32:23 -0700
committerSam Atkins <atkinssj@gmail.com>2023-04-29 12:09:08 +0100
commit8bc232e6be928812cb4f68538ae5331cbf61a686 (patch)
treea0879ce4c8d1da601af7c934e5b90e45b54fa8d8 /Userland/Applications
parent7c204745ee9d052e9a872503c98a3ab7fa1d479b (diff)
downloadserenity-8bc232e6be928812cb4f68538ae5331cbf61a686.zip
Spreadsheet: Enable the ability to undo/redo changes in cell color
Cells can be updated with new background/foreground colors and then this action can be undone/redone.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index d0499be60c..8d0b2abd5f 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -485,12 +485,18 @@ void SpreadsheetWidget::change_cell_static_color_format(Spreadsheet::FormatType
auto dialog = GUI::ColorPicker::construct(Color::White, window(), "Select Color");
if (dialog->exec() == GUI::Dialog::ExecResult::OK) {
+ Vector<CellChange> cell_changes;
for (auto& position : current_worksheet_if_available()->selected_cells()) {
+ auto* cell = current_worksheet_if_available()->at(position);
+ auto previous_type_metadata = cell->type_metadata();
if (format_type == Spreadsheet::FormatType::Background)
- current_worksheet_if_available()->at(position)->type_metadata().static_format.background_color = dialog->color();
+ cell->type_metadata().static_format.background_color = dialog->color();
else
- current_worksheet_if_available()->at(position)->type_metadata().static_format.foreground_color = dialog->color();
+ cell->type_metadata().static_format.foreground_color = dialog->color();
+ cell_changes.append(CellChange(*cell, previous_type_metadata));
}
+ undo_stack().push(make<CellsUndoMetadataCommand>(move(cell_changes)));
+ window()->set_modified(true);
}
}