HackStudio: Update the tree view cursor on editor change and 'Save as'
The more important thing here is to update the tree view on 'Save As..', as we want to drop every connection from an old file. Updating the tree view on current editor change is just a cool small bonus. :^)
This commit is contained in:
parent
b92a6d6542
commit
a230524c46
Notes:
sideshowbarker
2024-07-19 17:18:14 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/a230524c466 Pull-request: https://github.com/SerenityOS/serenity/pull/9597
2 changed files with 14 additions and 0 deletions
|
@ -690,6 +690,9 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
|
|||
m_open_files_vector.append(relative_file_path);
|
||||
|
||||
update_window_title();
|
||||
|
||||
m_project->model().invalidate();
|
||||
update_tree_view();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -887,6 +890,7 @@ void HackStudioWidget::set_current_editor_wrapper(RefPtr<EditorWrapper> editor_w
|
|||
{
|
||||
m_current_editor_wrapper = editor_wrapper;
|
||||
update_window_title();
|
||||
update_tree_view();
|
||||
}
|
||||
|
||||
void HackStudioWidget::configure_project_tree_view()
|
||||
|
@ -1257,6 +1261,15 @@ void HackStudioWidget::update_gml_preview()
|
|||
m_gml_preview_widget->load_gml(gml_content);
|
||||
}
|
||||
|
||||
void HackStudioWidget::update_tree_view()
|
||||
{
|
||||
auto index = m_project->model().index(m_current_editor_wrapper->filename(), GUI::FileSystemModel::Column::Name);
|
||||
if (index.is_valid()) {
|
||||
m_project_tree_view->expand_all_parents_of(index);
|
||||
m_project_tree_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set);
|
||||
}
|
||||
}
|
||||
|
||||
void HackStudioWidget::update_window_title()
|
||||
{
|
||||
window()->set_title(String::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_label().text(), m_project->name()));
|
||||
|
|
|
@ -125,6 +125,7 @@ private:
|
|||
bool any_document_is_dirty() const;
|
||||
|
||||
void update_gml_preview();
|
||||
void update_tree_view();
|
||||
void update_window_title();
|
||||
|
||||
NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
|
||||
|
|
Loading…
Add table
Reference in a new issue