mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
TextEditor: Show "Untitled" when there's no current document path
This commit is contained in:
parent
7c0e43eb3d
commit
2dc09d1cd7
3 changed files with 8 additions and 3 deletions
|
@ -540,7 +540,10 @@ void TextEditorWidget::set_path(const LexicalPath& lexical_path)
|
|||
void TextEditorWidget::update_title()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_path);
|
||||
if (m_path.is_empty())
|
||||
builder.append("Untitled");
|
||||
else
|
||||
builder.append(m_path);
|
||||
if (m_document_dirty)
|
||||
builder.append(" (*)");
|
||||
builder.append(" - Text Editor");
|
||||
|
|
|
@ -54,10 +54,11 @@ public:
|
|||
void set_preview_mode(PreviewMode);
|
||||
void set_auto_detect_preview_mode(bool value) { m_auto_detect_preview_mode = value; }
|
||||
|
||||
void update_title();
|
||||
|
||||
private:
|
||||
TextEditorWidget();
|
||||
void set_path(const LexicalPath& file);
|
||||
void update_title();
|
||||
void update_preview();
|
||||
void update_markdown_preview();
|
||||
void update_html_preview();
|
||||
|
|
|
@ -56,7 +56,6 @@ int main(int argc, char** argv)
|
|||
auto app_icon = GUI::Icon::default_icon("app-text-editor");
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("Text Editor");
|
||||
window->resize(640, 400);
|
||||
|
||||
auto& text_widget = window->set_main_widget<TextEditorWidget>();
|
||||
|
@ -84,6 +83,8 @@ int main(int argc, char** argv)
|
|||
|
||||
if (file_to_edit)
|
||||
text_widget.open_sesame(file_to_edit);
|
||||
else
|
||||
text_widget.update_title();
|
||||
|
||||
window->show();
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
|
Loading…
Add table
Reference in a new issue