1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:28:12 +00:00

Spreadsheet: Show the opened filename in the window title

Prior to this commit, there was a set_filename() function that could set
the window title, but actually it never did that.  It was called only
in one place -- by the 'Save as...' action, but it always failed to
change anything, because there was a check that tried to reassign
the same filename. :/

This patch:
1. removes that check, and therefore
2. renames the function to simply `update_window_title()`,
3. starts calling the function from more places (at startup and after
   loading a file),
4. changes the window title order
   (`{app_name} - {filename}` -> `{filename} - {app_name}`) to match
   the other applications style on the system. :^)
This commit is contained in:
Karol Kosek 2022-02-26 17:32:54 +01:00 committed by Ali Mohammad Pur
parent b59773de17
commit dc65543fa9
3 changed files with 13 additions and 12 deletions

View file

@ -140,6 +140,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
return;
save(save_path.value());
update_window_title();
} else {
save(current_filename());
}
@ -152,9 +153,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
return;
save(save_path.value());
if (!current_filename().is_empty())
set_filename(current_filename());
update_window_title();
});
m_quit_action = GUI::CommonActions::make_quit_action([&](auto&) {
@ -457,6 +456,7 @@ void SpreadsheetWidget::load_file(Core::File& file)
}
setup_tabs(m_workbook->sheets());
update_window_title();
}
bool SpreadsheetWidget::request_close()
@ -473,6 +473,7 @@ bool SpreadsheetWidget::request_close()
return false;
save(save_path.value());
update_window_title();
} else {
save(current_filename());
}
@ -506,16 +507,16 @@ void SpreadsheetWidget::add_sheet(NonnullRefPtr<Sheet>&& sheet)
setup_tabs(new_sheets);
}
void SpreadsheetWidget::set_filename(const String& filename)
void SpreadsheetWidget::update_window_title()
{
if (m_workbook->set_filename(filename)) {
StringBuilder builder;
builder.append("Spreadsheet - ");
StringBuilder builder;
if (current_filename().is_empty())
builder.append("Untitled");
else
builder.append(current_filename());
builder.append("[*] - Spreadsheet");
window()->set_title(builder.string_view());
window()->update();
}
window()->set_title(builder.to_string());
}
void SpreadsheetWidget::clipboard_action(bool is_cut)