1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 19:05:07 +00:00

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. :^)
This commit is contained in:
Karol Kosek 2022-12-22 12:55:11 +01:00 committed by Andreas Kling
parent 661c02b914
commit 98fa3736ed
3 changed files with 10 additions and 12 deletions

View file

@ -22,8 +22,7 @@
namespace HackStudio { namespace HackStudio {
GitWidget::GitWidget(DeprecatedString const& repo_root) GitWidget::GitWidget()
: m_repo_root(repo_root)
{ {
set_layout<GUI::HorizontalBoxLayout>(); set_layout<GUI::HorizontalBoxLayout>();

View file

@ -27,7 +27,7 @@ public:
void change_repo(DeprecatedString const& repo_root); void change_repo(DeprecatedString const& repo_root);
private: private:
explicit GitWidget(DeprecatedString const& repo_root); explicit GitWidget();
bool initialize(); bool initialize();
bool initialize_if_needed(); bool initialize_if_needed();

View file

@ -88,8 +88,6 @@ ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(DeprecatedStri
widget->set_layout<GUI::VerticalBoxLayout>(); widget->set_layout<GUI::VerticalBoxLayout>();
widget->layout()->set_spacing(2); widget->layout()->set_spacing(2);
widget->open_project(path_to_project);
auto& toolbar_container = widget->add<GUI::ToolbarContainer>(); auto& toolbar_container = widget->add<GUI::ToolbarContainer>();
auto& outer_splitter = widget->add<GUI::HorizontalSplitter>(); auto& outer_splitter = widget->add<GUI::HorizontalSplitter>();
@ -98,14 +96,17 @@ ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(DeprecatedStri
auto& left_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>(); auto& left_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>();
left_hand_splitter.layout()->set_spacing(6); left_hand_splitter.layout()->set_spacing(6);
left_hand_splitter.set_preferred_width(150); 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->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<GUI::VerticalSplitter>(); widget->m_right_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>();
widget->m_right_hand_stack = widget->m_right_hand_splitter->add<GUI::StackWidget>(); widget->m_right_hand_stack = widget->m_right_hand_splitter->add<GUI::StackWidget>();
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. // Put a placeholder widget front & center since we don't have a file open yet.
widget->m_right_hand_stack->add<GUI::Widget>(); widget->m_right_hand_stack->add<GUI::Widget>();
@ -126,8 +127,6 @@ ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(DeprecatedStri
widget->m_save_as_action = widget->create_save_as_action(); widget->m_save_as_action = widget->create_save_as_action();
widget->m_new_project_action = widget->create_new_project_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_tab_widget_action = widget->create_add_editor_tab_widget_action();
widget->m_add_editor_action = widget->create_add_editor_action(); widget->m_add_editor_action = widget->create_add_editor_action();
widget->m_add_terminal_action = widget->create_add_terminal_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->set_model(m_project->model());
m_project_tree_view->update(); 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->change_repo(root_path);
m_git_widget->refresh(); m_git_widget->refresh();
} }
@ -1327,7 +1326,7 @@ ErrorOr<void> HackStudioWidget::create_action_tab(GUI::Widget& parent)
}; };
m_disassembly_widget = m_action_tab_widget->add_tab<DisassemblyWidget>("Disassembly"); m_disassembly_widget = m_action_tab_widget->add_tab<DisassemblyWidget>("Disassembly");
m_git_widget = m_action_tab_widget->add_tab<GitWidget>("Git", m_project->root_path()); m_git_widget = m_action_tab_widget->add_tab<GitWidget>("Git");
m_git_widget->set_view_diff_callback([this](auto const& original_content, auto const& diff) { m_git_widget->set_view_diff_callback([this](auto const& original_content, auto const& diff) {
m_diff_viewer->set_content(original_content, diff); m_diff_viewer->set_content(original_content, diff);
set_edit_mode(EditMode::Diff); set_edit_mode(EditMode::Diff);