mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:27:44 +00:00
FontEditor: Add a "Save as..." menu item
This commit is contained in:
parent
03e722f664
commit
315dc8d81b
3 changed files with 25 additions and 6 deletions
|
@ -219,12 +219,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
|
|||
save_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
save_button.set_preferred_size(80, 0);
|
||||
save_button.set_text("Save");
|
||||
save_button.on_click = [this](auto) {
|
||||
auto ret_val = m_edited_font->write_to_file(m_path);
|
||||
if (!ret_val) {
|
||||
GUI::MessageBox::show("The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
}
|
||||
};
|
||||
save_button.on_click = [this](auto) { save_as(m_path); };
|
||||
|
||||
auto& quit_button = bottom_container.add<GUI::Button>();
|
||||
quit_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
|
@ -296,3 +291,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
|
|||
FontEditorWidget::~FontEditorWidget()
|
||||
{
|
||||
}
|
||||
|
||||
bool FontEditorWidget::save_as(const String& path)
|
||||
{
|
||||
auto ret_val = m_edited_font->write_to_file(path);
|
||||
if (!ret_val) {
|
||||
GUI::MessageBox::show("The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
return false;
|
||||
}
|
||||
m_path = path;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue