1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 10:01:13 +09:00

TextEditor: Implement File/New Action

The user is asked if they want to save a dirty file before they create
a new one.
This commit is contained in:
Andrew Weller 2019-09-05 23:05:28 -06:00 committed by Andreas Kling
parent 73fdbba59c
commit 16aba5100d
Notes: sideshowbarker 2024-07-19 17:44:17 +09:00

View file

@ -116,8 +116,20 @@ TextEditorWidget::TextEditorWidget()
statusbar->set_text(builder.to_string());
};
m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [](const GAction&) {
dbgprintf("FIXME: Implement File/New\n");
m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) {
if (m_document_dirty) {
GMessageBox save_document_first_box("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window());
auto save_document_first_result = save_document_first_box.exec();
if (save_document_first_result != GDialog::ExecResult::ExecOK)
return;
m_save_action->activate();
}
m_document_dirty = false;
m_editor->set_text(StringView());
set_path(FileSystemPath());
update_title();
});
m_open_action = GAction::create("Open...", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [this](const GAction&) {