From 6e6498839674b7bfcddea6e40faf62ba3b5c447b Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Fri, 13 Aug 2021 13:10:58 +0200 Subject: [PATCH] HackStudio: Update the window title after changing an active editor Prior this change, the window title was updated only when a new file has been opened, which means that it wasn't updated when user selected an already opened file in the split view. This change updates the title whenever the active editor changes. In addition, this title update logic has now its own function as it'll also be used in the next commit. :) --- Userland/DevTools/HackStudio/HackStudioWidget.cpp | 7 ++++++- Userland/DevTools/HackStudio/HackStudioWidget.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 15db0dab88..b888d3cbd5 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -288,7 +288,6 @@ bool HackStudioWidget::open_file(const String& full_filename) if (filename.starts_with(m_project->root_path())) relative_file_path = filename.substring(m_project->root_path().length() + 1); - window()->set_title(String::formatted("{} - {} - Hack Studio", relative_file_path, m_project->name())); m_project_tree_view->update(); current_editor_wrapper().set_filename(filename); @@ -826,6 +825,7 @@ Project& HackStudioWidget::project() void HackStudioWidget::set_current_editor_wrapper(RefPtr editor_wrapper) { m_current_editor_wrapper = editor_wrapper; + update_window_title(); } void HackStudioWidget::configure_project_tree_view() @@ -1194,4 +1194,9 @@ void HackStudioWidget::update_gml_preview() m_gml_preview_widget->load_gml(gml_content); } +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 6e00dc5634..19fe065c2f 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -122,6 +122,7 @@ private: bool any_document_is_dirty() const; void update_gml_preview(); + void update_window_title(); NonnullRefPtrVector m_all_editor_wrappers; RefPtr m_current_editor_wrapper;