mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
FontEditor: Warn on unsaved changes
Standardizes saving conventions: Editor now warns on close, new, and open if there are unsaved changes, and new files prompt to Save As.
This commit is contained in:
parent
67f81adc55
commit
8febfb169d
3 changed files with 102 additions and 11 deletions
|
@ -52,7 +52,7 @@ int main(int argc, char** argv)
|
|||
|
||||
RefPtr<Gfx::BitmapFont> edited_font;
|
||||
if (path == nullptr) {
|
||||
path = "/tmp/saved.font";
|
||||
path = "Untitled.font";
|
||||
edited_font = static_ptr_cast<Gfx::BitmapFont>(Gfx::FontDatabase::default_font().clone());
|
||||
} else {
|
||||
auto bitmap_font = Gfx::BitmapFont::load_from_file(path);
|
||||
|
@ -74,14 +74,20 @@ int main(int argc, char** argv)
|
|||
auto window = GUI::Window::construct();
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
window->resize(440, 470);
|
||||
window->set_title(String::formatted("{} - Font Editor", path));
|
||||
|
||||
auto& font_editor = window->set_main_widget<FontEditorWidget>(path, move(edited_font));
|
||||
font_editor.update_title();
|
||||
|
||||
auto menubar = GUI::Menubar::construct();
|
||||
font_editor.initialize_menubar(menubar);
|
||||
window->set_menubar(move(menubar));
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
if (font_editor.request_close())
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
return GUI::Window::CloseRequestDecision::StayOpen;
|
||||
};
|
||||
|
||||
window->show();
|
||||
|
||||
return app->exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue