diff options
author | Glenford Williams <gw_dev@outlook.com> | 2022-01-09 14:31:51 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-09 20:38:55 +0100 |
commit | f5ff011c1b23575004fa0c1ac800d7dd63432fd0 (patch) | |
tree | 733bfe80941060fa5b63022060ac6777c7dad6a5 /Userland | |
parent | 876424923af03443ed7a3d8c3268051daeb81e0f (diff) | |
download | serenity-f5ff011c1b23575004fa0c1ac800d7dd63432fd0.zip |
Spreadsheet: Properly pass parent window to Workbook
Change the parent of the WizardDialog to that of the Spreadsheet window.
Previously the WizardDialog was using the open file dialog as the
parent resulting in the csv import dialog
Diffstat (limited to 'Userland')
5 files changed, 10 insertions, 7 deletions
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 <LibGUI/StackWidget.h> #include <LibGUI/TableView.h> #include <LibGUI/TextBox.h> +#include <LibGUI/Window.h> #include <LibGUI/Wizards/WizardDialog.h> #include <LibGUI/Wizards/WizardPage.h> @@ -174,9 +175,9 @@ void CSVImportDialogPage::update_preview() m_data_preview_table_view->update(); } -Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(StringView mime, Core::File& file, Workbook& workbook) +Result<NonnullRefPtrVector<Sheet>, 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<NonnullRefPtrVector<Sheet>, String> make_and_run_for(StringView mime, Core::File& file, Workbook&); + static Result<NonnullRefPtrVector<Sheet>, 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<Sheet>&& sheets, bool should_add_sheet_if_empty) - : m_workbook(make<Workbook>(move(sheets))) + : m_workbook(make<Workbook>(move(sheets), window())) { set_fill_with_background_color(true); set_layout<GUI::VerticalBoxLayout>().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<Sheet>&& sheets) +Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window* parent_window) : m_sheets(move(sheets)) , m_vm(JS::VM::create()) , m_interpreter(JS::Interpreter::create<JS::GlobalObject>(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<WorkbookObject>(m_interpreter->global_object(), *this); m_interpreter->global_object().define_direct_property("workbook", workbook_object(), JS::default_attributes); @@ -62,7 +63,7 @@ Result<bool, String> 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<Sheet>&& sheets); + Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window* parent_window); Result<bool, String> save(StringView filename); Result<bool, String> 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 }; |