summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbuneri <foo@bar.com>2023-04-21 12:18:54 -0700
committerSam Atkins <atkinssj@gmail.com>2023-04-29 12:14:21 +0100
commita04316403e0fae3848438b496acc866fc2a01313 (patch)
tree574033186dfb2f6c4c5534bc98661a8a0af859e4
parent8bc232e6be928812cb4f68538ae5331cbf61a686 (diff)
downloadserenity-a04316403e0fae3848438b496acc866fc2a01313.zip
Spreadsheet: Add blank sheet when import dialog is cancelled
If you launch the Spreadsheet app by clicking on a CSV (or other supported formats) the import dialog is immediately launched. If you cancel out of the import the application ends up in an empty state where there are no sheets added. When you launch the app normally it defaults to having a blank sheet, so we should have the same behaviour in this scenario to prevent users from having to manually add the new/blank sheet before being able to use the app
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index 8d0b2abd5f..717ff58c1b 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -517,6 +517,9 @@ void SpreadsheetWidget::load_file(String const& filename, Core::File& file)
auto result = m_workbook->open_file(filename, file);
if (result.is_error()) {
GUI::MessageBox::show_error(window(), result.error());
+ if (!m_workbook->has_sheets()) {
+ add_sheet();
+ }
return;
}