mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
HackStudio: Preserve the untitled filename text on file modification
Previously, the title of an unnamed file would just disappear from the editor label if you started typing.
This commit is contained in:
parent
c1063e3219
commit
eb5320023a
Notes:
sideshowbarker
2024-07-19 17:14:44 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/eb5320023ad Pull-request: https://github.com/SerenityOS/serenity/pull/9899
2 changed files with 7 additions and 2 deletions
|
@ -26,7 +26,7 @@ EditorWrapper::EditorWrapper()
|
|||
label_wrapper.set_layout<GUI::HorizontalBoxLayout>();
|
||||
label_wrapper.layout()->set_margins({ 0, 2 });
|
||||
|
||||
m_filename_label = label_wrapper.add<GUI::Label>("(Untitled)");
|
||||
m_filename_label = label_wrapper.add<GUI::Label>(untitled_label);
|
||||
m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
m_filename_label->set_fixed_height(14);
|
||||
|
||||
|
@ -123,7 +123,10 @@ void EditorWrapper::set_project_root(LexicalPath const& project_root)
|
|||
void EditorWrapper::update_title()
|
||||
{
|
||||
StringBuilder title;
|
||||
title.append(m_filename);
|
||||
if (m_filename.is_null())
|
||||
title.append(untitled_label);
|
||||
else
|
||||
title.append(m_filename);
|
||||
|
||||
if (m_document_dirty)
|
||||
title.append(" (*)");
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
Function<void()> on_change;
|
||||
|
||||
private:
|
||||
static constexpr auto untitled_label = "(Untitled)";
|
||||
|
||||
EditorWrapper();
|
||||
|
||||
void update_title();
|
||||
|
|
Loading…
Reference in a new issue