summaryrefslogtreecommitdiff
path: root/Userland/Applications/HexEditor
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-06-23 09:19:58 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-23 13:08:14 +0200
commitb246221eac48145c9ee2601cfd4715706b86834c (patch)
treeb36f34f97d585e7ae60a97ee9b62297075b5b2ad /Userland/Applications/HexEditor
parent5edc0d11b01ed7a55bde9885ed0ac7e57e2db5bd (diff)
downloadserenity-b246221eac48145c9ee2601cfd4715706b86834c.zip
HexEditor: Prompt the user to save changes when opening a file
Diffstat (limited to 'Userland/Applications/HexEditor')
-rw-r--r--Userland/Applications/HexEditor/HexEditorWidget.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp
index 6117d2a286..6cf46ec832 100644
--- a/Userland/Applications/HexEditor/HexEditorWidget.cpp
+++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp
@@ -92,6 +92,14 @@ HexEditorWidget::HexEditorWidget()
if (!open_path.has_value())
return;
+ if (m_document_dirty) {
+ auto save_document_first_result = GUI::MessageBox::show(window(), "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
+ if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes)
+ m_save_action->activate();
+ if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && m_document_dirty)
+ return;
+ }
+
open_file(open_path.value());
});