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:
parent
73fdbba59c
commit
16aba5100d
Notes:
sideshowbarker
2024-07-19 17:44:17 +09:00
Author: https://github.com/aanddrew
Commit: 16aba5100d
Pull-request: https://github.com/SerenityOS/serenity/pull/526
Reviewed-by: https://github.com/awesomekling
1 changed files with 14 additions and 2 deletions
|
@ -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&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue