From e2dcf27a2e39ef1d088aea858f51a7eafb9737ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Cholewa?= Date: Sat, 21 Dec 2019 23:20:43 +0100 Subject: [PATCH] TextEditor: Ask before opening a file if current document is dirty This commit should be a fix of issue #892 --- Applications/TextEditor/TextEditorWidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 96dce569e2..6e4ebfc2eb 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -153,6 +153,14 @@ TextEditorWidget::TextEditorWidget() if (!open_path.has_value()) return; + if (m_document_dirty) { + auto save_document_first_box = GMessageBox::construct("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) + m_save_action->activate(); + } + open_sesame(open_path.value()); });