diff options
author | Karol Kosek <krkk@krkk.ct8.pl> | 2021-08-22 19:38:05 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-25 17:42:54 +0200 |
commit | a230524c4668c72b5a519a8f441637f54bee6654 (patch) | |
tree | f803866e60d0101066724d2e4e23d2cc39fe3c02 /Userland/DevTools | |
parent | b92a6d654296718fd3e49a7bf37fda3ade4263ed (diff) | |
download | serenity-a230524c4668c72b5a519a8f441637f54bee6654.zip |
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. :^)
Diffstat (limited to 'Userland/DevTools')
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.cpp | 13 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 4932b6ddec..bf715e6e9b 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -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())); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 8703eeb312..b690676e5e 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -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; |