diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index 2c646bf41b..4540b738b1 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -174,9 +175,9 @@ void CSVImportDialogPage::update_preview() m_data_preview_table_view->update(); } -Result, String> ImportDialog::make_and_run_for(StringView mime, Core::File& file, Workbook& workbook) +Result, String> ImportDialog::make_and_run_for(GUI::Window* parent, StringView mime, Core::File& file, Workbook& workbook) { - auto wizard = GUI::WizardDialog::construct(GUI::Application::the()->active_window()); + auto wizard = GUI::WizardDialog::construct(parent); wizard->set_title("File Import Wizard"); wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet").bitmap_for_size(16)); diff --git a/Userland/Applications/Spreadsheet/ImportDialog.h b/Userland/Applications/Spreadsheet/ImportDialog.h index 4ba081359a..c0e3a45e21 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.h +++ b/Userland/Applications/Spreadsheet/ImportDialog.h @@ -56,7 +56,7 @@ private: }; struct ImportDialog { - static Result, String> make_and_run_for(StringView mime, Core::File& file, Workbook&); + static Result, String> make_and_run_for(GUI::Window* parent, StringView mime, Core::File& file, Workbook&); }; } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 4160c7110b..50814fbac0 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -26,7 +26,7 @@ namespace Spreadsheet { SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector&& sheets, bool should_add_sheet_if_empty) - : m_workbook(make(move(sheets))) + : m_workbook(make(move(sheets), window())) { set_fill_with_background_color(true); set_layout().set_margins(2); diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index b6d90dd0af..41a133e74a 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -17,12 +17,13 @@ namespace Spreadsheet { -Workbook::Workbook(NonnullRefPtrVector&& sheets) +Workbook::Workbook(NonnullRefPtrVector&& sheets, GUI::Window* parent_window) : m_sheets(move(sheets)) , m_vm(JS::VM::create()) , m_interpreter(JS::Interpreter::create(m_vm)) , m_interpreter_scope(*m_interpreter) , m_main_execution_context(m_vm->heap()) + , m_parent_window(parent_window) { m_workbook_object = m_vm->heap().allocate(m_interpreter->global_object(), *this); m_interpreter->global_object().define_direct_property("workbook", workbook_object(), JS::default_attributes); @@ -62,7 +63,7 @@ Result Workbook::load(StringView filename) auto mime = Core::guess_mime_type_based_on_filename(filename); // Make an import dialog, we might need to import it. - auto result = ImportDialog::make_and_run_for(mime, file_or_error.value(), *this); + auto result = ImportDialog::make_and_run_for(m_parent_window, mime, file_or_error.value(), *this); if (result.is_error()) return result.error(); diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h index 99206d0e6b..7fa7946136 100644 --- a/Userland/Applications/Spreadsheet/Workbook.h +++ b/Userland/Applications/Spreadsheet/Workbook.h @@ -15,7 +15,7 @@ namespace Spreadsheet { class Workbook { public: - Workbook(NonnullRefPtrVector&& sheets); + Workbook(NonnullRefPtrVector&& sheets, GUI::Window* parent_window); Result save(StringView filename); Result load(StringView filename); @@ -48,6 +48,7 @@ private: JS::VM::InterpreterExecutionScope m_interpreter_scope; WorkbookObject* m_workbook_object { nullptr }; JS::ExecutionContext m_main_execution_context; + GUI::Window* m_parent_window { nullptr }; String m_current_filename; bool m_dirty { false };