From 98fa3736ed016288db60be93e4671167bb852f35 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Thu, 22 Dec 2022 12:55:11 +0100 Subject: [PATCH] HackStudio: Open projects after the action tab was created This change also removes the path argument from the GitWidget constructor because otherwise, the app wouldn't work now, as it doesn't yet know the project path. But it'll be set right away in open_project(), so nothing's lost. :^) --- Userland/DevTools/HackStudio/Git/GitWidget.cpp | 3 +-- Userland/DevTools/HackStudio/Git/GitWidget.h | 2 +- .../DevTools/HackStudio/HackStudioWidget.cpp | 17 ++++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index dd47d4227eb..81778cad462 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -22,8 +22,7 @@ namespace HackStudio { -GitWidget::GitWidget(DeprecatedString const& repo_root) - : m_repo_root(repo_root) +GitWidget::GitWidget() { set_layout(); diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.h b/Userland/DevTools/HackStudio/Git/GitWidget.h index 47c0f076093..7bc7180a37e 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.h +++ b/Userland/DevTools/HackStudio/Git/GitWidget.h @@ -27,7 +27,7 @@ public: void change_repo(DeprecatedString const& repo_root); private: - explicit GitWidget(DeprecatedString const& repo_root); + explicit GitWidget(); bool initialize(); bool initialize_if_needed(); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 1d15bd3d4a6..9177f3e4e3e 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -88,8 +88,6 @@ ErrorOr> HackStudioWidget::create(DeprecatedStri widget->set_layout(); widget->layout()->set_spacing(2); - widget->open_project(path_to_project); - auto& toolbar_container = widget->add(); auto& outer_splitter = widget->add(); @@ -98,14 +96,17 @@ ErrorOr> HackStudioWidget::create(DeprecatedStri auto& left_hand_splitter = outer_splitter.add(); left_hand_splitter.layout()->set_spacing(6); left_hand_splitter.set_preferred_width(150); - widget->create_project_tab(left_hand_splitter); widget->m_project_tree_view_context_menu = widget->create_project_tree_view_context_menu(); - widget->create_open_files_view(left_hand_splitter); - widget->m_right_hand_splitter = outer_splitter.add(); widget->m_right_hand_stack = widget->m_right_hand_splitter->add(); + TRY(widget->create_action_tab(*widget->m_right_hand_splitter)); + + widget->open_project(path_to_project); + widget->create_project_tab(left_hand_splitter); + widget->create_open_files_view(left_hand_splitter); + // Put a placeholder widget front & center since we don't have a file open yet. widget->m_right_hand_stack->add(); @@ -126,8 +127,6 @@ ErrorOr> HackStudioWidget::create(DeprecatedStri widget->m_save_as_action = widget->create_save_as_action(); widget->m_new_project_action = widget->create_new_project_action(); - TRY(widget->create_action_tab(*widget->m_right_hand_splitter)); - widget->m_add_editor_tab_widget_action = widget->create_add_editor_tab_widget_action(); widget->m_add_editor_action = widget->create_add_editor_action(); widget->m_add_terminal_action = widget->create_add_terminal_action(); @@ -257,7 +256,7 @@ void HackStudioWidget::open_project(DeprecatedString const& root_path) m_project_tree_view->set_model(m_project->model()); m_project_tree_view->update(); } - if (m_git_widget && m_git_widget->initialized()) { + if (m_git_widget->initialized()) { m_git_widget->change_repo(root_path); m_git_widget->refresh(); } @@ -1327,7 +1326,7 @@ ErrorOr HackStudioWidget::create_action_tab(GUI::Widget& parent) }; m_disassembly_widget = m_action_tab_widget->add_tab("Disassembly"); - m_git_widget = m_action_tab_widget->add_tab("Git", m_project->root_path()); + m_git_widget = m_action_tab_widget->add_tab("Git"); m_git_widget->set_view_diff_callback([this](auto const& original_content, auto const& diff) { m_diff_viewer->set_content(original_content, diff); set_edit_mode(EditMode::Diff);